kernel thread and user thread

In the book "UNIX Internals", it says:
The kernel retains the responsibility for process switching, because it alone has the privilege
to modify the memory management registers. User threads are not truly schedulable entities, and the
kernel has no knowledge of them. The kernel simply schedules the underlying process or LWP,
which in turn uses library functions to schedule its threads. When the process or LWP is preempted,
so are its threads. Likewise, if a user thread makes a blocking system call, it blocks the underlying
LWP. If the process has only one LWP (or if the user threads are implemented on a single-threaded
system), all its threads are blocked.
Is it still the case for freebsd?
 
I am not sure I fully understand your question.
If you mean does FreeBSD implement a 1:1 scheduling model, then the answer is :
- Yes since V6. (Although N:M was the default and recommended choice)
- 1:1 is the default and recommended choice since V7.
I know nothing about V8, but I read somewhere that N:M would no longer be supported.
 
aCOSwt said:
I am not sure I fully understand your question.
If you mean does FreeBSD implement a 1:1 scheduling model, then the answer is :
- Yes since V6. (Although N:M was the default and recommended choice)
- 1:1 is the default and recommended choice since V7.
I know nothing about V8, but I read somewhere that N:M would no longer be supported.

What do you mean by 1:1 or N:M?
The kernel schedules only processes, include processes, and it doesn't know about user thread. Is it still the case for FreeBSD nowadays?
 
jronald said:
The kernel schedules only processes, include processes, and it doesn't know about user thread.
Well, this is not exactly right.
The kernel schedules only scheduling entities which can be far smaller than an entire process.
To make short, let's call them kernel-threads.
In a 1:1 scheduling model such as the one priviledged under freeBSD 7, A single user-thread is associated to a single kernel-thread.
which means that, although the kernel knows nothing about user-threads, by scheduling a kernel-thread, a single user thread (i.e. not an entire process if this one is multi-threaded) will be scheduled.
I understand the part of the book you mention as dealing with a N:M scheduling model. In such a model, there can be more than one user-thread associated to a single kernel-thread.
"The kernel simply schedules the underlying process or LWP, [i.e kernel-thread] which in turn uses library functions to schedule its threads. When the process or LWP is preempted,
so are its threads.

In other words, all the user-threads associated with the kernel-thread will be scheduled when the kernel-thread is scheduled.
However, this does not mean that the whole user process will be scheduled. It will depend on how the userland part of the scheduler will have made the associations.
Anyway, this is no longer the priviledged approach under freeBSD since V7.
 
aCOSwt said:
Anyway, this is no longer the priviledged approach under freeBSD since V7.

Thanks a lot.
The priviledged approach is a little complicated,
I'm going to study the new ones in V7 and V8.
 
Back
Top