On Mon, 16 Sep 2002, Robert Collins wrote:
> On Sat, 2002-08-17 at 06:18, Thomas Pfaff wrote:
> >
> > Rob suggested to break the pthread_fork patch into smaller chunks. Ths is
> > part 1 providing a fork save key value handling.
> > The patch will add a linked list of keys to< MTinterface and a fork buffer
> > in pthread_key where the key values are passed between parent and child.
>
> In general, I liked this patch.
> I've made some essentially stylistic alterations, to make the resulting
> code a little easier to read. I realise you followed my lead on some of
> the layout - I need to fix up my existing code too :].
>
> Here's a snapshot of HEAD with your patch after my changes.
>
> I'd love it if you sent me the source for the test case you used when
> developing this.
>
I have attached a small source file for testing.
My main goal was to get a working threaded perl, so this was the reference
source for the final testing. With all patches applied (and the changed
mutex implementation) i was able to build and run it without problems.
Thomas
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <pthread.h>
int main(void)
{
pthread_key_t p_key;
pthread_key_create (&p_key,NULL);
pthread_setspecific (p_key, (void*) 0x10);
switch (fork())
{
case -1:
return 0;
case 0:
printf ("child: %p %p\n", pthread_self(), pthread_getspecific (p_key));
break;
default:
printf ("parent: %p %p\n", pthread_self(), pthread_getspecific (p_key));
}
return 0;
}