From 222a76c37c89ee37eebecd53dd32fd481245e6fa Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 25 Oct 2001 13:24:58 +0000 Subject: * barrier.c: Move _LONG and _LPLONG defines into implement.h; rename to PTW32_INTERLOCKED_LONG and PTW32_INTERLOCKED_LPLONG respectively. * spin.c: Likewise; ptw32_interlocked_compare_exchange used in place of InterlockedCompareExchange directly. * global.c (ptw32_interlocked_compare_exchange): Add prototype for this new routine pointer to be used when InterlockedCompareExchange isn't supported by Windows. * nonportable.c (pthread_win32_process_attach_np): Check for support of InterlockedCompareExchange in kernel32 and assign its address to ptw32_interlocked_compare_exchange if it exists, or our own ix86 specific implementation ptw32_InterlockedCompareExchange. *private.c (ptw32_InterlockedCompareExchange): An implementation of InterlockedCompareExchange() which is specific to ix86; written directly in assembler for either MSVC or GNU C; needed because Windows 95 doesn't support InterlockedCompareExchange(). * sched.c (sched_get_priority_min): Extend to return THREAD_PRIORITY_IDLE. (sched_get_priority_max): Extend to return THREAD_PRIORITY_CRITICAL. --- sched.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sched.c') diff --git a/sched.c b/sched.c index bc8aca0..8ef502f 100644 --- a/sched.c +++ b/sched.c @@ -155,6 +155,8 @@ int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { + int prio; + /* Validate the thread id. */ if (thread == NULL || thread->threadH == 0) { @@ -173,15 +175,17 @@ pthread_setschedparam(pthread_t thread, int policy, return ENOTSUP; } + prio = param->sched_priority; + /* Validate priority level. */ - if (param->sched_priority < sched_get_priority_min(policy) || - param->sched_priority > sched_get_priority_max(policy)) + if (prio < sched_get_priority_min(policy) || + prio > sched_get_priority_max(policy)) { return EINVAL; } /* This is practically guaranteed to return TRUE. */ - (void) SetThreadPriority(thread->threadH, param->sched_priority); + (void) SetThreadPriority(thread->threadH, prio); return 0; } @@ -253,7 +257,7 @@ sched_get_priority_max(int policy) return sched_Max(THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); #else /* This is independent of scheduling policy in Win32. */ - return sched_Max(THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_HIGHEST); + return sched_Max(THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL) #endif } @@ -271,7 +275,7 @@ sched_get_priority_min(int policy) return sched_Min(THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); #else /* This is independent of scheduling policy in Win32. */ - return sched_Min(THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_HIGHEST); + return sched_Min(THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); #endif } -- cgit v1.2.3