summaryrefslogtreecommitdiff
path: root/lib/libpthread/pthread_misc.c
diff options
context:
space:
mode:
authorrmind <rmind@NetBSD.org>2008-01-26 17:55:29 +0000
committerrmind <rmind@NetBSD.org>2008-01-26 17:55:29 +0000
commitb5e9addd22eabcce2e017947a3b5e8569ca6500a (patch)
tree3dd6e6289a1458aafa08984cba5c0c1f18ae4180 /lib/libpthread/pthread_misc.c
parentef515ac1dc49cc036e4437a2a8dbf89d538707fe (diff)
sched_setparam: fix the case when incorrect (according to the class)
in-kernel priority is used. Reported by <drochner>. Minor fixes for scheduling calls to conform the POSIX: - If pid is equal to zero, use the calling process; - In case of permission problem, return EPERM instead of EACESS; - sched_setscheduler() should return previously used policy; - pthread_* calls should return the error code or zero; Should fix the namespace problems (and builds of some packages): - Move cpuset_t defintion from pset.h to sched.h; - Remove the #include of pset.h in pthread.h;
Diffstat (limited to 'lib/libpthread/pthread_misc.c')
-rw-r--r--lib/libpthread/pthread_misc.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/lib/libpthread/pthread_misc.c b/lib/libpthread/pthread_misc.c
index 42e77eae4a6..2c161b655f2 100644
--- a/lib/libpthread/pthread_misc.c
+++ b/lib/libpthread/pthread_misc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_misc.c,v 1.4 2008/01/15 03:37:14 rmind Exp $ */
+/* $NetBSD: pthread_misc.c,v 1.5 2008/01/26 17:55:30 rmind Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_misc.c,v 1.4 2008/01/15 03:37:14 rmind Exp $");
+__RCSID("$NetBSD: pthread_misc.c,v 1.5 2008/01/26 17:55:30 rmind Exp $");
#include <errno.h>
#include <string.h>
@@ -68,15 +68,15 @@ __strong_alias(__libc_thr_yield,pthread__sched_yield)
int
pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param)
{
- int error;
if (pthread__find(thread) != 0)
return ESRCH;
- error = _sched_getparam(getpid(), thread->pt_lid, param);
- if (error == 0)
- *policy = param->sched_class;
- return error;
+ if (_sched_getparam(getpid(), thread->pt_lid, param) < 0)
+ return errno;
+
+ *policy = param->sched_class;
+ return 0;
}
int
@@ -90,7 +90,10 @@ pthread_setschedparam(pthread_t thread, int policy,
memcpy(&sp, param, sizeof(struct sched_param));
sp.sched_class = policy;
- return _sched_setparam(getpid(), thread->pt_lid, &sp);
+ if (_sched_setparam(getpid(), thread->pt_lid, &sp) < 0)
+ return errno;
+
+ return 0;
}
int
@@ -100,7 +103,10 @@ pthread_getaffinity_np(pthread_t thread, size_t size, cpuset_t *cpuset)
if (pthread__find(thread) != 0)
return ESRCH;
- return _sched_getaffinity(getpid(), thread->pt_lid, size, cpuset);
+ if (_sched_getaffinity(getpid(), thread->pt_lid, size, cpuset) < 0)
+ return errno;
+
+ return 0;
}
int
@@ -110,7 +116,10 @@ pthread_setaffinity_np(pthread_t thread, size_t size, cpuset_t *cpuset)
if (pthread__find(thread) != 0)
return ESRCH;
- return _sched_setaffinity(getpid(), thread->pt_lid, size, cpuset);
+ if (_sched_setaffinity(getpid(), thread->pt_lid, size, cpuset) < 0)
+ return errno;
+
+ return 0;
}
int
@@ -123,7 +132,10 @@ pthread_setschedprio(pthread_t thread, int prio)
sp.sched_class = SCHED_NONE;
sp.sched_priority = prio;
- return _sched_setparam(getpid(), thread->pt_lid, &sp);
+ if (_sched_setparam(getpid(), thread->pt_lid, &sp) < 0)
+ return errno;
+
+ return 0;
}
int