From f9229ef74bf3ad334534609a17165a4958322ae8 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Tue, 11 Sep 2001 08:15:39 +0000 Subject: Tue Sep 11 18:15:00 2001 Robert Collins * dcrt0.cc (cygwin_finished_initializing): Copy _mtinterf on fork; * fork.cc (fork_child): fixup thread-related structures after fork; * thread.cc (MTinterface::Init): Initialise the new mutex, condition and semaphore lists. (MTinterface::fixup_after_fork): Iterate through each list and fixup the objects. (pthread_cond::pthread_cond): Add this to the condition list. (pthread_cond::~pthread_cond): Remove this from the condition list. (pthread_cond::fixup_after_fork): Recreate as best we can the pre-fork state. (pthread_mutex::pthread_mutex): Add this to the mutex list. (pthread_mutex::~pthread_mutex): Remove this from the mutex list. (pthread_mutex::fixup_after_fork): Recreate as best we can the pre-fork state. (semaphore::semaphore): Store the initial value, and add this to the semaphore list. (semaphore::~semaphore): Remove this from the semaphore list. (semaphore::Post): Increment the current semaphore value. (semaphore::TryWait): Decrement the current semaphore value. (semaphore::Wait): Ditto. (semaphote::fixup_after_fork): Recreate the pre-fork state as best we can. * thread.h (pthread_mutex): New members to allow fixup_after_fork. (pthread_cond): Ditto. (semaphore): Ditto. (MTinterface): New list heads for tracking conds and semaphores. --- winsup/cygwin/thread.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'winsup/cygwin/thread.h') diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index d027830d4..e810530e0 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -270,10 +270,12 @@ public: HANDLE win32_obj_id; LONG condwaits; int pshared; + class pthread_mutex * next; int Lock (); int TryLock (); int UnLock (); + void fixup_after_fork (); pthread_mutex (unsigned short); pthread_mutex (pthread_mutexattr *); @@ -299,9 +301,11 @@ public: /* to allow atomic behaviour for cond_broadcast */ pthread_mutex_t cond_access; HANDLE win32_obj_id; + class pthread_cond * next; int TimedWait (DWORD dwMilliseconds); void BroadCast (); void Signal (); + void fixup_after_fork (); pthread_cond (pthread_condattr *); ~pthread_cond (); @@ -319,10 +323,13 @@ class semaphore:public verifyable_object { public: HANDLE win32_obj_id; + class semaphore * next; int shared; + long currentvalue; void Wait (); void Post (); int TryWait (); + void fixup_after_fork (); semaphore (int, unsigned int); ~semaphore (); @@ -358,8 +365,11 @@ public: // list of mutex's. USE THREADSAFE INSERTS AND DELETES. class pthread_mutex * mutexs; + class pthread_cond * conds; + class semaphore * semaphores; void Init (int); + void fixup_after_fork (void); MTinterface ():reent_index (0), indexallocated (0), threadcount (1) { -- cgit v1.2.3