task switching at Page Faults
Hi all.
I am in doubt about the linux kernel behaviour is this situation:
supose a have the process A, with the highest realtime priority and SCHED_FIFO policy. The process then issues a syscall, say read():
1) Can I be sure that there will be no process switch during the
syscall processing, even if the system call causes a page fault?
2) What if the process was a non-realtime processes (ordinary
one, SCHED_OTHER)?
Thanks a lot.
Fabiano
Quoted 9 lines
Hi all.
I am in doubt about the linux kernel behaviour is this situation:
supose a have the process A, with the highest realtime priority andSCHED_FIFOpolicy. The process then issues a syscall, sayread():1) Can I be sure that there will be no process switch during the
syscall processing, even if the system call causes a page fault?
No. If the data read is not in cache and if read operations causes page fault there will be process switch.
Additionally, if you don't mlock memory, there can be process switch at any place, because of page faults on code pages or swapping of data pages.
Quoted 2 lines
2) What if the process was a non-realtime processes (ordinary
one,SCHED_OTHER)?
There can be process switches too.
Mikulas
--- Mikulas Patocka
<[email protected]> escreveu: > > Hi all.
Quoted 14 lines
Quoted 2 lines
I am in doubt about the linux kernel behaviour is
this situation:
Quoted 1 line
supose a have the process A, with the highest
realtime
Quoted 1 line
priority and
SCHED_FIFOpolicy. The process thenissues a syscall,
Quoted 3 lines
say
read():1) Can I be sure that there will be no process
switch during the
Quoted 1 line
syscall processing, even if the system call causes
a page fault?
Quoted 8 lines
No. If the data read is not in cache and if read operations causes page
fault there will be process switch.Additionally, if you don't mlock memory, there can be process switch at
any place, because of page faults on code pages or swapping of data pages.
I was reading the book "Understanding the Linux
kernel", about 2.4, and the authors:
1)assure that there is no process switch during
the execution of an eception handler (aka syscall). they emphasize it.
2) say that the execption handler may not generate
exceptions, except for page faults.
So, if process switching occurs at page faults, I
was wondering which statement is true of if I am missing sth.
You mentioned page faults due to code. Aren´t the
syscall handlers located in mlocked?
Thanks again
Fabiano
Quoted 10 lines
Quoted 2 lines
2) What if the process was a non-realtime
processes (ordinary
Quoted 1 line
one,
SCHED_OTHER)?There can be process switches too.
Mikulas
=====
Fabiano Ramos
Mestrando em Engenharia de Sistemas e Computação
COPPE / UFRJ
http://www.cos.ufrj.br/~ramosf
[email protected]
______________________________________________________________________
Yahoo! Messenger - Fale com seus amigos online. Instale agora!
http://br.download.yahoo.com/messenger/
Quoted 22 lines
Quoted 13 lines
Quoted 1 line
I am in doubt about the linux kernel behaviour is
this situation:
Quoted 1 line
supose a have the process A, with the highest
realtime
Quoted 1 line
priority and
SCHED_FIFOpolicy. The process thenissues a syscall,
Quoted 3 lines
say
read():1) Can I be sure that there will be no process
switch during the
Quoted 1 line
syscall processing, even if the system call causes
a page fault?
Quoted 8 lines
No. If the data read is not in cache and if read operations causes page
fault there will be process switch.Additionally, if you don't mlock memory, there can be process switch at
any place, because of page faults on code pages or swapping of data pages.
Quoted 5 lines
I was reading the book "Understanding the Linux
kernel", about 2.4, and the authors:
1)assure that there is no process switch during
the execution of an eception handler (aka syscall). they emphasize it.
It is wrong. The process switch will occur, if the process blocks waiting for some resource (disk IO, keyboard, net or similar). Moreover, on 2.6 kernels, if you turn on CONFIG_PREEMPT, process switch in kernel may occur almost anywhere
Quoted 2 lines
2) say that the execption handler may not generate
exceptions, except for page faults.
That's true. Kernel can generate only page fault.
Quoted 5 lines
So, if process switching occurs at page faults, I
was wondering which statement is true of if I am missing sth.
You mentioned page faults due to code. Aren´t the
syscall handlers located in mlocked?
Kernel is nonswappable, but when the syscalls returns from kernel, it can generate page-fault because of its code or data were paged-out.
Mikulas
Quoted 2 lines
Thanks again
Fabiano
Quoted 10 lines · Fabiano Ramos
Hi all.
I am in doubt about the linux kernel behaviour is this situation:
supose a have the process A, with the highest realtime priority andSCHED_FIFOpolicy. The process then issues a syscall, sayread():1) Can I be sure that there will be no process switch during the
syscall processing, even if the system call causes a page fault?
Quoted 6 lines
2) What if the process was a non-realtime processes (ordinary
one,SCHED_OTHER)?Thanks a lot.
Fabiano
Read() from a device will probably sleep so you will certainly end up losing the CPU while the data are being fetched. You can prevent any of your processes pages from being faulted out. See mlockall() and friends.
Normally, a system call does not cause a context switch. The kernel handles the requirements of the caller in the context of the caller just like a library. BUT.... If the kernel needs to wait for something, it will always give the CPU to some runable task. That causes a context-switch. The kernel does not busy-wait, i.e, spin.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5596.77 BogoMips).
Note 96.31% of all statistics are fiction.
Quoted 9 lines · Fabiano Ramos
Hi all.
I am in doubt about the linux kernel behaviour is this situation:
supose a have the process A, with the highest realtime priority andSCHED_FIFOpolicy. The process then issues a syscall, sayread():1) Can I be sure that there will be no process switch during the
syscall processing, even if the system call causes a page fault?
A page fault means your realtime process must wait, because the data it wants isn't available yet. (Data have to be fetched from disk/device which takes lots of time.)
There is nothing wrong with handing the cpu to some other lower priority process unser such circumstances, because your realtime process are stuck and can't use it anyway.
The realtime process wil grab the cpu as soon as it gets ready to run anyway, I believe the scheduler looks for this sort of thing when the pagefault eventually completes.
Helge Hafting