diff options
| author | ad <ad@NetBSD.org> | 2008-06-28 10:29:37 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2008-06-28 10:29:37 +0000 |
| commit | cbd43ffa55c43f368f793c80465bfcbe883b5dc7 (patch) | |
| tree | 3475b48477d2226956925e025938382b7b57f2af /lib/libpthread/pthread.c | |
| parent | e645b45bcf30a080ba6aa204346c51b0269f8760 (diff) | |
Now that we have all the scheduling gunk, make these do something useful:
pthread_attr_get_np
pthread_attr_setschedparam
pthread_attr_getschedparam
pthread_attr_setschedpolicy
pthread_attr_getschedpolicy
Diffstat (limited to 'lib/libpthread/pthread.c')
| -rw-r--r-- | lib/libpthread/pthread.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/libpthread/pthread.c b/lib/libpthread/pthread.c index 365b7f32b0a..73bb194b169 100644 --- a/lib/libpthread/pthread.c +++ b/lib/libpthread/pthread.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread.c,v 1.102 2008/06/25 11:06:34 ad Exp $ */ +/* $NetBSD: pthread.c,v 1.103 2008/06/28 10:29:37 ad Exp $ */ /*- * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread.c,v 1.102 2008/06/25 11:06:34 ad Exp $"); +__RCSID("$NetBSD: pthread.c,v 1.103 2008/06/28 10:29:37 ad Exp $"); #define __EXPOSE_STACK 1 @@ -415,7 +415,8 @@ pthread_create(pthread_t *thread, const pthread_attr_t *attr, newthread, startfunc, arg); flag = LWP_DETACHED; - if ((newthread->pt_flags & PT_FLAG_SUSPENDED) != 0) + if ((newthread->pt_flags & PT_FLAG_SUSPENDED) != 0 || + (attr->pta_flags & PT_FLAG_EXPLICIT_SCHED) != 0) flag |= LWP_SUSPENDED; ret = _lwp_create(&newthread->pt_uc, flag, &newthread->pt_lid); if (ret != 0) { @@ -427,6 +428,16 @@ pthread_create(pthread_t *thread, const pthread_attr_t *attr, return ret; } + if ((attr->pta_flags & PT_FLAG_EXPLICIT_SCHED) != 0) { + if (p != NULL) { + (void)pthread_setschedparam(newthread, p->ptap_policy, + &p->ptap_sp); + } + if ((newthread->pt_flags & PT_FLAG_SUSPENDED) == 0) { + (void)_lwp_continue(newthread->pt_lid); + } + } + *thread = newthread; return 0; @@ -1291,3 +1302,16 @@ pthread__hashlock(volatile const void *p) v = (uintptr_t)p; return &hashlocks[((v >> 9) ^ (v >> 3)) & (NHASHLOCK - 1)].mutex; } + +int +pthread__checkpri(int pri) +{ + static int havepri, min, max; + + if (!havepri) { + min = sysconf(_SC_SCHED_PRI_MIN); + max = sysconf(_SC_SCHED_PRI_MAX); + havepri = 1; + } + return (pri < min || pri > max) ? EINVAL : 0; +} |
