aboutsummaryrefslogtreecommitdiff
path: root/pthreads/pthread_setschedparam.c
diff options
context:
space:
mode:
Diffstat (limited to 'pthreads/pthread_setschedparam.c')
-rw-r--r--pthreads/pthread_setschedparam.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/pthreads/pthread_setschedparam.c b/pthreads/pthread_setschedparam.c
index a122eaca6..b762753cd 100644
--- a/pthreads/pthread_setschedparam.c
+++ b/pthreads/pthread_setschedparam.c
@@ -71,7 +71,8 @@ int
ptw32_setthreadpriority (pthread_t thread, int policy, int priority)
{
int prio;
- int result;
+ ptw32_mcs_local_node_t threadLock;
+ int result = 0;
ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
prio = priority;
@@ -100,26 +101,23 @@ ptw32_setthreadpriority (pthread_t thread, int policy, int priority)
#endif
- result = pthread_mutex_lock (&tp->threadLock);
+ ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock);
- if (0 == result)
+ /* If this fails, the current priority is unchanged. */
+ if (0 == SetThreadPriority (tp->threadH, prio))
+ {
+ result = EINVAL;
+ }
+ else
{
- /* If this fails, the current priority is unchanged. */
- if (0 == SetThreadPriority (tp->threadH, prio))
- {
- result = EINVAL;
- }
- else
- {
- /*
- * Must record the thread's sched_priority as given,
- * not as finally adjusted.
- */
- tp->sched_priority = priority;
- }
-
- (void) pthread_mutex_unlock (&tp->threadLock);
+ /*
+ * Must record the thread's sched_priority as given,
+ * not as finally adjusted.
+ */
+ tp->sched_priority = priority;
}
+ ptw32_mcs_lock_release (&threadLock);
+
return result;
}