green-threads

why green threads do not work on multiple cores

荒凉一梦 提交于 2019-12-23 09:47:38
问题 On wikipedia: Green_threads is described as normally cannot run on multi-cores without explaining why. On a multi-core processor, native thread implementations can automatically assign work to multiple processors, whereas green thread implementations normally cannot. I understand native threads can be assigned by OS to multi-cores. Can someone explain that why green threads can not run on multi-cores? Is it because green threads are derived/spawned from native threads, they cannot be moved

How long does it take to create 1 million threads in Haskell?

房东的猫 提交于 2019-12-20 09:07:11
问题 What I understand, Haskell have green threads. But how light weight are they. Is it possible to create 1 million threads? Or How long would it take for 100 000 threads? 回答1: from here. import Control.Concurrent import Control.Monad n = 100000 main = do left <- newEmptyMVar right <- foldM make left [0..n-1] putMVar right 0 -- bang! x <- takeMVar left -- wait for completion print x where make l n = do r <- newEmptyMVar forkIO (thread n l r) return r thread :: Int -> MVar Int -> MVar Int -> IO (

`eventlet.spawn` doesn't work as expected

好久不见. 提交于 2019-12-17 19:54:46
问题 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 a long time to run.), and the user is redirected to some other page. After searching for an async library for python , I started with eventlet , here's what I wrote in a flask view function: db.save(task) eventlet.spawn(executor, task) return

Combining two Runnable objects

大城市里の小女人 提交于 2019-12-10 10:47:57
问题 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 thread? The second part of the question is if this is possible, can I then specify the order that they will run in? EDIT!: The reason why I wanted to do this was because I need to run code on the EDT but some of the other code needs to be run on another

Combining two Runnable objects

◇◆丶佛笑我妖孽 提交于 2019-12-06 10:43:49
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 thread? The second part of the question is if this is possible, can I then specify the order that they will run in? EDIT!: The reason why I wanted to do this was because I need to run code on the EDT but some of the other code needs to be run on another thread. Please take a look at the code below. Something like this public final class CompoundRunnable

What other systems beside Erlang are based on “Green Processes”?

喜欢而已 提交于 2019-12-06 03:17:35
问题 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 based Go Native Process based C, C++ Updated : Nobody answered the question directly and so I have accepted an answer that provided me with more information with regards to Green Processes in general. 回答1: Regarding the whole "green thread" as a name, see

Which green threads libraries are available for C that can match the performance and ease of use of Haskell's green threads? [closed]

两盒软妹~` 提交于 2019-12-03 03:43:56
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am well used to relying on GHC's forkIO for portable lightweight threads when programming in Haskell. What are equivalent libraries for C that can provide the same scalibility and ease of use? Specifically I need C-equivalents of at least the following two functions. forkIO :: IO () -> IO ThreadId killThread :

What's the difference between “green threads” and Erlang's processes?

自作多情 提交于 2019-11-30 14:00:58
问题 After reading about Erlang's lighweight processes I was pretty much sure that they were "green threads". Until I read that there are differences between green threads and Erlang's processes. But I don't get it. What are the actual differences? 回答1: Green Threads can share data memory amongst themselves directly (although synchronization is required of course). Erlang doesn't use "Green Threads" but rather something closer to "Green Processes": processes do not share data memory directly but

Green-threads and thread in Python

风流意气都作罢 提交于 2019-11-28 16:40:59
As Wikipedia states : Green threads emulate multi-threaded 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. Python's threads are implemented as pthreads (kernel threads) , and because of the global interpreter lock (GIL), a Python process only runs one thread at a time. [ QUESTION ] But in the case of Green-threads (or so-called greenlet or tasklets), Does the GIL affect them? Can there be more than one greenlet running at a time? What are the

`eventlet.spawn` doesn't work as expected

喜夏-厌秋 提交于 2019-11-28 11:40:05
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 a long time to run.), and the user is redirected to some other page. After searching for an async library for python , I started with eventlet , here's what I wrote in a flask view function: db.save(task) eventlet.spawn(executor, task) return redirect("/show_tasks") With the code above, the executor didn't execute at all. What may be the problem