summaryrefslogtreecommitdiff
path: root/lib/libpthread/thread/thr_create.c
diff options
context:
space:
mode:
authorJohn Birrell <jb@FreeBSD.org>1998-09-30 06:36:56 +0000
committerJohn Birrell <jb@FreeBSD.org>1998-09-30 06:36:56 +0000
commitdc3a8b52c0f870cb23ddea843431bacca03fc629 (patch)
treeae55e7dc9f14a22b4e9e0ff67c28ff7d6541727d /lib/libpthread/thread/thr_create.c
parent05f3e91279c3769a892dd11d1c779bdbf58aee6d (diff)
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_create.c')
-rw-r--r--lib/libpthread/thread/thr_create.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libpthread/thread/thr_create.c b/lib/libpthread/thread/thr_create.c
index 7603dd3a30c9..c7ddeb2a59c0 100644
--- a/lib/libpthread/thread/thr_create.c
+++ b/lib/libpthread/thread/thr_create.c
@@ -46,9 +46,11 @@ int
pthread_create(pthread_t * thread, const pthread_attr_t * attr,
void *(*start_routine) (void *), void *arg)
{
+ int f_gc = 0;
int i;
int ret = 0;
int status;
+ pthread_t gc_thread;
pthread_t new_thread;
pthread_attr_t pattr;
void *stack;
@@ -185,6 +187,12 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
/* Lock the thread list: */
_lock_thread_list();
+ /*
+ * Check if the garbage collector thread
+ * needs to be started.
+ */
+ f_gc = (_thread_link_list == _thread_initial);
+
/* Add the thread to the linked list of all threads: */
new_thread->nxt = _thread_link_list;
_thread_link_list = new_thread;
@@ -197,6 +205,14 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
/* Schedule the new user thread: */
_thread_kern_sched(NULL);
+
+ /*
+ * Start a garbage collector thread
+ * if necessary.
+ */
+ if (f_gc && pthread_create(&gc_thread,NULL,
+ _thread_gc,NULL) != 0)
+ PANIC("Can't create gc thread");
}
}