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