vfs: check userland buffers before reading them.
[haiku.git] / headers / os / kernel / scheduler.h
blobbe3508775e90fff45b0bb933827a23baa8410e01
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
9 #include <OS.h>
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
29 /* bitmasks for suggest_thread_priority() */
30 enum 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 */
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 */
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
52 enum scheduler_mode {
53 SCHEDULER_MODE_LOW_LATENCY,
54 SCHEDULER_MODE_POWER_SAVING,
57 #if defined(__cplusplus)
58 extern "C" {
60 int32 suggest_thread_priority(uint32 task_flags = B_DEFAULT_MEDIA_PRIORITY,
61 int32 period = 0, bigtime_t jitter = 0, bigtime_t length = 0);
63 bigtime_t estimate_max_scheduling_latency(thread_id th = -1);
64 /* default is current thread */
66 status_t set_scheduler_mode(int32 mode);
67 int32 get_scheduler_mode(void);
70 #else
72 int32 suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter,
73 bigtime_t length);
75 bigtime_t estimate_max_scheduling_latency(thread_id th);
76 /* default is current thread */
78 status_t set_scheduler_mode(int32 mode);
79 int32 get_scheduler_mode(void);
81 #endif
83 #endif // SCHEDULER_H