[M3devel] swaping user threads for kernel threads w/o rebuilding everything?

Jay K jay.krell at cornell.edu
Sun Apr 29 23:20:58 CEST 2012


We fixed it a long time ago.
The problem was:


Usually fork() is followed very soon by exec().
i.e. the way Posix programs (processes) often run sub-programs (processes) is via fork and exec.
This is ok. No problem.


However there is another pattern of use of fork where "servers" call fork for each "client".
They don't exec.


It is something like creating a thread. Except that everything is read-only/copy-on-write, not really shared.


This is useful if servers have an expensive initialization, and don't need to share per-client.


Cvsup does that.


When fork is not followed by exec, whatever Modula-3 user threads existed in the "parent" process, still
exist in the "child" process.
The same is NOT true with pthreads.


cvsup depended on the threads all surviving fork.


We fixed cvsup to recreate its threads in the child process, and to fix user threads to NOT have threads
survive fork, except the one calling fork.


This highlighted other problems -- the existance of and possible need to use pthread_atfork.

I'm not really explaining it all, but mostly.
Look up pthread_atfork.

 - Jay


> Date: Sun, 29 Apr 2012 17:11:36 -0400
> From: hendrik at topoi.pooq.com
> To: m3devel at elegosoft.com
> Subject: Re: [M3devel] swaping user threads for kernel threads w/o rebuilding everything?
> 
> On Sun, Apr 29, 2012 at 06:40:51PM +0100, Daniel Alejandro Benavides D. wrote:
> > (see for example cvsup), cvsup has strong reliance on network idle 
> > times
> 
> Speaking of cvsup, I seem to remember it stopped working, perhaps 
> because of thread implementatino problems.  Is it back in order yet?
> 
> -- hendrik
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120429/9c7d1191/attachment-0002.html>


More information about the M3devel mailing list