Questions tagged [green-threads]

Green threads are threads that are scheduled by a virtual machine (VM) instead of natively by the underlying operating system. They emulate multithreaded environments in user space without relying on any native OS capabilities.

In computer programming, green threads are threads that are scheduled by a virtual machine (VM) instead of natively by the underlying operating system. Green threads emulate multithreaded environments without relying on any native OS capabilities, and they are managed in user space instead of kernel space, enabling them to work in environments that do not have native thread support.

See also the Wikipedia article.

Related tags

59 questions
5
votes
0 answers

How to run multiple blocking loops simultaneously in Common Lisp. [Combining cl-async with queues in thread-pool]

I am new to programming, as well as to Common Lisp. I am trying to solve the following problem: There are stream sources (S1, S2, S3), two processors (P1, P2) (by processor I don't mean CPU-processor, but rather processing functions/subsystems), and…
5
votes
4 answers

What other systems beside Erlang are based on "Green Processes"?

I was reading this informative page on Green Thread (Wikipedia) and I wonder: what other programming systems rely on "green processes" beside Erlang? Edit: " Green Thread != Green Process " Green Process based Erlang Inferno Green Thread…
jldupont
  • 93,734
  • 56
  • 203
  • 318
4
votes
2 answers

Is it safe to mix green threads and native threads in a single python process?

Firstly, is it safe to mix green threads such as eventlet or gevent with python native threads from the standard library, i.e. Lib/threading.py in the same python process? Secondly, if it is safe, is it a bad idea?
David Watson
  • 3,394
  • 2
  • 36
  • 51
4
votes
1 answer

What exactly makes Erlang process, green thread, coroutine "lighter" than kernel thread? What about context switching that's heavy?

Possible Duplicate: Technically why is processes in Erlang more efficient than OS threads? Any time Erlang processes or green threads or coroutines are mentioned, they are always described as "light weight" when compared to kernel threads. The…
Continuation
  • 12,722
  • 20
  • 82
  • 106
4
votes
2 answers

How does erlang implements preemptive scheduling with one OS thread?

I want to know how erlang's VM preempts the running code and contexts the stack. How it can be done in a language such as c?
4
votes
5 answers

Combining two Runnable objects

Say for example that I have a Runnable called RunnableA that does something. I also have a Runnable called RunnableB that does something else. Is there a way that I can combine these two Runnables someway so that they will run in the same…
user489041
  • 27,916
  • 55
  • 135
  • 204
3
votes
4 answers

Using Thread.new to send email on rails

I've been sending emails on my application (ruby 1.8.7, rails 2.3.2) like this Thread.new{UserMailer.deliver_signup_notification(user)} Since ruby use green threads, there's any performance advantage doing this, or I can just use…
Rafael Mueller
  • 6,028
  • 3
  • 24
  • 28
3
votes
1 answer

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 When a green thread executes a blocking system call,…
3
votes
1 answer

Why doesn't eventlet GreenPool call func after spawn_n unless waitall()?

This code prints nothing: def foo(i): print i def main(): pool = eventlet.GreenPool(size=100) for i in xrange(100): pool.spawn_n(foo, i) while True: pass But this code prints numbers: def foo(i): print i def…
Wilence
  • 343
  • 2
  • 3
  • 8
3
votes
1 answer

eventlet.greenthread.sleep VS time.sleep in monkey-patched environment

We're running a server on eventlet green-threads + monkey-patching everything. I need to implement wait loop with periodic check, and I want to put sleep inside. Is there any difference between : eventlet.greenthread.sleep(1) AND time.sleep(1) in…
Max Lobur
  • 5,662
  • 22
  • 35
3
votes
2 answers

Aren't Python tasklets breaking the rule of no "GOTO"?

I've made a huge google research about Stackless Python's tasklets. Every source mentions it as a thread stackless.com : Microthreads: tasklets wrap functions allowing them to be launched as microthreads. disinterest.orgv: Tasklets — Lightweight…
Krzysztof Wende
  • 3,208
  • 25
  • 38
3
votes
1 answer

Interaction of forkIO/killThread with forkProcess

I've written the code below, and noticed that killThread blocks and the thread still continues. That only happens if I do it in the forkProcess, if I remove the forkProcess, everything works as expected. Code {-# LANGUAGE TupleSections #-} module…
bennofs
  • 11,873
  • 1
  • 38
  • 62
3
votes
3 answers

`eventlet.spawn` doesn't work as expected

I'm writing a web UI for data analysis tasks. Here's the way it's supposed to work: After a user specifies parameters like dataset and learning rate, I create a new task record, then a executor for this task is started asyncly (The executor may take…
satoru
  • 31,822
  • 31
  • 91
  • 141
3
votes
1 answer

How can I raise exception in main thread when using eventlet.GreenPool.spawn

I run some task using eventlet.GreenPool.spawn, then wait for all greanthreads to finish. I know there would be an exception raised - how can I catch that exception and throw it in a main thread? I am pretty sure it's easy however I'm totally…
lukaszb
  • 694
  • 1
  • 6
  • 15
2
votes
2 answers

At which point a goroutine can yield?

I am trying to gain better understanding of how goroutines are scheduled in Go programs, especially at which points they can yield to other goroutines. We know that a goroutine yields on syscals that would block it, but apparently this is not the…
greatvovan
  • 2,439
  • 23
  • 43