Thread man­ager

Exposing the switcher's thread operations to applications

This subsystem keeps track of thread ancestry and groups (could it?), and allows its blocking operations to use handles.  It also provides the exec functionality, since it must be aware of the first thread started, um, no, the switcher (or summat) will have to inform it when all the threads have been wiped out due to an exec…  Needs more thought.

Interface

This is essentially a SWI exposition of the switcher's thread and process operations.  However, the thread manager maintains more information about threads than the switcher, and this is also reflected in the operations.

Thread-manager routines
Type Routine
SWI operation Thread​Manager_​Fork
SWI operation Thread​Manager_​Exec
SWI operation Thread​Manager_​Exit
SWI operation Thread​Manager_​Wait
SWI operation Thread​Manager_​Spawn
SWI operation Thread​Manager_​Finish
SWI operation Thread​Manager_​Join

SWI​ ​Thread​Manager_​Fork​ ​​ ​

Duplicate the current process

On exit

  • R0=child process id, or 0

Description

The current process is forked, i.e. all subcontexts of the current process are duplicated. The call returns twice: for the parent, the process id of the child is returned; for the child, zero is returned.

This routine first calls Context​Switcher_​Fork, which then calls Subsystem_​Fork on each subsystem, and then duplicates the SVC stack.

SWI​ ​Thread​Manager_​Exec​ ​​ ​

Replace program image

Description

[Edit:

Um, not entirely sure how this one is supposed to work, yet. Perhaps it's just a matter of getting OS_FSControl,2 to clear all the thread information (which would ensure Subsystem_​Terminate was called on all subsystems blocked on those threads).

Why is that functionality in OS_FSControl,2 anyway? Ideally, FileSwitch (and other subsystems) should surely get a signal from a central component (the switcher?) which they have registered with. However, for backwards compatibility, it will probably have to stay here.

]

All threads in the current process are terminated. All subcontexts [Edit: except memory?] are otherwise preserved.