What data are shared between the green thread and the kernel level thread it is bound to?

143 Views Asked by At

I understand that the user level threads or green threads are managed by some user-level threading library and have to be "linked" to some operating system thread to perform its task. I understand that threads are just an abstraction for a sequence of independent code. Threads are represented with some data structures stored in the memory. In the case of user level or green threads are present in the user space and are managed by the user-level threading library. In case of OS level or kernel level threads, they are stored and managed by the kernel or OS. What I don't understand is what actually is meant by the linking a green thread to OS thread?? I know about the 1:1, n:1, n:m schemes and that is not what my question is about. My question is what data structures are copied or shared (or something else) between the green thread and the kernel thread it is bound to?? And what does the user level threading library do to these structures when green threads have to context switched??

1

There are 1 best solutions below

0
user3344003 On

There are THREADS and there are SIMULATED THREAD. What you are calling a "green thread" is a SIMULATED THREAD.

The kernel has no knowledge whatsoever of the existence of a simulated thread.

My question is what data structures are copied or shared (or something else) between the green thread and the kernel thread it is bound to?

The answer then is NONE; at least at the operating system level. The process must keep track of the threads in the user space.

I know about the 1:1, n:1, n:m schemes and that is not what my question is about.

The 1:1, n:1 and n:M schemes are complete and total academic BullS*&T designed to confuse students. There is no such thing as an n:M in threading. It is impracticable theoretical nonsense. 1:1 just means real THREADS. n:1 means SIMULATED THREADS.

Only two models exist in real life:

In the classic model, a process consisted of an execution stream and an address space.

In the current model, a process consists of multiple execution streams and an address space.

In the classic model there are no threads. If you want threads, you have to simulate them using libraries with timers; a topic that is not fit for an operating systems course, except for historical background.

In the current model, the multiple execution streams are called threads. There is no reason whatsoever to use simulated/green/user threads in the current model. The textbooks that say simulated/green/user threads have any advantage are only fit to be used for cat box liner.