xref: /haiku/src/system/libroot/os/scheduler.c (revision 1384a3a81f0d40727f2e04accc7ca073dd3e19be)
15af32e75SAxel Dörfler /*
2fc069a2aSMichael Pfeiffer  * Copyright 2004-2007, Haiku. All rights reserved.
3fc069a2aSMichael Pfeiffer  * Distributed under the terms of the MIT License.
4fc069a2aSMichael Pfeiffer  *
5fc069a2aSMichael Pfeiffer  * Authors:
6fc069a2aSMichael Pfeiffer  *      Jérôme Duval, korli@users.sourceforge.net.
7fc069a2aSMichael Pfeiffer  *      Michael Pfeiffer, laplace@users.sourceforge.net
85af32e75SAxel Dörfler  */
95af32e75SAxel Dörfler 
105af32e75SAxel Dörfler 
115af32e75SAxel Dörfler #include <scheduler.h>
125af32e75SAxel Dörfler 
13fc069a2aSMichael Pfeiffer 
14fc069a2aSMichael Pfeiffer static struct {
15fc069a2aSMichael Pfeiffer 	uint32 what;
16fc069a2aSMichael Pfeiffer 	int32 priority;
17fc069a2aSMichael Pfeiffer } gWhatPriorityArray[] = {
18fc069a2aSMichael Pfeiffer 	// highest priority first
19fc069a2aSMichael Pfeiffer 	{B_MIDI_PROCESSING, 0x78},
20fc069a2aSMichael Pfeiffer 	{B_AUDIO_RECORDING | B_AUDIO_PLAYBACK, 0x73},
21fc069a2aSMichael Pfeiffer 	{B_LIVE_AUDIO_MANIPULATION, 0x6e},
22fc069a2aSMichael Pfeiffer 	{B_VIDEO_RECORDING, 0x19},
23fc069a2aSMichael Pfeiffer 	{B_VIDEO_PLAYBACK, 0x14},
24fc069a2aSMichael Pfeiffer 	{B_USER_INPUT_HANDLING, 0x0f},
25fc069a2aSMichael Pfeiffer 	{B_LIVE_VIDEO_MANIPULATION, 0x0e},
26fc069a2aSMichael Pfeiffer 	{B_LIVE_3D_RENDERING, 0x0c},
27fc069a2aSMichael Pfeiffer 	{B_STATUS_RENDERING, 0xa},
28fc069a2aSMichael Pfeiffer 	{B_OFFLINE_PROCESSING, 0x06},
29fc069a2aSMichael Pfeiffer 	{B_NUMBER_CRUNCHING, 0x05},
30fc069a2aSMichael Pfeiffer 	{(uint32)-1, -1}
31fc069a2aSMichael Pfeiffer };
32fc069a2aSMichael Pfeiffer 
335af32e75SAxel Dörfler int32
345af32e75SAxel Dörfler suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter, bigtime_t length)
355af32e75SAxel Dörfler {
36*1384a3a8SMichael Pfeiffer 	int i;
37fc069a2aSMichael Pfeiffer 	int32 priority = what == B_DEFAULT_MEDIA_PRIORITY ? 0x0a : 0;
38fc069a2aSMichael Pfeiffer 		// default priority
39fc069a2aSMichael Pfeiffer 
40*1384a3a8SMichael Pfeiffer 	for (i = 0; gWhatPriorityArray[i].what != (uint32)-1; i ++) {
41fc069a2aSMichael Pfeiffer 		if ((what & gWhatPriorityArray[i].what) != 0) {
42fc069a2aSMichael Pfeiffer 			priority = gWhatPriorityArray[i].priority;
43fc069a2aSMichael Pfeiffer 			break;
44fc069a2aSMichael Pfeiffer 		}
45fc069a2aSMichael Pfeiffer 	}
46fc069a2aSMichael Pfeiffer 
47fc069a2aSMichael Pfeiffer 	return priority;
485af32e75SAxel Dörfler }
495af32e75SAxel Dörfler 
505af32e75SAxel Dörfler bigtime_t
515af32e75SAxel Dörfler estimate_max_scheduling_latency(thread_id th)
525af32e75SAxel Dörfler {
535af32e75SAxel Dörfler 	if (th == -1)
545af32e75SAxel Dörfler 		th = find_thread(NULL);
555af32e75SAxel Dörfler 
565af32e75SAxel Dörfler 	return 0;
575af32e75SAxel Dörfler }
585af32e75SAxel Dörfler 
59