diff options
author | jeff <jeff@FreeBSD.org> | 2003-04-02 03:05:39 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2003-04-02 03:05:39 +0000 |
commit | bb610376a5e993ec00e22a5e13f106b3b43d90f6 (patch) | |
tree | 3edb86617f8b88a54083b0eeb1e45c1b253d05e0 /lib/libthr/thread/thr_create.c | |
parent | dc2ed57595804600bd48f7fa875694c5f01ec98d (diff) | |
download | FreeBSD-src-bb610376a5e993ec00e22a5e13f106b3b43d90f6.zip FreeBSD-src-bb610376a5e993ec00e22a5e13f106b3b43d90f6.tar.gz |
- Define curthread as _get_curthread() and remove all direct calls to
_get_curthread(). This is similar to the kernel's curthread. Doing
this saves stack overhead and is more convenient to the programmer.
- Pass the pointer to the newly created thread to _thread_init().
- Remove _get_curthread_slow().
Diffstat (limited to 'lib/libthr/thread/thr_create.c')
-rw-r--r-- | lib/libthr/thread/thr_create.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/libthr/thread/thr_create.c b/lib/libthr/thread/thr_create.c index 9a663b4..539a7c5 100644 --- a/lib/libthr/thread/thr_create.c +++ b/lib/libthr/thread/thr_create.c @@ -62,7 +62,6 @@ int _pthread_create(pthread_t * thread, const pthread_attr_t * attr, void *(*start_routine) (void *), void *arg) { - struct pthread *curthread = _get_curthread(); struct itimerval itimer; int f_gc = 0; int ret = 0; @@ -117,7 +116,7 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, getcontext(&new_thread->ctx); new_thread->ctx.uc_stack.ss_sp = new_thread->stack; new_thread->ctx.uc_stack.ss_size = pattr->stacksize_attr; - makecontext(&new_thread->ctx, _thread_start, 1); + makecontext(&new_thread->ctx, _thread_start, 1, new_thread); /* Copy the thread attributes: */ memcpy(&new_thread->attr, pattr, sizeof(struct pthread_attr)); @@ -209,19 +208,12 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, } void -_thread_start(void) +_thread_start(pthread_t thread) { - struct pthread *curthread = _get_curthread_slow(); - - curthread->arch_id = _set_curthread(curthread); - - if (_get_curthread() != curthread) { - _thread_printf("%x - %x\n", _get_curthread(), curthread); - abort(); - } + thread->arch_id = _set_curthread(thread); /* Run the current thread's start routine with argument: */ - pthread_exit(curthread->start_routine(curthread->arg)); + pthread_exit(thread->start_routine(thread->arg)); /* This point should never be reached. */ PANIC("Thread has resumed after exit"); |