How is preemptive scheduling implemented for user-level threads in Linux?

Viewed 2867

With user-level threads there are N user-level threads running on top of a single kernel thread. This is in contrast to pthreads where only one user thread runs on a kernel thread.

The N user-level threads are preemptively scheduled on the single kernel thread. But what are the details of how that is done.

I heard something that suggested that the threading library sets things up so that a signal is sent by the kernel and that is the mechanism to yank execution from an individual user-level thread to a signal handler that can then do the preemptive scheduling.

But what are the details of how state such as registers and thread structs are saved and/or mutated to make this all work? Is there maybe a very simple of user-level threads that is useful for learning the details?

1 Answers
Related