B
B
beduin012015-04-24 19:19:44
Operating Systems
beduin01, 2015-04-24 19:19:44

Do I understand correctly how green threads work?

I'm trying to understand how green threads work. As far as I understand, not all languages ​​can do it. Out of the box, they go only to Go and D.
As I understand this matter:
0. Gourutins = faebers = green threads
1. Many threads can be executed inside each process (how is this limited by the way?)
2. Faebers can exchange data through the stack.
3. In order to be able to exchange data through the stack, the pointer to the stack is artificially shifted higher than necessary
4. Faebers can move from one thread to another if the thread is blocked
I did not find information:
5. What is the maximum stack size in the OS?
6. can each process have its own stack?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Cheremisin, 2015-04-24
@leahch

There are also "green threads" out of the box in scala and erlang. Well, in many functional languages ​​like haskel.
The maximum stack size is usually limited by the size of physical memory. Unless restrictions are imposed, which can usually be changed or removed altogether. On Linux, start looking at the /etc/security/limits.conf file and the ulimit command
Each process has its own stack! A thread, any, shares the stack with all the threads of the process.

A
asd111, 2015-04-25
@asd111

5. The maximum stack size depends on the OS. On Linux, this is usually 8 Mb, but the size can be changed with ulimit -s and beyond. You can set unlimited then the stack size will be limited by the size of free RAM. On windows, I don't know how. Another stack size can be specified through compiler flags (at least in gcc).

A
Alexey Pomogaev, 2015-04-25
@Foror

You have not clarified the main thing - why green threads are needed. Otherwise, a more interesting question would be asked - How do green threads crowd out each other when IO occurs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question