1/*
2 * Copyright 2004-2010, 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#include <syscalls.h>
14
15
16static 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}
33};
34
35
36int32
37suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter,
38	bigtime_t length)
39{
40	int i;
41	int32 priority = what == B_DEFAULT_MEDIA_PRIORITY ? 0x0a : 0;
42		// default priority
43
44	// TODO: this needs kernel support, and is a pretty simplistic solution
45
46	for (i = 0; sWhatPriorityArray[i].what != (uint32)-1; i ++) {
47		if ((what & sWhatPriorityArray[i].what) != 0) {
48			priority = sWhatPriorityArray[i].priority;
49			break;
50		}
51	}
52
53	return priority;
54}
55
56
57bigtime_t
58estimate_max_scheduling_latency(thread_id thread)
59{
60	return _kern_estimate_max_scheduling_latency(thread);
61}
62
63