summaryrefslogtreecommitdiff
path: root/lib/librthread/rthread.c
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-04-29 06:01:38 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-04-29 06:01:38 +0000
commit1da00ba6dd51a3720813a564ab780bb7f6742fbc (patch)
tree3b940db3b6c287b34875c8ab181a2751a2c58fa9 /lib/librthread/rthread.c
parent3008e883ed6e89f83c8f9c2ee9c9544a5772c93a (diff)
Delete the duplicated sched_{policy,param} members from the internal struct
pthread and instead use the values from the embedded struct pthread_attr. For bonus points, pay attention to the sched_inherit attribute and possibly set the values from the parent thread. Problem noted by natano of bitrig.
Diffstat (limited to 'lib/librthread/rthread.c')
-rw-r--r--lib/librthread/rthread.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c
index 688f438a27b..72babbf5032 100644
--- a/lib/librthread/rthread.c
+++ b/lib/librthread/rthread.c
@@ -1,4 +1,4 @@
-/* $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.
@@ -197,6 +197,7 @@ _rthread_init(void)
_thread_pagesize = (size_t)sysconf(_SC_PAGESIZE);
_rthread_attr_default.guard_size = _thread_pagesize;
+ thread->attr = _rthread_attr_default;
_rthread_initlib();
@@ -429,6 +430,12 @@ pthread_create(pthread_t *threadp, const pthread_attr_t *attr,
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;