[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gwydion & threads



Eric Gouriou <eric_gouriou@pobox.com> writes:
>   But then it's debatable whether you support threads :-)
> 
>   Such a threading model would be closer to co-routines
> than to the Posix thread model. I won't argue whether
> Posix threads are really the right programming model,
> but that's certainly what many programmer expect when
> you mention "threads".

Rob Pike says, "If people understood fork(), they wouldn't have
threads."  In Plan 9, the operating system provides lightweight,
shared memory, loci of scheduling, called processes (modern versions
of unix do the same); the runtime system of your programming langauge
provides coroutines.  Conflating the two things, as pthreads does,
just causes confusion.  A common idiom is to use a process to connect
an external source of data (a network connections, say) with a
coroutine.  That way your program doesn't block when you talk to the
outside world, but still has a nice clean concurrent style with no
extra OS overhead.