简体   繁体   English

绿色线程中的I / O阻塞

[英]I/O Blocking in Green threads

I was reading about green threads and was able to understand that these threads are created by the VM or during runtime and not by the os but I am not able to understand the following statement 我正在阅读有关绿色线程的内容,并且能够理解这些线程是由VM创建的,还是在运行时而不是由OS创建的,但我无法理解以下语句

When a green thread executes a blocking system call, not only is that thread blocked, but all of the threads within the process are blocked. 当绿色线程执行阻塞系统调用时,不仅该线程被阻塞,而且进程中的所有线程都被阻止。

Can anyone please explain how is it possible ? 任何人都可以解释它是如何可能的?

That's pretty simple actually. 实际上这很简单。

"Green Threads" are implemented programmatically inside the VM, which schedules the CPU and memory among them, just like a real OS schedules those resources among OS-level processes and threads. “绿色线程”以编程方式在VM内部实现,它在其中调度CPU和内存,就像真实操作系统在OS级进程和线程之间调度这些资源一样。

But from the OS point of view, there is just one thread - the VM itself, so when it makes a blocking system call (on behalf of one of the "Green Threads" it manages internally), this single thread is naturally blocked, and can not do anything, including scheduling the "Green Threads", so the "world stops" for them too. 但是从操作系统的角度来看,只有一个线程 - 虚拟机本身,所以当它进行阻塞系统调用时(代表它内部管理的“绿色线程”之一),这个单线程自然会被阻塞,什么都做不了,包括安排“绿线”,所以“世界也停止了”。

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

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