Added a real yield function to the kernel (using the next_priority approach).

The test application lets run a thread at the highest priority that calls
yield all the time - the system stays responsible when it runs, so it seems
to work fine :)
Changed the malloc implementation to use _kern_thread_yield() instead of
snoozing.
We should think about making this call public, too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16166 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-01-31 02:29:02 +00:00
parent d14af9fde6
commit 204131dc97
6 changed files with 75 additions and 15 deletions
+30 -2
View File
@@ -1232,19 +1232,40 @@ thread_dequeue_id(struct thread_queue *q, thread_id id)
thread_id
allocate_thread_id()
allocate_thread_id(void)
{
return atomic_add(&sNextThreadID, 1);
}
thread_id
peek_next_thread_id()
peek_next_thread_id(void)
{
return atomic_get(&sNextThreadID);
}
void
thread_yield(void)
{
cpu_status state;
struct thread *thread = thread_get_current_thread();
if (thread == NULL)
return;
state = disable_interrupts();
GRAB_THREAD_LOCK();
// just add the thread at the end of the run queue
thread->next_priority = B_LOWEST_ACTIVE_PRIORITY;
scheduler_reschedule();
RELEASE_THREAD_LOCK();
restore_interrupts(state);
}
/** Kernel private thread creation function.
*
* \param threadID The ID to be assigned to the new thread. If
@@ -2044,6 +2065,13 @@ _user_snooze_etc(bigtime_t timeout, int timebase, uint32 flags)
}
void
_user_thread_yield(void)
{
thread_yield();
}
status_t
_user_get_thread_info(thread_id id, thread_info *userInfo)
{