[Midnightbsd-cvs] src [7491] trunk/lib/libthr/thread: tweak threading priority
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Mar 20 19:13:12 EDT 2016
Revision: 7491
http://svnweb.midnightbsd.org/src/?rev=7491
Author: laffer1
Date: 2016-03-20 19:13:12 -0400 (Sun, 20 Mar 2016)
Log Message:
-----------
tweak threading priority
Modified Paths:
--------------
trunk/lib/libthr/thread/thr_setprio.c
trunk/lib/libthr/thread/thr_setschedparam.c
trunk/lib/libthr/thread/thr_spec.c
Modified: trunk/lib/libthr/thread/thr_setprio.c
===================================================================
--- trunk/lib/libthr/thread/thr_setprio.c 2016-03-20 22:18:45 UTC (rev 7490)
+++ trunk/lib/libthr/thread/thr_setprio.c 2016-03-20 23:13:12 UTC (rev 7491)
@@ -45,38 +45,22 @@
int ret;
param.sched_priority = prio;
- if (pthread == curthread) {
+ if (pthread == curthread)
THR_LOCK(curthread);
- if (curthread->attr.sched_policy == SCHED_OTHER ||
- curthread->attr.prio == prio) {
- curthread->attr.prio = prio;
- ret = 0;
- } else {
- ret = _thr_setscheduler(curthread->tid,
- curthread->attr.sched_policy, ¶m);
- if (ret == -1)
- ret = errno;
- else
- curthread->attr.prio = prio;
- }
- THR_UNLOCK(curthread);
- } else if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0))
- == 0) {
- THR_THREAD_LOCK(curthread, pthread);
- if (pthread->attr.sched_policy == SCHED_OTHER ||
- pthread->attr.prio == prio) {
+ else if ((ret = _thr_find_thread(curthread, pthread, /*include dead*/0)))
+ return (ret);
+ if (pthread->attr.sched_policy == SCHED_OTHER ||
+ pthread->attr.prio == prio) {
+ pthread->attr.prio = prio;
+ ret = 0;
+ } else {
+ ret = _thr_setscheduler(pthread->tid,
+ pthread->attr.sched_policy, ¶m);
+ if (ret == -1)
+ ret = errno;
+ else
pthread->attr.prio = prio;
- ret = 0;
- } else {
- ret = _thr_setscheduler(pthread->tid,
- curthread->attr.sched_policy, ¶m);
- if (ret == -1)
- ret = errno;
- else
- pthread->attr.prio = prio;
- }
- THR_THREAD_UNLOCK(curthread, pthread);
- _thr_ref_delete(curthread, pthread);
}
+ THR_THREAD_UNLOCK(curthread, pthread);
return (ret);
}
Modified: trunk/lib/libthr/thread/thr_setschedparam.c
===================================================================
--- trunk/lib/libthr/thread/thr_setschedparam.c 2016-03-20 22:18:45 UTC (rev 7490)
+++ trunk/lib/libthr/thread/thr_setschedparam.c 2016-03-20 23:13:12 UTC (rev 7491)
@@ -53,42 +53,25 @@
struct pthread *curthread = _get_curthread();
int ret;
- if (pthread == curthread) {
+ if (pthread == curthread)
THR_LOCK(curthread);
- if (curthread->attr.sched_policy == policy &&
- (policy == SCHED_OTHER ||
- curthread->attr.prio == param->sched_priority)) {
- pthread->attr.prio = param->sched_priority;
- THR_UNLOCK(curthread);
- return (0);
- }
- ret = _thr_setscheduler(curthread->tid, policy, param);
- if (ret == -1)
- ret = errno;
- else {
- curthread->attr.sched_policy = policy;
- curthread->attr.prio = param->sched_priority;
- }
- THR_UNLOCK(curthread);
- } else if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0))
- == 0) {
- THR_THREAD_LOCK(curthread, pthread);
- if (pthread->attr.sched_policy == policy &&
- (policy == SCHED_OTHER ||
- pthread->attr.prio == param->sched_priority)) {
- pthread->attr.prio = param->sched_priority;
- THR_THREAD_UNLOCK(curthread, pthread);
- return (0);
- }
- ret = _thr_setscheduler(pthread->tid, policy, param);
- if (ret == -1)
- ret = errno;
- else {
- pthread->attr.sched_policy = policy;
- pthread->attr.prio = param->sched_priority;
- }
+ else if ((ret = _thr_find_thread(curthread, pthread,
+ /*include dead*/0)) != 0)
+ return (ret);
+ if (pthread->attr.sched_policy == policy &&
+ (policy == SCHED_OTHER ||
+ pthread->attr.prio == param->sched_priority)) {
+ pthread->attr.prio = param->sched_priority;
THR_THREAD_UNLOCK(curthread, pthread);
- _thr_ref_delete(curthread, pthread);
+ return (0);
}
+ ret = _thr_setscheduler(pthread->tid, policy, param);
+ if (ret == -1)
+ ret = errno;
+ else {
+ pthread->attr.sched_policy = policy;
+ pthread->attr.prio = param->sched_priority;
+ }
+ THR_THREAD_UNLOCK(curthread, pthread);
return (ret);
}
Modified: trunk/lib/libthr/thread/thr_spec.c
===================================================================
--- trunk/lib/libthr/thread/thr_spec.c 2016-03-20 22:18:45 UTC (rev 7490)
+++ trunk/lib/libthr/thread/thr_spec.c 2016-03-20 23:13:12 UTC (rev 7491)
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: stable/9/lib/libthr/thread/thr_spec.c 262221 2014-02-19 15:00:55Z jhb $
*/
#include "namespace.h"
@@ -70,7 +70,7 @@
/* Unlock the key table: */
THR_LOCK_RELEASE(curthread, &_keytable_lock);
- *key = i;
+ *key = i + 1;
return (0);
}
@@ -81,9 +81,10 @@
}
int
-_pthread_key_delete(pthread_key_t key)
+_pthread_key_delete(pthread_key_t userkey)
{
struct pthread *curthread = _get_curthread();
+ int key = userkey - 1;
int ret = 0;
if ((unsigned int)key < PTHREAD_KEYS_MAX) {
@@ -178,9 +179,10 @@
}
int
-_pthread_setspecific(pthread_key_t key, const void *value)
+_pthread_setspecific(pthread_key_t userkey, const void *value)
{
struct pthread *pthread;
+ pthread_key_t key = userkey - 1;
int ret = 0;
/* Point to the running thread: */
@@ -209,9 +211,10 @@
}
void *
-_pthread_getspecific(pthread_key_t key)
+_pthread_getspecific(pthread_key_t userkey)
{
struct pthread *pthread;
+ pthread_key_t key = userkey - 1;
const void *data;
/* Point to the running thread: */
More information about the Midnightbsd-cvs
mailing list