On Tue Oct 16, 2007 at 20:53:51 +0900, Lin wrote:
(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 ?
Fiasco can never switch from A to B directly as both are never ready at the same time. The switch order is always A -> Linux-server -> B. Besides that the active context of the Linux server always corresponds to the L4 thread currently active, as you already stated.
I have been able to confirm this mechanism for your help. Thanks a lot !
I attached my image of context switches in L4Linux system (correct ?).
When I execute two programs which does not cause any system call or exception (except at start and end of program), they seems to switch together at almost constant intervals.
Switch together? They are scheduled in a way the Linux scheduler decides.
(Actually, other programs such as init, watchdog, pdflush also run at times.)
What is the trigger of this context switch ?
In other words, what is the [?] in (2) in my attachement ?
Is it a IPC message ? If so, what is the kind of this IPC ? And, what is the cause of it ?
Interrupts wake up the Linux server (e.g. the timer interrupt) which then stops the running user process (if any).
Regards, Lin
THE CONTEXT SWITCH MECHANISM IN L4LINUX (Lin's expectation...)
+----------------------------------------------+ | * : L4 thread scheduled by Fiasco scheduler | | # : task_struct scheduled by Linux scheduler | +----------------------------------------------+
(1) Starting state - L4 thread "A" is active. - The context of Linux server is the task_struct corresponds to "A". - L4 thread "B" is waiting IPC from Linux server. +-------------------+ | Linux server | |+-----------------+| || task_struct(A)# || |+-----------------+| |+-----------------+| || task_struct(B) || |+-----------------+| | : | +-----------------+ +-----------------+ | : | | L4 thread (A)* | | L4 thread (B) | +-------------------+ +-----------------+ +-----------------+ (Waiting IPC) (Running) (Waiting IPC)
(2) Switch to Linux server
- Linux server is scheduled by Fiasco scheduler (how to ?).
- "A" and "B" are waiting IPC from Linux server.
+-------------------+ | Linux server * | |+-----------------+| || task_struct(A)# <-----------+ |+-----------------+| | [?] |+-----------------+| | || task_struct(B) || | |+-----------------+| | | : | +-----------------+ +-----------------+ | : | | L4 thread (A) | | L4 thread (B) | +-------------------+ +-----------------+ +-----------------+ (Running) (Waiting IPC) (Waiting IPC)
(3) Linux server internal context switch - schedule() is called in Linux server, and then task_struct of "B" becomes the context of it. +-------------------+ | Linux server * | |+-----------------+| || task_struct(A) || |+--------l--------+| |+--------V--------+| || task_struct(B)# || |+-----------------+| | : | +-----------------+ +-----------------+ | : | | L4 thread (A) | | L4 thread (B) | +-------------------+ +-----------------+ +-----------------+ (Running) (Waiting IPC) (Waiting IPC)
Yes.
(4) Switch to "B" - Linux server replies IPC to "B" and wait again. - "B" is only ready, so it is scheduled.
Yes.
+-------------------+ | Linux server | |+-----------------+| || task_struct(A) || |+-----------------+| |+-----------------+| [IPC reply ?] || task_struct(B)# |-------------------------------+ |+-----------------+| V | : | +-----------------+ +-----------------+ | : | | L4 thread (A) | | L4 thread (B) | +-------------------+ +-----------------+ +-----------------+ (Waiting IPC) (Waiting IPC) (Running)
Good pictures!
Adam