summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_create.c
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2003-12-26 08:16:17 +0000
committermtm <mtm@FreeBSD.org>2003-12-26 08:16:17 +0000
commitdd97c7c8fa6bc63be1c3715c5dfc8a981728d162 (patch)
treee82fd13767afbd3c3f05d29966af62c023d34a05 /lib/libthr/thread/thr_create.c
parent57cde0f9a725c266d83624b53174fd6d15564985 (diff)
downloadFreeBSD-src-dd97c7c8fa6bc63be1c3715c5dfc8a981728d162.zip
FreeBSD-src-dd97c7c8fa6bc63be1c3715c5dfc8a981728d162.tar.gz
Preparations to make libthr work in multi-threaded fork()ing applications.
o Remove some code duplication between _thread_init(), which is run once to initialize libthr and the intitial thread, and pthread_create(), which initializes newly created threads, into a new function called from both places: init_td_common() o Move initialization of certain parts of libthr into a separate function. These include: - Active threads list and it's lock - Dead threads list and it's lock & condition variable - Naming and insertion of the initial thread into the active threads list.
Diffstat (limited to 'lib/libthr/thread/thr_create.c')
-rw-r--r--lib/libthr/thread/thr_create.c25
1 files changed, 1 insertions, 24 deletions
diff --git a/lib/libthr/thread/thr_create.c b/lib/libthr/thread/thr_create.c
index 41019ad..f1a6301 100644
--- a/lib/libthr/thread/thr_create.c
+++ b/lib/libthr/thread/thr_create.c
@@ -97,20 +97,11 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr,
}
/* Initialise the thread structure: */
- memset(new_thread, 0, sizeof(struct pthread));
+ init_td_common(new_thread, pattr, 0);
new_thread->stack = stack;
new_thread->start_routine = start_routine;
new_thread->arg = arg;
- new_thread->cancelflags = PTHREAD_CANCEL_ENABLE |
- PTHREAD_CANCEL_DEFERRED;
-
- /*
- * Write a magic value to the thread structure
- * to help identify valid ones:
- */
- new_thread->magic = PTHREAD_MAGIC;
-
/* Initialise the machine context: */
getcontext(&new_thread->ctx);
new_thread->ctx.uc_stack.ss_sp = new_thread->stack;
@@ -128,9 +119,6 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr,
return (ret);
}
- /* Copy the thread attributes: */
- memcpy(&new_thread->attr, pattr, sizeof(struct pthread_attr));
-
/*
* Check if this thread is to inherit the scheduling
* attributes from its parent:
@@ -153,17 +141,6 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr,
new_thread->active_priority = new_thread->base_priority;
new_thread->inherited_priority = 0;
- /* Initialize joiner to NULL (no joiner): */
- new_thread->joiner = NULL;
-
- /* Initialize the mutex queue: */
- TAILQ_INIT(&new_thread->mutexq);
-
- /* Initialise hooks in the thread structure: */
- new_thread->specific = NULL;
- new_thread->cleanup = NULL;
- new_thread->flags = 0;
-
/*
* Initialise the unique id which GDB uses to
* track threads.
OpenPOWER on IntegriCloud