UML installs a SIGVTALRM handler which feeds the TIMER_IRQ.On Sun, May 26, 2013 at 1:01 AM, Hopsing K <email@example.com> wrote:
> I'm running UML in Linux 3.2 (Debian) in SKAS0 mode. I compiled UML with
> 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
> interrupt_end() which calls schedule(). I saw that SIGALRM handler is
> 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
> 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
> 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
> SIGALRM arrives.
> 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
> 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
> be welcome.
> 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
In the generic TIMER_IRQ handler Linux runs scheduler_tick() at some point.