diff options
author | David Leonard <d@cvs.openbsd.org> | 1999-05-26 00:18:27 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 1999-05-26 00:18:27 +0000 |
commit | ce75e095891d0e7855c5b4c94f24393cf7c2b610 (patch) | |
tree | d4a6264e2baa2c3ecbb2de438c063ad6883e6078 /lib/libc_r/uthread/uthread_create.c | |
parent | 8fd8f5d111ec2aa383bf3a5dd4a7f0394d0f9f57 (diff) |
sync with FreeBSD
Diffstat (limited to 'lib/libc_r/uthread/uthread_create.c')
-rw-r--r-- | lib/libc_r/uthread/uthread_create.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/lib/libc_r/uthread/uthread_create.c b/lib/libc_r/uthread/uthread_create.c index eede7c6b5e9..002f563d14a 100644 --- a/lib/libc_r/uthread/uthread_create.c +++ b/lib/libc_r/uthread/uthread_create.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: uthread_create.c,v 1.9 1999/05/12 06:00:00 d Exp $ + * $OpenBSD: uthread_create.c,v 1.10 1999/05/26 00:18:23 d Exp $ */ #include <errno.h> #include <stdlib.h> @@ -135,21 +135,26 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr, */ if (new_thread->attr.flags & PTHREAD_INHERIT_SCHED) { /* Copy the scheduling attributes: */ - new_thread->pthread_priority = _thread_run->pthread_priority; - new_thread->attr.prio = _thread_run->pthread_priority; - new_thread->attr.schedparam_policy = _thread_run->attr.schedparam_policy; + new_thread->base_priority = _thread_run->base_priority; + new_thread->attr.prio = _thread_run->base_priority; + new_thread->attr.sched_policy = _thread_run->attr.sched_policy; } else { /* * Use just the thread priority, leaving the * other scheduling attributes as their * default values: */ - new_thread->pthread_priority = new_thread->attr.prio; + new_thread->base_priority = new_thread->attr.prio; } + new_thread->active_priority = new_thread->base_priority; + new_thread->inherited_priority = 0; /* Initialise the join queue for the new thread: */ _thread_queue_init(&(new_thread->join_queue)); + /* Initialize the mutex queue: */ + TAILQ_INIT(&new_thread->mutexq); + /* Initialise hooks in the thread structure: */ new_thread->specific_data = NULL; new_thread->cleanup = NULL; @@ -173,6 +178,27 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr, /* Unlock the thread list: */ _unlock_thread_list(); + /* + * Guard against preemption by a scheduling signal. + * A change of thread state modifies the waiting + * and priority queues. + */ + _thread_kern_sched_defer(); + + if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) { + new_thread->state = PS_SUSPENDED; + PTHREAD_WAITQ_INSERT(new_thread); + } else { + new_thread->state = PS_RUNNING; + PTHREAD_PRIOQ_INSERT_TAIL(new_thread); + } + + /* + * Reenable preemption and yield if a scheduling + * signal occurred while in the critical region. + */ + _thread_kern_sched_undefer(); + /* Return a pointer to the thread structure: */ if (thread != NULL) (*thread) = new_thread; |