Deleted Added
full compact
thr_setschedparam.c (125968) thr_setschedparam.c (129484)
1/*
2 * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
1/*
2 * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $FreeBSD: head/lib/libthr/thread/thr_setschedparam.c 125968 2004-02-18 15:26:00Z mtm $
32 * $FreeBSD: head/lib/libthr/thread/thr_setschedparam.c 129484 2004-05-20 12:06:16Z mtm $
33 */
34#include <errno.h>
35#include <sys/param.h>
36#include <pthread.h>
37#include <stdlib.h>
38#include "thr_private.h"
39
40__weak_reference(_pthread_getschedparam, pthread_getschedparam);

--- 30 unchanged lines hidden (view full) ---

71 return (ESRCH);
72
73 /*
74 * If the pthread is waiting on a mutex grab it now. Doing it now
75 * even though we do not need it immediately greatly simplifies the
76 * LOR avoidance code.
77 */
78 do {
33 */
34#include <errno.h>
35#include <sys/param.h>
36#include <pthread.h>
37#include <stdlib.h>
38#include "thr_private.h"
39
40__weak_reference(_pthread_getschedparam, pthread_getschedparam);

--- 30 unchanged lines hidden (view full) ---

71 return (ESRCH);
72
73 /*
74 * If the pthread is waiting on a mutex grab it now. Doing it now
75 * even though we do not need it immediately greatly simplifies the
76 * LOR avoidance code.
77 */
78 do {
79 _thread_critical_enter(pthread);
80 if (pthread->state == PS_MUTEX_WAIT) {
79 PTHREAD_LOCK(pthread);
80 if ((pthread->flags & PTHREAD_FLAGS_IN_MUTEXQ) != 0) {
81 mtx = pthread->data.mutex;
82 if (_spintrylock(&mtx->lock) == EBUSY)
81 mtx = pthread->data.mutex;
82 if (_spintrylock(&mtx->lock) == EBUSY)
83 _thread_critical_exit(pthread);
83 PTHREAD_UNLOCK(pthread);
84 else
85 break;
86 } else {
87 break;
88 }
89 } while (1);
90
91 PTHREAD_ASSERT(pthread->active_priority >= pthread->inherited_priority,

--- 18 unchanged lines hidden (view full) ---

110 * mutexes this thread is waiting on and its position in the
111 * queue.
112 */
113 pthread->active_priority = param->sched_priority;
114 readjust_priorities(pthread, mtx);
115
116 }
117 pthread->attr.sched_policy = policy;
84 else
85 break;
86 } else {
87 break;
88 }
89 } while (1);
90
91 PTHREAD_ASSERT(pthread->active_priority >= pthread->inherited_priority,

--- 18 unchanged lines hidden (view full) ---

110 * mutexes this thread is waiting on and its position in the
111 * queue.
112 */
113 pthread->active_priority = param->sched_priority;
114 readjust_priorities(pthread, mtx);
115
116 }
117 pthread->attr.sched_policy = policy;
118 _thread_critical_exit(pthread);
118 PTHREAD_UNLOCK(pthread);
119 if (mtx != NULL)
120 _SPINUNLOCK(&mtx->lock);
121 return(0);
122}
119 if (mtx != NULL)
120 _SPINUNLOCK(&mtx->lock);
121 return(0);
122}