Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescheduling behavior on syscalls #7

Open
11 of 25 tasks
Subv opened this issue Jan 1, 2017 · 0 comments
Open
11 of 25 tasks

Rescheduling behavior on syscalls #7

Subv opened this issue Jan 1, 2017 · 0 comments

Comments

@Subv
Copy link
Owner

Subv commented Jan 1, 2017

Our current scheduling behavior when performing syscalls is to always attempt a reschedule, which is wrong and probably breaks some things.
The correct (although perhaps incomplete) rescheduling behavior is documented here.

This issue is a running TODO list of what's implemented and what is not.

Rescheduling

Cases when a reschedule attempt happens:

  • After a call to svcExitThread.

  • After a call to svcSleepThread.

  • After a KThread is awakened by a timeout interrupt (WaitSynch timeout, Sleep timeout).

  • In a WaitSynchronization1 call if the given timeout is greater than 0 and the thread has to wait for the object.

  • In a WaitSynchronizationN call if the given timeout is greater than 0 and the thread has to wait for the objects.

  • After a SyncRequest to a KClientSession.

  • After a thread resumes from wait due to a KObject signal.

  • After svcCreateThread.

  • After svcSetThreadPriority.

  • After svcReleaseMutex if the mutex lock count reached 0.

  • After a KThread is destroyed and at least one thread was waiting for it.

  • At the end of each SVC if the thread is marked for termination (via calling svcTerminateProcess on its parent process)

  • At the end of each SVC if the thread's owner process has a KDebug event associated with it.

  • After a call to svcExitProcess.

  • After a call to svcTerminateProcess.

  • After a KProcess is destroyed and at least one thread was waiting for it.

  • After a call to svcSetResourceLimit values with resource type = CPU_TIME (9) and resource value < 0x5A.

  • After a call to svcReplyAndReceive to reply to a KServerSession.

  • After a KClientSession is closed. This also causes any waiting threads to awake with an error code.

  • After a KServerSession is closed. This also causes any waiting threads to awake with an error code.

From here on, everything should be re-verified.

  • TODO: Some magic related to AddressArbiters.
  • TODO: Some magic related to memory mappings (svcControlMemory, some cache cleaning ops also cause a reschedule?).
  • TODO: After a DMA transfer?
  • TODO: After svcMapProcessMemory?
  • TODO: After svcUnmapProcessMemory?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant