diff options
author | David Leonard <d@cvs.openbsd.org> | 1998-11-09 03:13:22 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 1998-11-09 03:13:22 +0000 |
commit | ff47464de5e68e9c49fe312c953f54b2e90f546c (patch) | |
tree | 4ec0e7f13d619e1b5bf6abfd7125a4ec17569568 /lib/libpthread/uthread/uthread_create.c | |
parent | 1b2b2c2386c6cc5ebffc769b8a39b80d47e4e0d0 (diff) |
sync with FreeBSD (rwlock, gc thread, man pages)
add (broken) mips md stuff
fix some const warnings
add sigaltstack() stub
another hash at getting shlib auto-init to work (mips/elf and i386/a.out)
Diffstat (limited to 'lib/libpthread/uthread/uthread_create.c')
-rw-r--r-- | lib/libpthread/uthread/uthread_create.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/libpthread/uthread/uthread_create.c b/lib/libpthread/uthread/uthread_create.c index 53759d8f440..68db603cac2 100644 --- a/lib/libpthread/uthread/uthread_create.c +++ b/lib/libpthread/uthread/uthread_create.c @@ -44,9 +44,9 @@ int pthread_create(pthread_t * thread, const pthread_attr_t * attr, void *(*start_routine) (void *), void *arg) { - int i; + int f_gc = 0; int ret = 0; - int status; + pthread_t gc_thread; pthread_t new_thread; pthread_attr_t pattr; void *stack; @@ -149,6 +149,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; @@ -161,6 +167,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"); } } @@ -171,6 +185,9 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr, void _thread_start(void) { + /* We just left the scheduler via longjmp: */ + _thread_kern_in_sched = 0; + /* Run the current thread's start routine with argument: */ pthread_exit(_thread_run->start_routine(_thread_run->arg)); |