On Mon, 15 Aug 2005 15:17:20 +0200 Rene Wittmann (RW) wrote:
RW> > When a thread is preempted (that means it gets involuntarily RW> > descheduled), the remaining time quantum is saved and later RW> > restored when the thread is scheduled again. If the thread RW> > yields its scheduling context (that means it voluntarily RW> > gives it away), the time quantum is no longer available to RW> > the thread. A yield can happen in two ways depending on the RW> > target thread id specified: RW> > RW> > 1) if the target ID is the NIL_ID, then the thread yields its active RW> > scheduling context to noone - the time is effectively gone. This is RW> > what next_reservation does. Note that the kernel checks RW> > the user-specified RW> > ID, to guard against the case where a thread wants to RW> > yield its active RW> > scheduling context and the time quantum on that scheduling RW> > context expires RW> > simultaneously. RW> > RW> > 2) if the target ID is a valid thread ID in the system, then RW> > the action RW> > depends on whether the specified thread is ready to run: RW> > a) if it is, then the current thread donates the current scheduling RW> > context to the specified thread and that thread then becomes the RW> > current thread. This is similar to what happens during RW> > a donating IPC. RW> > RW> > b) if the specified thread is not ready, then the current RW> > scheduling RW> > context is gone, similar to 1) RW> > RW> How can I specify the target ID? When creating the thread? But how?
The target thread ID for l4_thread_switch, i.e. the thread to yield to, is a parameter to that system call. The L4 interface (see L4.V2 manual) describes the ABI for x86: The following registers are defined for Fiasco:
EAX scheduling context ID ESI low part of the target thread ID
After the system call returns, the following registers are defined:
EAX return value (0 = success, -1 = failure) ECX low part of remaining time on yielded sched. context (if EAX is 0) EDX high part of remaining time on yielded sched. context (if EAX is 0)
You probably need not concern yourself with these low-level details of the L4 ABI - there should be bindings in l4/pkg/l4sys that provide high-level interfaces to l4_thread_switch.
-Udo.
l4-hackers@os.inf.tu-dresden.de