* don't destroy an already dead thread. Fixed #5271. Maybe we should only make this check on the sMainThread though.

* Implementations of pthread_getschedparam and pthread_setschedparam I had since a while.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35098 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2010-01-16 15:19:50 +00:00
parent 2924bf5134
commit 0bce4bb917
1 changed files with 32 additions and 0 deletions

View File

@ -52,6 +52,10 @@ void
__pthread_destroy_thread(void)
{
pthread_thread* thread = pthread_self();
// check if the thread is already dead
if ((atomic_get(&thread->flags) & THREAD_DEAD) != 0)
return;
// call cleanup handlers
while (true) {
@ -243,6 +247,34 @@ pthread_setconcurrency(int newLevel)
}
int
pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param)
{
thread_info info;
status_t status = _kern_get_thread_info(thread->id, &info);
if (status == B_BAD_THREAD_ID)
return ESRCH;
param->sched_priority = info.priority;
if (policy != NULL)
*policy = SCHED_RR;
return 0;
}
int
pthread_setschedparam(pthread_t thread, int policy,
const struct sched_param *param)
{
status_t status;
if (policy != SCHED_RR)
return ENOTSUP;
status = _kern_set_thread_priority(thread->id, param->sched_priority);
if (status == B_BAD_THREAD_ID)
return ESRCH;
return status;
}
// #pragma mark - Haiku thread API bridge