xref: /haiku/src/system/libroot/os/scheduler.c (revision d9cebac2b77547b7064f22497514eecd2d047160)
1 /*
2  * Copyright 2004-2007, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *      Jérôme Duval, korli@users.sourceforge.net.
7  *      Michael Pfeiffer, laplace@users.sourceforge.net
8  */
9 
10 
11 #include <scheduler.h>
12 
13 
14 static struct {
15 	uint32 what;
16 	int32 priority;
17 } gWhatPriorityArray[] = {
18 	// highest priority first
19 	{B_MIDI_PROCESSING, 0x78},
20 	{B_AUDIO_RECORDING | B_AUDIO_PLAYBACK, 0x73},
21 	{B_LIVE_AUDIO_MANIPULATION, 0x6e},
22 	{B_VIDEO_RECORDING, 0x19},
23 	{B_VIDEO_PLAYBACK, 0x14},
24 	{B_USER_INPUT_HANDLING, 0x0f},
25 	{B_LIVE_VIDEO_MANIPULATION, 0x0e},
26 	{B_LIVE_3D_RENDERING, 0x0c},
27 	{B_STATUS_RENDERING, 0xa},
28 	{B_OFFLINE_PROCESSING, 0x06},
29 	{B_NUMBER_CRUNCHING, 0x05},
30 	{(uint32)-1, -1}
31 };
32 
33 int32
34 suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter, bigtime_t length)
35 {
36 	int i;
37 	int32 priority = what == B_DEFAULT_MEDIA_PRIORITY ? 0x0a : 0;
38 		// default priority
39 
40 	for (i = 0; gWhatPriorityArray[i].what != (uint32)-1; i ++) {
41 		if ((what & gWhatPriorityArray[i].what) != 0) {
42 			priority = gWhatPriorityArray[i].priority;
43 			break;
44 		}
45 	}
46 
47 	return priority;
48 }
49 
50 bigtime_t
51 estimate_max_scheduling_latency(thread_id th)
52 {
53 	if (th == -1)
54 		th = find_thread(NULL);
55 
56 	return 0;
57 }
58 
59