How is the time slice split between pthreads in the process?

The Linux kernel knows about pthreads in the user's address space (which I don’t think it is ... but I did not find any information about this). How does the instruction pointer change when switching threads.

+5
source share
3 answers

The native NPTL (native posix thread library) used on Linux maps pthreads to "processes that share resources and therefore look like threads" in the kernel. Thus, the kernel scheduler directly controls pthreads scheduling.

The "Pthread switch" is executed using the same code (in the kernel) that processes the process switches. Simplified, it will be something like "save the previous state of the process, if the next process uses a different virtual address space, and then switches the virtual address spaces, load the next state of the process"; (where "process status" includes an instruction pointer for the process / thread).

+5
source

Well, the Linux kernel does not know about user threads (pthread does in user space, moreover, the kernel really does not care about them, except you just need to know what to plan).

. ​​ , ? task_struct, , ( , ..) .

+2

1) The kernel does not know about user level threads. However, NPTL is not a user level

2) This is a very broad question. You should look at the OS book. He will delve into this problem and everyone else involved in the context switch.

+1
source

All Articles