summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-25 15:46:04 +0000
committerrpj <rpj>1998-07-25 15:46:04 +0000
commitd2298ecbc9910e9186dad3eeb7fa8eed7bca9a80 (patch)
tree70b888de3962c85cd93d6fcef87fcd05f9e35c4d
parent9ec682372a4f13353f7437fcffd48b75b5489a8f (diff)
Sun Jul 26 00:09:59 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* sync.c: Rename all instances of _pthread_count_mutex to _pthread_table_mutex. * implement.h: Rename _pthread_count_mutex to _pthread_table_mutex. * global.c: Rename _pthread_count_mutex to _pthread_table_mutex. * create.c (pthread_create): Add critical sections. (_pthread_start_call): Rename _pthread_count_mutex to _pthread_table_mutex.
-rw-r--r--ChangeLog13
-rw-r--r--create.c29
-rw-r--r--global.c2
-rw-r--r--implement.h2
-rw-r--r--sync.c12
5 files changed, 44 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index f351b15..ba1c3b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
Sun Jul 26 00:09:59 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
+ * sync.c: Rename all instances of _pthread_count_mutex to
+ _pthread_table_mutex.
+
+ * implement.h: Rename _pthread_count_mutex to
+ _pthread_table_mutex.
+
+ * global.c: Rename _pthread_count_mutex to
+ _pthread_table_mutex.
+
+ * create.c (pthread_create): Add critical sections.
+ (_pthread_start_call): Rename _pthread_count_mutex to
+ _pthread_table_mutex.
+
* cancel.c (pthread_setcancelstate): Fix indirection bug and rename
"this" to "us".
diff --git a/create.c b/create.c
index 3a3f4b5..4639b21 100644
--- a/create.c
+++ b/create.c
@@ -52,7 +52,7 @@ _pthread_start_call(void * us_arg)
was called and there are no waiting joins. */
/* CRITICAL SECTION */
- pthread_mutex_lock(&_pthread_count_mutex);
+ pthread_mutex_lock(&_pthread_table_mutex);
if (us->detach == TRUE
&& us->join_count == 0)
@@ -60,7 +60,7 @@ _pthread_start_call(void * us_arg)
_pthread_delete_thread_entry(us);
}
- pthread_mutex_lock(&_pthread_count_mutex);
+ pthread_mutex_lock(&_pthread_table_mutex);
/* END CRITICAL SECTION */
}
else
@@ -73,7 +73,7 @@ _pthread_start_call(void * us_arg)
was called and there are no waiting joins. */
/* CRITICAL SECTION */
- pthread_mutex_lock(&_pthread_count_mutex);
+ pthread_mutex_lock(&_pthread_table_mutex);
if (us->detach == TRUE
&& us->join_count == 0)
@@ -81,7 +81,7 @@ _pthread_start_call(void * us_arg)
_pthread_delete_thread_entry(us);
}
- pthread_mutex_lock(&_pthread_count_mutex);
+ pthread_mutex_lock(&_pthread_table_mutex);
/* END CRITICAL SECTION */
ret = 0;
@@ -105,9 +105,17 @@ pthread_create(pthread_t *thread,
pthread_attr_t * attr_copy;
_pthread_threads_thread_t * us;
/* Success unless otherwise set. */
- int ret = 0;
+ int ret;
- if (_pthread_new_thread_entry((pthread_t) handle, us) == 0)
+ /* CRITICAL SECTION */
+ pthread_mutex_lock(&_pthread_table_mutex);
+
+ ret = _pthread_new_thread_entry((pthread_t) handle, us);
+
+ pthread_mutex_lock(&_pthread_table_mutex);
+ /* END CRITICAL SECTION */
+
+ if (ret == 0)
{
attr_copy = &(us->attr);
@@ -154,9 +162,18 @@ pthread_create(pthread_t *thread,
}
else
{
+ /* CRITICAL SECTION */
+ pthread_mutex_lock(&_pthread_table_mutex);
+
/* Remove the failed thread entry. */
_pthread_delete_thread_entry(us);
+
+ pthread_mutex_lock(&_pthread_table_mutex);
+ /* END CRITICAL SECTION */
}
return ret;
}
+
+
+
diff --git a/global.c b/global.c
index 406d203..8b317b9 100644
--- a/global.c
+++ b/global.c
@@ -34,7 +34,7 @@ const int _pthread_cancel_asynchronous = 0;
const int _pthread_cancel_deferred = 1;
-pthread_mutex_t _pthread_count_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t _pthread_table_mutex = PTHREAD_MUTEX_INITIALIZER;
DWORD _pthread_threads_count = 0;
diff --git a/implement.h b/implement.h
index 7c6c6d2..cde8a33 100644
--- a/implement.h
+++ b/implement.h
@@ -116,7 +116,7 @@ void _pthread_vacuum(void);
/* Global data declared in global.c */
-extern pthread_mutex_t _pthread_count_mutex;
+extern pthread_mutex_t _pthread_table_mutex;
extern DWORD _pthread_threads_count;
diff --git a/sync.c b/sync.c
index 721574e..7483598 100644
--- a/sync.c
+++ b/sync.c
@@ -76,7 +76,7 @@ pthread_join(pthread_t thread, void ** valueptr)
target_thread_mutex = _PTHREAD_THREAD_MUTEX(target);
/* CRITICAL SECTION */
- pthread_mutex_lock(&_pthread_count_mutex);
+ pthread_mutex_lock(&_pthread_table_mutex);
/* If the thread is in DETACHED state, then join will return
immediately. */
@@ -89,7 +89,7 @@ pthread_join(pthread_t thread, void ** valueptr)
target->join_count++;
- pthread_mutex_lock(&_pthread_count_mutex);
+ pthread_mutex_lock(&_pthread_table_mutex);
/* END CRITICAL SECTION */
/* CANCELATION POINT */
@@ -116,7 +116,7 @@ pthread_join(pthread_t thread, void ** valueptr)
following critical section. */
/* CRITICAL SECTION */
- pthread_mutex_lock(&_pthread_count_mutex);
+ pthread_mutex_lock(&_pthread_table_mutex);
/* Collect the value pointer passed to pthread_exit(). If
another thread detaches our target thread while we're
@@ -144,7 +144,7 @@ pthread_join(pthread_t thread, void ** valueptr)
_pthread_delete_thread_entry(target);
}
- pthread_mutex_lock(&_pthread_count_mutex);
+ pthread_mutex_lock(&_pthread_table_mutex);
/* END CRITICAL SECTION */
return ret;
@@ -163,7 +163,7 @@ pthread_detach(pthread_t thread)
pthread_mutex_t * target_thread_mutex;
/* CRITICAL SECTION */
- pthread_mutex_lock(&_pthread_count_mutex);
+ pthread_mutex_lock(&_pthread_table_mutex);
target = _pthread_find_thread_entry(thread);
@@ -195,7 +195,7 @@ pthread_detach(pthread_t thread)
}
}
- pthread_mutex_unlock(&_pthread_count_mutex);
+ pthread_mutex_unlock(&_pthread_table_mutex);
/* END CRITICAL SECTION */
return ret;