Skip to content

Instantly share code, notes, and snippets.

@TuxSH
Last active August 6, 2018 18:04
Show Gist options
  • Save TuxSH/242416cff54a95c3ffe5aab41206177e to your computer and use it in GitHub Desktop.
Save TuxSH/242416cff54a95c3ffe5aab41206177e to your computer and use it in GitHub Desktop.
svcGetLastThreadInfo
  • GetLastThreadInfo returns the last thread of the process that was scheduled on the current core.
  • A thread holds a reference to itself; only a thread that has exited can be destroyed

Two possibilities arise:

  • the thread exited before the svc, in which case it clears cctx->scheduler->previousScheduledThread, and that field will never point to the exiting thread. This is safe.
  • the svc executes first: it fetches the last thread ptr & info with all interrupts masked. Therefore, the thread executing the svc will not be switched and no thread on the same core is going to be terminated/destroyed, this is also safe.

Similar remarks for svcGetFutureThreadInfo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment