On Thu, 13 Jan 2011, Ben Pfaff wrote:
> (Alan Curry) writes:
>
>> In article <>,
>> Ian Collins <ian-> wrote:
>>>
>>>Just as we don't want C to be left behind. The C++ standard has adapted
>>>to modern hardware by incorporating threading into the core language and
>>>the C1x drafts do likewise.
>>
>> If anything like pthreads gets added, and fork() doesn't, it'll be a tragedy.
>
>Threads affect the language a lot more than fork() does. It's a
>lot easier to add fork() as an afterthought than it is to add
>threads.
>--
>Ben Pfaff
>http://benpfaff.org
>
Of course it is easy to add fork() on some platforms, but I think including
threads to the standard but fork() not would make fork() look like some 2nd
class threading, so people would always use threading instead of several
processes. Of course there are some scenarios were threads are actually better
than processes ( e.g. scientific calculations), but in most of the cases
processes with separated address spaces lead to programs much easier to debug and to maintain. Wouldn't it be possible to add a clone(2)-like library function where you can specify how much you want to share with your child process. You had to find a way how to support separated data on platforms without separated process memory, but couldn't you just handle per process data like a variable with prefix? (So if the programmer says "I want to have 2 processes, one containing var1 and one containig var2" you could simulate it by dividing your programs memory and only refer to the memory used by the simulated process you're in)
I have no experience with writing compilers or operating systems, so the
approach may be quite naive, but I would be glad to hear some feedback where I'm
wrong