aboutsummaryrefslogtreecommitdiff
path: root/pthreads/pthread_setschedparam.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-07-18 10:33:05 +0200
committermarha <marha@users.sourceforge.net>2011-07-18 10:33:05 +0200
commit88101146f2ec7d53ffb793e365f05097ffd35fd3 (patch)
treedb77eef572a00c62c8d9485c4786f682e20a2fd0 /pthreads/pthread_setschedparam.c
parent772373ccc8da2b2019555228f4972cc0c5a885a4 (diff)
downloadvcxsrv-88101146f2ec7d53ffb793e365f05097ffd35fd3.tar.gz
vcxsrv-88101146f2ec7d53ffb793e365f05097ffd35fd3.tar.bz2
vcxsrv-88101146f2ec7d53ffb793e365f05097ffd35fd3.zip
cvs version of pthreads
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;
}