This is a discussion on Re: [9fans] Plan 9 on Blue Gene - Plan9 ; > I've been writing a lot of Erlang code lately, and I keep thinking about, > but not having too much time to do much about, wanting to have a runtime for > the libthread "threads" that could auto-schedule them ...
> I've been writing a lot of Erlang code lately, and I keep thinking about,
> but not having too much time to do much about, wanting to have a runtime for
> the libthread "threads" that could auto-schedule them to libthread "procs",
> in much the same way Haskell "sparks" may end up real threads, or Erlang
> processes, might run in parallel.
the model is that there may be any number of procs sharing memory,
channels, etc. each proc has at least one thread. threads have their
own stack and one one-at-a time.
since threads run one at a time and have a few, well-known calls that
implicitly schedule, one often needs no locking. this is like the big
kernel lock in linux. and so in general converting threadcreate to
proccreate will break programs which rely on the implicit mutex
between threads to keep memory accesses from overlapping.
my personal and uninformed opinion is that it's better to be explicit
about resource sharing and just lock critical sections—or better yet,
don't overlap data use. use channels to transfer data. if there's no
overlapping data access then proccreate and threadcreate may usually
another personal opinion is that parallelism can be a
"performance hack". however, when the speed differences
between various resources (e.g. disk drive seek vs anything else)
is great enough, the difference between working and broken
can be parallelism.