1/*
2 * Copyright 2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef SCHEDULER_H
6#define SCHEDULER_H
7
8
9#include <OS.h>
10
11
12/*!
13	To get a good thread priority, call suggest_thread_priority() with the
14	following information:
15		\a what is a bit mask describing what you're doing in the thread.
16		\a period is how many times a second your thread needs to run
17			(-1 if you're running continuously.)
18		\a jitter is an estimate (in us) of how much that period can vary,
19			as long as it stays centered on the average.
20		\a length is how long (in us) you expect to run for each invocation.
21			"Invocation" means, typically, receiving a message, dispatching
22			it, and then returning to reading a message.
23		MANIPULATION means both filtering and compression/decompression.
24		PLAYBACK and RECORDING means threads feeding/reading ACTUAL
25		HARDWARE ONLY.
26		0 means don't care
27*/
28
29/* bitmasks for suggest_thread_priority() */
30enum be_task_flags {
31	B_DEFAULT_MEDIA_PRIORITY	= 0x000,
32	B_OFFLINE_PROCESSING		= 0x001,
33	B_STATUS_RENDERING			= 0x002,	/* can also use this for */
34											/* "preview" type things */
35	B_USER_INPUT_HANDLING		= 0x004,
36	B_LIVE_VIDEO_MANIPULATION	= 0x008,	/* non-live processing is */
37											/* OFFLINE_PROCESSING */
38
39	B_VIDEO_PLAYBACK			= 0x010,	/* feeding hardware */
40	B_VIDEO_RECORDING			= 0x020,	/* grabbing from hardware */
41	B_LIVE_AUDIO_MANIPULATION	= 0x040,	/* non-live processing is */
42											/* OFFLINE_PROCESSING */
43
44	B_AUDIO_PLAYBACK			= 0x080,	/* feeding hardware */
45	B_AUDIO_RECORDING			= 0x100,	/* grabbing from hardware */
46	B_LIVE_3D_RENDERING			= 0x200,	/* non-live rendering is */
47											/* OFFLINE_PROCESSING */
48	B_NUMBER_CRUNCHING			= 0x400,
49	B_MIDI_PROCESSING			= 0x800
50};
51
52#if defined(__cplusplus)
53extern "C" {
54
55int32 suggest_thread_priority(uint32 task_flags = B_DEFAULT_MEDIA_PRIORITY,
56	int32 period = 0, bigtime_t jitter = 0, bigtime_t length = 0);
57
58bigtime_t estimate_max_scheduling_latency(thread_id th = -1);
59	/* default is current thread */
60
61}
62#else
63
64int32 suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter,
65	bigtime_t length);
66
67bigtime_t estimate_max_scheduling_latency(thread_id th);
68	/* default is current thread */
69
70#endif
71
72#endif // SCHEDULER_H
73
74