diff options
author | rpj <rpj> | 2004-05-17 01:38:02 +0000 |
---|---|---|
committer | rpj <rpj> | 2004-05-17 01:38:02 +0000 |
commit | 771465fed0cf50ee2dd790723245fc091699c324 (patch) | |
tree | d8c18d095a33fe7c4564bd90c5f313bb9e4057dd /pthread_setschedparam.c | |
parent | 8b14911744f58cbe3730703f3fcc41cd969fd0f3 (diff) |
re-indentation, bug fixes, hooks for pre-emptive async cancelation
Diffstat (limited to 'pthread_setschedparam.c')
-rw-r--r-- | pthread_setschedparam.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/pthread_setschedparam.c b/pthread_setschedparam.c index 1447c04..d23e5d0 100644 --- a/pthread_setschedparam.c +++ b/pthread_setschedparam.c @@ -39,13 +39,13 @@ #include "sched.h" int -pthread_setschedparam(pthread_t thread, int policy, - const struct sched_param *param) +pthread_setschedparam (pthread_t thread, int policy, + const struct sched_param *param) { int result; /* Validate the thread id. */ - result = pthread_kill(thread, 0); + result = pthread_kill (thread, 0); if (0 != result) { return result; @@ -63,12 +63,12 @@ pthread_setschedparam(pthread_t thread, int policy, return ENOTSUP; } - return (ptw32_setthreadpriority(thread, policy, param->sched_priority)); + return (ptw32_setthreadpriority (thread, policy, param->sched_priority)); } int -ptw32_setthreadpriority(pthread_t thread, int policy, int priority) +ptw32_setthreadpriority (pthread_t thread, int policy, int priority) { int prio; int result; @@ -76,8 +76,8 @@ ptw32_setthreadpriority(pthread_t thread, int policy, int priority) prio = priority; /* Validate priority level. */ - if (prio < sched_get_priority_min(policy) || - prio > sched_get_priority_max(policy)) + if (prio < sched_get_priority_min (policy) || + prio > sched_get_priority_max (policy)) { return EINVAL; } @@ -87,38 +87,37 @@ ptw32_setthreadpriority(pthread_t thread, int policy, int priority) #else /* Everything else */ - if (THREAD_PRIORITY_IDLE < prio - && THREAD_PRIORITY_LOWEST > prio) + if (THREAD_PRIORITY_IDLE < prio && THREAD_PRIORITY_LOWEST > prio) { prio = THREAD_PRIORITY_LOWEST; } else if (THREAD_PRIORITY_TIME_CRITICAL > prio - && THREAD_PRIORITY_HIGHEST < prio) + && THREAD_PRIORITY_HIGHEST < prio) { prio = THREAD_PRIORITY_HIGHEST; } #endif - result = pthread_mutex_lock(&thread->threadLock); + result = pthread_mutex_lock (&thread->threadLock); if (0 == result) { /* If this fails, the current priority is unchanged. */ - if (0 == SetThreadPriority(thread->threadH, prio)) - { - result = EINVAL; - } + if (0 == SetThreadPriority (thread->threadH, prio)) + { + result = EINVAL; + } else - { - /* - * Must record the thread's sched_priority as given, - * not as finally adjusted. - */ - thread->sched_priority = priority; - } - - (void) pthread_mutex_unlock(&thread->threadLock); + { + /* + * Must record the thread's sched_priority as given, + * not as finally adjusted. + */ + thread->sched_priority = priority; + } + + (void) pthread_mutex_unlock (&thread->threadLock); } return result; |