I'm running UML in Linux 3.2 (Debian) in SKAS0 mode. I compiled UML with defconfig.
Now I try to poked in the source to figure out how Preemption is done
in UML. I came so far to understand that there is a ptrace-ing parent and
for each UML process a userspace-slave process on the host:
arch/um/os-Linux/skas/process.c:userspace(). This routine also has the jump to
interrupt_end() which calls schedule(). I saw that SIGALRM handler is installed
for that ptrace-ing parent and the userspace() loop catches SIGALRM for the
traced slave. However I didnt see it being called. Only the ptrace-ing parent
gets SIGALRM and the signal handler arch/um/os-Linux/signal.c:hard_handler()
is called directly. With my understanding there must be some connection between
hard_handler() and the call to interrupt_end() inside the userspace() loop, but I
cannot find any, I cannot figure out how Preemption is initiated when the
I wonder: Is all kernel code implementing cooperative threading ? Is there
no preemption when in kernel space?
If a userspace process runs a loop "while(1);" and therefore never calls out
to the kernel, how can another process been sheduled? The ptrace-ing parent's
userspace() loop will never get control back.
I can also see a variable userspace_pid that I assume is the active
slave-process and that there is only one such process running at any time,
the others are stopped?
I'm really curious how Preemption is done internally in UML, any insight would
Some question at the side: can you call longjmp from within a signal
handler? My first assumption was that UML uses longjmp from within
the SIGALRM handler to implement preemption, butseems not to .
-- Thanks Konrad