32c32
< * $FreeBSD: head/lib/libthr/thread/thr_getschedparam.c 158073 2006-04-27 08:18:23Z davidxu $
---
> * $FreeBSD: head/lib/libthr/thread/thr_getschedparam.c 160287 2006-07-12 06:13:18Z davidxu $
49c49
< int ret, tmp;
---
> int ret;
51,54c51,54
< if ((param == NULL) || (policy == NULL))
< /* Return an invalid argument error: */
< ret = EINVAL;
< else if (pthread == curthread) {
---
> if (policy == NULL || param == NULL)
> return (EINVAL);
>
> if (pthread == curthread) {
59,64c59,74
< THR_THREAD_LOCK(curthread, curthread);
< param->sched_priority = pthread->base_priority;
< tmp = pthread->attr.sched_policy;
< THR_THREAD_UNLOCK(curthread, curthread);
< *policy = tmp;
< ret = 0;
---
> THR_LOCK(curthread);
>
> /*
> * XXX Here we need two separated syscalls, atomic is only
> * guaranteed in thread library, a new syscall is needed.
> */
>
> *policy = sched_getscheduler((pid_t)curthread->tid);
> if (*policy == -1)
> ret = errno;
> else {
> ret = sched_getparam((pid_t)curthread->tid, param);
> if (ret == -1)
> ret = errno;
> }
> THR_UNLOCK(curthread);
70,71c80,87
< param->sched_priority = pthread->base_priority;
< tmp = pthread->attr.sched_policy;
---
> *policy = sched_getscheduler((pid_t)pthread->tid);
> if (*policy == -1)
> ret = errno;
> else {
> ret = sched_getparam((pid_t)pthread->tid, param);
> if (ret == -1)
> ret = errno;
> }
74d89
< *policy = tmp;
< * $FreeBSD: head/lib/libthr/thread/thr_getschedparam.c 158073 2006-04-27 08:18:23Z davidxu $
---
> * $FreeBSD: head/lib/libthr/thread/thr_getschedparam.c 160287 2006-07-12 06:13:18Z davidxu $
49c49
< int ret, tmp;
---
> int ret;
51,54c51,54
< if ((param == NULL) || (policy == NULL))
< /* Return an invalid argument error: */
< ret = EINVAL;
< else if (pthread == curthread) {
---
> if (policy == NULL || param == NULL)
> return (EINVAL);
>
> if (pthread == curthread) {
59,64c59,74
< THR_THREAD_LOCK(curthread, curthread);
< param->sched_priority = pthread->base_priority;
< tmp = pthread->attr.sched_policy;
< THR_THREAD_UNLOCK(curthread, curthread);
< *policy = tmp;
< ret = 0;
---
> THR_LOCK(curthread);
>
> /*
> * XXX Here we need two separated syscalls, atomic is only
> * guaranteed in thread library, a new syscall is needed.
> */
>
> *policy = sched_getscheduler((pid_t)curthread->tid);
> if (*policy == -1)
> ret = errno;
> else {
> ret = sched_getparam((pid_t)curthread->tid, param);
> if (ret == -1)
> ret = errno;
> }
> THR_UNLOCK(curthread);
70,71c80,87
< param->sched_priority = pthread->base_priority;
< tmp = pthread->attr.sched_policy;
---
> *policy = sched_getscheduler((pid_t)pthread->tid);
> if (*policy == -1)
> ret = errno;
> else {
> ret = sched_getparam((pid_t)pthread->tid, param);
> if (ret == -1)
> ret = errno;
> }
74d89
< *policy = tmp;