News for hackers. Stuff that matters.
Re:ARM is now a fully supported target platform for GHC Haskell by dons on Monday June 11, 2012 @09:02AM (#4094345)
GHC uses pre-emptive thread switching, not co-operative thread switching. Threads are forced by the runtime to be switched out -- they have no choice in the matter -- based on rts interrupts.

Typically, threads will be switched when they allocate.

See

https://github.com/ghc/ghc/blob/master/rts/Schedule.c#L208

and for low-level fun:

https://github.com/ghc/ghc/blob/master/includes/stg/SMP.h

Re:ARM is now a fully supported target platform for GHC Haskell by exDM69 on Monday June 11, 2012 @10:26AM (#4094729)
> GHC uses pre-emptive thread switching, not co-operative thread switching. > Threads may be switched when they allocate.

If threads are scheduled in and out when they allocate memory or are about to issue a possibly blocking system call, it's called co-operative multithreading, isn't it?

If the thread execution was stopped using external means like a timer interrupt, that would be pre-emptive. Some definitions of pre-emptive involve the ability to stop a lower priority thread in favor of a higher priority thread that becomes ready when a syscall is finished.

The best I understand the situation, Haskell's green threads voluntarily (co-operatively) give up their time slice (for another green thread) when allocating memory or doing I/O. Haskell's green threads run on top of several native threads that are pre-emptively scheduled by the operating system.

Please correct me if I'm wrong.

Re:ARM is now a fully supported target platform for GHC Haskell by dons on Wednesday June 20, 2012 @11:24AM (#4137397)
The threads do not volunteer. They are pre-empted by an external authority - the runtime system. They have no choice in the matter.