-/* $OpenBSD: rthread.c,v 1.80 2015/04/07 01:27:07 guenther Exp $ */
+/* $OpenBSD: rthread.c,v 1.81 2015/04/29 06:01:37 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
_thread_pagesize = (size_t)sysconf(_SC_PAGESIZE);
_rthread_attr_default.guard_size = _thread_pagesize;
+ thread->attr = _rthread_attr_default;
_rthread_initlib();
thread->tid = -1;
thread->attr = attr != NULL ? *(*attr) : _rthread_attr_default;
+ if (thread->attr.sched_inherit == PTHREAD_INHERIT_SCHED) {
+ pthread_t self = pthread_self();
+
+ thread->attr.sched_policy = self->attr.sched_policy;
+ thread->attr.sched_param = self->attr.sched_param;
+ }
if (thread->attr.detach_state == PTHREAD_CREATE_DETACHED)
thread->flags |= THREAD_DETACHED;
thread->flags |= THREAD_CANCEL_ENABLE|THREAD_CANCEL_DEFERRED;
-/* $OpenBSD: rthread.h,v 1.50 2014/08/31 04:02:08 guenther Exp $ */
+/* $OpenBSD: rthread.h,v 1.51 2015/04/29 06:01:37 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
LIST_ENTRY(pthread) threads;
TAILQ_ENTRY(pthread) waiting;
pthread_cond_t blocking_cond;
- int sched_policy;
struct pthread_attr attr;
- struct sched_param sched_param;
struct rthread_storage *local_storage;
struct rthread_cleanup_fn *cleanup_fns;
int myerrno;
-/* $OpenBSD: rthread_sched.c,v 1.12 2012/03/22 15:26:04 kurt Exp $ */
+/* $OpenBSD: rthread_sched.c,v 1.13 2015/04/29 06:01:37 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
pthread_getschedparam(pthread_t thread, int *policy,
struct sched_param *param)
{
- *policy = thread->sched_policy;
+ *policy = thread->attr.sched_policy;
if (param)
- *param = thread->sched_param;
+ *param = thread->attr.sched_param;
return (0);
}
if (policy != SCHED_OTHER && policy != SCHED_FIFO &&
policy != SCHED_RR)
return (EINVAL);
- thread->sched_policy = policy;
+ thread->attr.sched_policy = policy;
if (param)
- thread->sched_param = *param;
+ thread->attr.sched_param = *param;
return (0);
}
int
-pthread_attr_getschedparam(const pthread_attr_t *attrp, struct sched_param *param)
+pthread_attr_getschedparam(const pthread_attr_t *attrp,
+ struct sched_param *param)
{
*param = (*attrp)->sched_param;
}
int
-pthread_attr_setschedparam(pthread_attr_t *attrp, const struct sched_param *param)
+pthread_attr_setschedparam(pthread_attr_t *attrp,
+ const struct sched_param *param)
{
(*attrp)->sched_param = *param;
int
pthread_getprio(pthread_t thread)
{
- return (thread->sched_param.sched_priority);
+ return (thread->attr.sched_param.sched_priority);
}
int
pthread_setprio(pthread_t thread, int priority)
{
- thread->sched_param.sched_priority = priority;
+ thread->attr.sched_param.sched_priority = priority;
return (0);
}