Subject: Re: fork(2) vs. pthread_create()
To: Nathan J. Williams <nathanw@wasabisystems.com>
From: Love <lha@stacken.kth.se>
List: tech-userlevel
Date: 06/09/2004 11:05:47
--=-=-=


"Nathan J. Williams" <nathanw@wasabisystems.com> writes:

> In order for this to work, there would have to be a fork handler that
> reset all of libpthread's state to initialization values, and the
> child program would still suffer severe constraints on what program
> mutexes or variables it could use (consider, for example, the state of
> stdio mutexes at the moment of fork()).

There is already a forkhandler that reset the childstate, however it
doesn't change the state that the the rr timer is no longer there (in the
child).

The quick fix below for this specific problem, it its replaced by a
PTHREAD_DIAG thingy that would be fine too.

Love

Index: pthread_sa.c
===================================================================
RCS file: /sources/netbsd/NetBSD-cvs/src/lib/libpthread/pthread_sa.c,v
retrieving revision 1.30
diff -u -u -w -r1.30 pthread_sa.c
--- pthread_sa.c	14 Mar 2004 01:19:42 -0000	1.30
+++ pthread_sa.c	9 Jun 2004 08:56:57 -0000
@@ -624,10 +624,11 @@
 /*
  * Set the round-robin timeslice timer.
  */
+static int rrtimer_created;
+
 static int
 pthread__setrrtimer(int msec, int startit)
 {
-	static int rrtimer_created;
 	struct itimerspec it;
 
 	/*
@@ -668,6 +669,8 @@
 	int ret, i, errnosave, flags, rr;
 	char *value;
 
+	rrtimer_created = 0;
+
 	flags = 0;
 	value = getenv("PTHREAD_PREEMPT");
 	if (value && strcmp(value, "yes") == 0)

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iQEVAwUAQMbS+XW+NPVfDpmCAQKHwQgAh9SwSw6+15Mq7NP53lfYeQoqUNrbFVLw
CEBLzAWPB/XaBFGKtwVSjv6X66HEPPmDxBIFk+X87AdB3AVHeEH5DTaNNP2dVM3o
H0bU1fhNbx0tuoyMQHNp8FUogm/OQ/y2MXOqFLB/WghMA44gII3v0+ehQYxjJp07
xY65/y+Ng2BYy/mgN5/y9stgNCXa2k3y3w20D/+kbVFcqvn6etLRrSKaTAC9hf2Q
pAcUfNPy2qQi+SW8jzA3ntTKzpyFkW0bQF784cZokgUElz8UMXVV1fq6TvWWf+wZ
6OYx2MSzqEJ3pXmCeEm6RijPkwUpi90AGMZu2IM46jWLUIjmdYwhYA==
=iQ8S
-----END PGP SIGNATURE-----
--=-=-=--