about the L4Linux scheduler

Lin bugeaterk at gmail.com
Tue Oct 2 23:35:28 CEST 2007

Hello, Adam.

Thanks for your comment, it is quite helpful for me.

I could make sure many about the L4Linux scheduler, but still have a
little question.

> It's the idle thread. It is running when no other activity is in the
> L4Linux system. It just sits there are waits for things to happen.
> > And more, What is the thread "l4lx.idler" used for ??
> It wakes up the idle thread when work is to be done.

"l4lx.idler" is created by "l4lx.cpu0" in "l4x_idle" and its start
function is "idler_func" (in "arch/l4/kernel/dispatch.c").

But this function only executes

  while(1) l4_sleep_forever();

so I can't understand how "l4lx_idler" wakes up "l4lx_cpu0".

It seems to only sleep.

> >   (4) What does the function "l4x_user_dispatcher" do ?
> >       How to switch contexts in Linux and in L4 almost at the same
> >       time ? (in 3)
> Context switching in L4 is done by the kernel (Fiasco). Also note that
> the L4Linux server itself runs in an L4 thread and thus Fiasco is doing
> context switches when switching from a user process (L4 thread) to the
> L4Linux server (another L4 thread). This basically happens when the IPCs
> are sent. The context switch in the other direction happens when the
> L4Linux server replies the user process.
> The context switches in the Linux server happen inside the schedule()
> call, the L4 side is not affected by this, as it basically only means
> that the Linux server switches to another stack.

> >   - If Linux server gets IPC for some reasons, it wakes up and check
> >     the IPC sender. Then, if the sender is a thread corresponds to
> >     certain Linux task, Linux server wakes up this Linux task and
> >     reschedules by calling "schedule()".
> I don't quite understand what you want to say. If the Linux server gets
> an IPC it has to handle this request (Pagefault, syscall...). If the
> Linux system wants to reschedule, schedule() is called so that another
> context may be selected.

I may have some misunderstanding...

Could you check the following things ?

(1) When a L4 thread which is runnig as a Linux task is scheduled by
    L4, is the Linux task ("task_struct" instance) corresponds to the
    L4 thread scheduled as "l4lx.cpu0" by Linux scheduler ?
    (Of course, "l4lx.cpu0" is not scheduled by L4 at this time.)

For example, there are two user processes A and B in Linux server now.

There are two threads (tasks) corresponds to A and B in L4, and there
are two "task_struct" instances (both of them only execute the loop of
"l4x_user_dispatcher") in Linux system.

When the L4 thread of A is running (scheduled by Fiasco), the context
of "l4lx.cpu0" is "task_struct" of A.

If Fiasco switches the running thread from A to B, the context of
"l4lx.cpu0" is changed to "task_struct" of B after ? (or no change ?)

In other words, are the active L4 thread of Linux process and the L4
thread the context of "l4lx.cpu0" corresponds to always the same ?

If (1) is true (if false, please skip the following...),

(2) How does the Linux server (l4lx.cpu0) notice context switches on
    L4 to change its internal context ?

If the active L4 thread is changed from A to B, Linux server needs to
switch its context to "task_struct" of B (by calling "schedule()").

But the way Linux server knows the active L4 thread is only IPC.

I assume the following section in "l4lx_user_dispatcher"

  if(!l4_thread_equal(src_id, t->user_thread_id)) {

might relate to preparation of such context switch in Linux server,
but it is not still clear ...


More information about the l4-hackers mailing list