Hi, Ok, thanks. I got a little better picture. Is the following true:
- The ptrace-ing parent waits in waitpid() called from within the
userspace() loops.
- The SIGVTALRM comes in and the signal handler is executed, it'll end up
in scheduler_tick() and set need_resched() true.
- Because of the signal the waitpid() system call is interrupted and the
ptrace-ing parent returnes from waitpid().
- At the same time the ptraced userspace slave is stopped (is this the
case?) therefore the condition WIFSTOPPED(status) is true and
therefore you end up calling interrupt_end() ?
-- Thanks Konrad
2013/5/26 richard -rw- weinberger <richard.weinber...@gmail.com>
> On Sun, May 26, 2013 at 1:01 AM, Hopsing K <hopsi...@gmail.com> wrote:
> > 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
> > 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
> > parent's
> > userspace() loop will never get control back.
> > I can also see a variable userspace_pid[0] 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
> > 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
>
> UML installs a SIGVTALRM handler which feeds the TIMER_IRQ.
> In the generic TIMER_IRQ handler Linux runs scheduler_tick() at some point.
>
> Thanks,
> //richard
>
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel