summaryrefslogtreecommitdiff
path: root/create.c
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 /create.c
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.
Diffstat (limited to 'create.c')
-rw-r--r--create.c29
1 files changed, 23 insertions, 6 deletions
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;
}
+
+
+