execution path of a process

Virginie Galtier (virginie.galtier@nist.gov)
Tue, 05 Oct 1999 10:29:10 -0400


Please apology if my message should'nt be in this list and point me to a
more suited one, but I did'nt find the answer to my question in all the
documentation I read. I hope someone would take a couple of minutes to
help me.

My question deals with the way linux schedules processes.

Imagine we have only 2 processes P1 and P2.
P1 needs to execute the following sequence: U11 U12 U13 K11 U14 U15 K12
U16
and P2: U21 U22 U23 U24 U25
where Uxx are executed in user mode and Kxx are executed in kernel mode.

Let's say the scheduler first choses P1.

Is the following correct?

P1 executes U11 U12 U13 in user mode
then it goes through the SAVE_ALL section of entry.S and switches to
kernel mode and executes K11. When K11 completes, RESTORE_ALL is
executed and execution continues with U14 in user mode.
But the scheduler then decides it is time for another process to run so
the schedule fonction of sched.c is executed with prev = P1 and next =
P2.
P2 starts its execution in user mode with U21 U22.
But the scheduler stops it and schedule is executed with prev = P2 and
next = P1.
So P1 resumes execution with U15. Then it goes again through SAVE_ALL
and starts K12. But then it puts itself to sleep (waiting for an IO for
instance). So the sched_yield of sched.c is executed with current = P1.
Next the schedule function is executed with prev = P1 and next = P2 and
P2 runs again.
It executes U23 and U24 and then the scheduler decides to stop it.
The schedule function is executed with prev = P2 and next = P1.
P1 resumes its execution in kernel mode and completes K12. Then the
RESTORE_ALL section is executed and P1 executes U16.
Schedule is executed again and P2 can execute U25 in user mode

Is that correct? Do I miss something important?
I would like to be able to trace a process very precisely: to log
information when the process is running in user mode, when it switches
to kernel mode, when it is put to sleep while in the kernel, when it
continues its execution, when it exits kernel mode and when it leaves
the processor. Modifying SAVE_ALL, RESTORE_ALL, schedule and sched_yield
is it enough?

Thank you very much for your help.
Regards,

Virginie Galtier

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/