xref: /haiku/headers/os/kernel/scheduler.h (revision 5d9e40fe9252c8f9c5e5e41594545bfa4419fcc7)
1 /*****************************************************************************
2 
3         File:           scheduler.h
4 
5 		Description:    Scheduling inquiry functions
6 
7         Copyright 1998-, Be Incorporated, All Rights Reserved.
8 
9 *****************************************************************************/
10 
11 
12 #if !defined(SCHEDULER_H)
13 #define SCHEDULER_H
14 
15 #include <SupportDefs.h>
16 #include <OS.h>
17 
18 /* To get a good thread priority, call suggest_thread_priority() with the following information: */
19 /* 'what' is a bit mask describing what you're doing in the thread. */
20 /* 'period' is how many times a second your thread needs to run (-1 if you're running continuously.) */
21 /* 'jitter' is an estimate (in us) of how much that period can vary, as long as it stays centered on the average. */
22 /* 'length' is how long (in us) you expect to run for each invocation. */
23 /* "invocation" means, typically, receiving a message, dispatching it, and then returning to reading a message. */
24 /* MANIPULATION means both filtering and compression/decompression. */
25 /* PLAYBACK and RECORDING means threads feeding/reading ACTUAL HARDWARE ONLY. */
26 /* 0 means don't care */
27 enum be_task_flags { /* bitmasks for "what" */
28 	B_DEFAULT_MEDIA_PRIORITY = 0,
29 	B_OFFLINE_PROCESSING = 0x1,
30 	B_STATUS_RENDERING = 0x2,		/* can also use this for "preview" type things */
31 	B_USER_INPUT_HANDLING = 0x4,
32 	B_LIVE_VIDEO_MANIPULATION = 0x8,	/* non-live processing is OFFLINE_PROCESSING */
33 	B_VIDEO_PLAYBACK = 0x10,	/* feeding hardware */
34 	B_VIDEO_RECORDING = 0x20,	/* grabbing from hardware */
35 	B_LIVE_AUDIO_MANIPULATION = 0x40,	/* non-live processing is OFFLINE_PROCESSING */
36 	B_AUDIO_PLAYBACK = 0x80,	/* feeding hardware */
37 	B_AUDIO_RECORDING = 0x100,	/* grabbing from hardware */
38 	B_LIVE_3D_RENDERING = 0x200,		/* non-live rendering is OFFLINE_PROCESSING */
39 	B_NUMBER_CRUNCHING = 0x400,
40 	B_MIDI_PROCESSING = 0x800
41 };
42 #if defined(__cplusplus)
43 extern "C" {
44 _IMPEXP_ROOT int32 suggest_thread_priority(uint32 task_flags = B_DEFAULT_MEDIA_PRIORITY,
45 	int32 period = 0, bigtime_t jitter = 0, bigtime_t length = 0);
46 _IMPEXP_ROOT bigtime_t estimate_max_scheduling_latency(thread_id th = -1);	/* default is current thread */
47 }
48 #else
49 _IMPEXP_ROOT int32 suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter, bigtime_t length);
50 _IMPEXP_ROOT bigtime_t estimate_max_scheduling_latency(thread_id th);	/* default is current thread */
51 #endif
52 
53 #endif /* SCHEDULER_H */
54 
55