- 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.