Sat Apr 14 17:04:00 2001 Robert Collins <rbtcollins@hotmail.com>

* thread.h (MTinterface): Add threadcount.
	* thread.cc (MTinterface::Init): Set threadcount to 1.
	(__pthread_create): Increment threadcount.
	(__pthread_exit): Decrement threadcount and call exit() from the last thread.
This commit is contained in:
Robert Collins
2001-04-14 07:06:02 +00:00
parent a25b8414ac
commit e6b98fc8d6
3 changed files with 15 additions and 3 deletions

View File

@ -291,6 +291,7 @@ MTinterface::Init (int forked)
}
concurrency = 0;
threadcount = 1; /* 1 current thread when Init occurs.*/
if (forked)
return;
@ -664,6 +665,7 @@ __pthread_create (pthread_t * thread, const pthread_attr_t * attr,
*thread = NULL;
return EAGAIN;
}
InterlockedIncrement(&MT_INTERFACE->threadcount);
return 0;
}
@ -1214,10 +1216,12 @@ __pthread_exit (void *value_ptr)
class pthread *thread = __pthread_self ();
MT_INTERFACE->destructors.IterateNull ();
// FIXME: run the destructors of thread_key items here
thread->return_ptr = value_ptr;
ExitThread (0);
if (InterlockedDecrement(&MT_INTERFACE->threadcount) == 0)
exit (0);
else
ExitThread (0);
}
int