15af32e75SAxel Dörfler /* 2*fc069a2aSMichael Pfeiffer * Copyright 2004-2007, Haiku. All rights reserved. 3*fc069a2aSMichael Pfeiffer * Distributed under the terms of the MIT License. 4*fc069a2aSMichael Pfeiffer * 5*fc069a2aSMichael Pfeiffer * Authors: 6*fc069a2aSMichael Pfeiffer * Jérôme Duval, korli@users.sourceforge.net. 7*fc069a2aSMichael Pfeiffer * Michael Pfeiffer, laplace@users.sourceforge.net 85af32e75SAxel Dörfler */ 95af32e75SAxel Dörfler 105af32e75SAxel Dörfler 115af32e75SAxel Dörfler #include <scheduler.h> 125af32e75SAxel Dörfler 13*fc069a2aSMichael Pfeiffer 14*fc069a2aSMichael Pfeiffer static struct { 15*fc069a2aSMichael Pfeiffer uint32 what; 16*fc069a2aSMichael Pfeiffer int32 priority; 17*fc069a2aSMichael Pfeiffer } gWhatPriorityArray[] = { 18*fc069a2aSMichael Pfeiffer // highest priority first 19*fc069a2aSMichael Pfeiffer {B_MIDI_PROCESSING, 0x78}, 20*fc069a2aSMichael Pfeiffer {B_AUDIO_RECORDING | B_AUDIO_PLAYBACK, 0x73}, 21*fc069a2aSMichael Pfeiffer {B_LIVE_AUDIO_MANIPULATION, 0x6e}, 22*fc069a2aSMichael Pfeiffer {B_VIDEO_RECORDING, 0x19}, 23*fc069a2aSMichael Pfeiffer {B_VIDEO_PLAYBACK, 0x14}, 24*fc069a2aSMichael Pfeiffer {B_USER_INPUT_HANDLING, 0x0f}, 25*fc069a2aSMichael Pfeiffer {B_LIVE_VIDEO_MANIPULATION, 0x0e}, 26*fc069a2aSMichael Pfeiffer {B_LIVE_3D_RENDERING, 0x0c}, 27*fc069a2aSMichael Pfeiffer {B_STATUS_RENDERING, 0xa}, 28*fc069a2aSMichael Pfeiffer {B_OFFLINE_PROCESSING, 0x06}, 29*fc069a2aSMichael Pfeiffer {B_NUMBER_CRUNCHING, 0x05}, 30*fc069a2aSMichael Pfeiffer {(uint32)-1, -1} 31*fc069a2aSMichael Pfeiffer }; 32*fc069a2aSMichael Pfeiffer 335af32e75SAxel Dörfler int32 345af32e75SAxel Dörfler suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter, bigtime_t length) 355af32e75SAxel Dörfler { 36*fc069a2aSMichael Pfeiffer int32 priority = what == B_DEFAULT_MEDIA_PRIORITY ? 0x0a : 0; 37*fc069a2aSMichael Pfeiffer // default priority 38*fc069a2aSMichael Pfeiffer 39*fc069a2aSMichael Pfeiffer for (int i = 0; gWhatPriorityArray[i].what != (uint32)-1; i ++) { 40*fc069a2aSMichael Pfeiffer if ((what & gWhatPriorityArray[i].what) != 0) { 41*fc069a2aSMichael Pfeiffer priority = gWhatPriorityArray[i].priority; 42*fc069a2aSMichael Pfeiffer break; 43*fc069a2aSMichael Pfeiffer } 44*fc069a2aSMichael Pfeiffer } 45*fc069a2aSMichael Pfeiffer 46*fc069a2aSMichael Pfeiffer return priority; 475af32e75SAxel Dörfler } 485af32e75SAxel Dörfler 495af32e75SAxel Dörfler bigtime_t 505af32e75SAxel Dörfler estimate_max_scheduling_latency(thread_id th) 515af32e75SAxel Dörfler { 525af32e75SAxel Dörfler if (th == -1) 535af32e75SAxel Dörfler th = find_thread(NULL); 545af32e75SAxel Dörfler 555af32e75SAxel Dörfler return 0; 565af32e75SAxel Dörfler } 575af32e75SAxel Dörfler 58