Hi
Theoritically, user level thread ensures thread management , such as
scheduling and context switch, to be performed without a system call
i.e Kernel intervention whereas with kernel level threads, kernel is
aware about the threads and the context switch is done by the kernel
which requires then a system call and mode switch. Meanwhile there are
three models to map user threads to kernel threads: one to one, many
to many, many to one.
My question is how can we have a conjunction of user level thread and
many to many model (or one to one model)? One to one model maps each
user thread to kernel thread which are normally used to perform
context switch at the kernel level (mode). However user level thread
dictates that context switch should be done without kernel
intervention!!
I read that Java switched from green to native mode, which involves
one to one model mapping and yet it is said that context switch is
done at the user level with no intervention from the kernel... that's
my confusion
Another question, how can i program kernel level threads in windows?
Maria wrote:
The context is just the registers the user can save and restore, basically
what setjmp(), longjmp(), or getcontext(), setcontext() does. To start
a new user level thread, you just need to allocate a new stack, create
a new context with that stack and right call linkage to the thread start
routine and swap (save current, restore new) contexts. That's simplifying
things considerably. The problem with kernel threads, is saving the
context of one kernel thread and restoring it on another can cause
undefined behavior if you're not careful. Careful means writing
your own version of any api that is aware of threads to make the
api aware of your own threads instead. That's a lot of work. Some
JVM's may use many to many threading if they started out with many
to one (ie. most of the work was done already) and they believe their
context switching is more efficient than the kernel's. This was
probably obvious to their users as they experienced their learning
curve in making the JVM internally thread-safe.
I believe win32 threads are 1-1 threading so you're doing it already.
Joe Seigh