From 8c2e9a29b1fbda33e57b2d33c7bfcb0de666b1fb Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 21 Feb 2003 10:00:33 +0000 Subject: Update. * pthreadP.h: Define INVALID_TD_P and INVALID_NOT_TERMINATED_TD_P. * pthread_cancel.c: Use INVALID_TD_P. * pthread_detach.c: Likewise. * pthread_getschedparam.c: Likewise. * pthread_setschedparam.c: Likewise. * sysdeps/pthread/pthread_getcpuclockid.c: Likewise. * sysdeps/unix/sysv/linux/pthread_kill.c: Likewise. * pthread_join.c: Use INVALID_NOT_TERMINATED_TD_P. * pthread_timedjoin.c: Likewise. * tst-basic7.c: Include . --- nptl/pthread_setschedparam.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'nptl/pthread_setschedparam.c') diff --git a/nptl/pthread_setschedparam.c b/nptl/pthread_setschedparam.c index cdba80cf07..3084836ad8 100644 --- a/nptl/pthread_setschedparam.c +++ b/nptl/pthread_setschedparam.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -25,33 +25,39 @@ int -__pthread_setschedparam (thread_id, policy, param) - pthread_t thread_id; +__pthread_setschedparam (threadid, policy, param) + pthread_t threadid; int policy; const struct sched_param *param; { - struct pthread *thread = (struct pthread *) thread_id; + struct pthread *pd = (struct pthread *) threadid; + + /* Make sure the descriptor is valid. */ + if (INVALID_TD_P (pd)) + /* Not a valid thread handle. */ + return ESRCH; + int result = 0; /* We have to handle cancellation in the following code since we are locking another threads desriptor. */ - pthread_cleanup_push ((void (*) (void *)) lll_unlock_wake_cb, &thread->lock); + pthread_cleanup_push ((void (*) (void *)) lll_unlock_wake_cb, &pd->lock); - lll_lock (thread->lock); + lll_lock (pd->lock); /* Try to set the scheduler information. */ - if (__builtin_expect (__sched_setscheduler (thread->tid, policy, + if (__builtin_expect (__sched_setscheduler (pd->tid, policy, param) == -1, 0)) result = errno; else { /* We succeeded changing the kernel information. Reflect this change in the thread descriptor. */ - thread->schedpolicy = policy; - memcpy (&thread->schedparam, param, sizeof (struct sched_param)); + pd->schedpolicy = policy; + memcpy (&pd->schedparam, param, sizeof (struct sched_param)); } - lll_unlock (thread->lock); + lll_unlock (pd->lock); pthread_cleanup_pop (0); -- cgit v1.2.3