简体   繁体   English

绿色线程和绑定到的内核级线程之间共享哪些数据?

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

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. 对于OS级或内核级线程,它们由内核或OS存储和管理。 What I don't understand is what actually is meant by the linking a green thread to OS thread?? 我不明白的是,将绿色线程链接到OS线程实际上是什么意思? I know about the 1:1, n:1, n:m schemes and that is not what my question is about. 我知道1:1,n:1,n:m方案,这不是我的问题。 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?? 当绿色线程必须进行上下文切换时,用户级线程库对这些结构做了什么?

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. 我知道1:1,n:1,n:m方案,这不是我的问题。

The 1:1, n:1 and n:M schemes are complete and total academic BullS*&T designed to confuse students. 1:1,n:1和n:M计划是完整的,旨在防止学生迷惑的学术BullS *&T。 There is no such thing as an n:M in threading. 线程中没有n:M这样的东西。 It is impracticable theoretical nonsense. 这是不切实际的理论废话。 1:1 just means real THREADS. 1:1意味着真正的线程。 n:1 means SIMULATED THREADS. n:1表示模拟线程。

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. 说模拟/绿色/用户线程具有任何优势的教科书仅适合用于猫盒衬里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM