headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / libroot / os / scheduler.c
blob4dc16b6225768ca1f4ed5d795d6b1b202b6f2a62
1 /*
2 * Copyright 2004-2010, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Jérôme Duval, korli@users.sourceforge.net.
7 * Michael Pfeiffer, laplace@users.sourceforge.net
8 */
11 #include <scheduler.h>
13 #include <syscalls.h>
16 static struct {
17 uint32 what;
18 int32 priority;
19 } sWhatPriorityArray[] = {
20 // highest priority first
21 {B_MIDI_PROCESSING, 0x78},
22 {B_AUDIO_RECORDING | B_AUDIO_PLAYBACK, 0x73},
23 {B_LIVE_AUDIO_MANIPULATION, 0x6e},
24 {B_VIDEO_RECORDING, 0x19},
25 {B_VIDEO_PLAYBACK, 0x14},
26 {B_USER_INPUT_HANDLING, 0x0f},
27 {B_LIVE_VIDEO_MANIPULATION, 0x0e},
28 {B_LIVE_3D_RENDERING, 0x0c},
29 {B_STATUS_RENDERING, 0xa},
30 {B_OFFLINE_PROCESSING, 0x06},
31 {B_NUMBER_CRUNCHING, 0x05},
32 {(uint32)-1, -1}
35 status_t __set_scheduler_mode(int32 mode);
36 int32 __get_scheduler_mode(void);
39 int32
40 suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter,
41 bigtime_t length)
43 int i;
44 int32 priority = what == B_DEFAULT_MEDIA_PRIORITY ? 0x0a : 0;
45 // default priority
47 // TODO: this needs kernel support, and is a pretty simplistic solution
49 for (i = 0; sWhatPriorityArray[i].what != (uint32)-1; i ++) {
50 if ((what & sWhatPriorityArray[i].what) != 0) {
51 priority = sWhatPriorityArray[i].priority;
52 break;
56 return priority;
60 bigtime_t
61 estimate_max_scheduling_latency(thread_id thread)
63 return _kern_estimate_max_scheduling_latency(thread);
67 status_t
68 __set_scheduler_mode(int32 mode)
70 return _kern_set_scheduler_mode(mode);
74 int32
75 __get_scheduler_mode(void)
77 return _kern_get_scheduler_mode();
81 B_DEFINE_WEAK_ALIAS(__set_scheduler_mode, set_scheduler_mode);
82 B_DEFINE_WEAK_ALIAS(__get_scheduler_mode, get_scheduler_mode);