Read about priority scheduling here: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Code: Select all
;PRIORITY TESTER.PB
;Created on 9/11/2011 by chris319
Global threadContinueFlag = #True
Procedure myThread(null)
Repeat
Delay (100)
Until threadContinueFlag = #False
EndProcedure
;CHANGE THIS VALUE TO SEE THE EFFECTS
SetPriorityClass_(GetCurrentProcess_(), #NORMAL_PRIORITY_CLASS)
tID = CreateThread(@myThread(), #Null)
;CHANGE THIS VALUE TO SEE THE EFFECTS
SetThreadPriority_(ThreadID(tID), #THREAD_PRIORITY_NORMAL)
b = GetPriorityClass_(GetCurrentProcess_())
a = GetThreadPriority_(ThreadID(tID))
If a <> #THREAD_PRIORITY_ERROR_RETURN
Select b
Case #IDLE_PRIORITY_CLASS: processPriClass$ = " Idle priority class"
Case #BELOW_NORMAL_PRIORITY_CLASS: processPriClass$ = " Below normal priority class"
Case #NORMAL_PRIORITY_CLASS: processPriClass$ = " Normal priority class"
Case #ABOVE_NORMAL_PRIORITY_CLASS: processPriClass$ = " Above normal priority class"
Case #HIGH_PRIORITY_CLASS: processPriClass$ = " High priority class"
Case #REALTIME_PRIORITY_CLASS: processPriClass$ = " Real-time priority class"
EndSelect
Select a
Case #THREAD_PRIORITY_ERROR_RETURN: threadPriority$ = " Error"
Case #THREAD_PRIORITY_IDLE: threadPriority$ = " Idle thread priority"
Case #THREAD_PRIORITY_LOWEST: threadPriority$ = " Lowest thread priority"
Case #THREAD_PRIORITY_BELOW_NORMAL: threadPriority$ = " Below normal thread priority"
Case #THREAD_PRIORITY_NORMAL: threadPriority$ = " Normal thread priority"
Case #THREAD_PRIORITY_ABOVE_NORMAL: threadPriority$ = " Above normal thread priority"
Case #THREAD_PRIORITY_HIGHEST: threadPriority$ = " Highest thread priority"
Case #THREAD_PRIORITY_TIME_CRITICAL: threadPriority$ = " Time-critical priority"
EndSelect
Debug "Process priority: $" + Hex(b) + processPriClass$
Debug "Thread priority: " + Str(a) + threadPriority$
Select b
Case #IDLE_PRIORITY_CLASS
Select a
Case #THREAD_PRIORITY_IDLE: basePriority = 1
Case #THREAD_PRIORITY_LOWEST: basePriority = 2
Case #THREAD_PRIORITY_BELOW_NORMAL: basePriority = 3
Case #THREAD_PRIORITY_NORMAL: basePriority = 4
Case #THREAD_PRIORITY_ABOVE_NORMAL: basePriority = 5
Case #THREAD_PRIORITY_HIGHEST: basePriority = 6
Case #THREAD_PRIORITY_TIME_CRITICAL: basePriority = 15
EndSelect
Case #BELOW_NORMAL_PRIORITY_CLASS
Select a
Case #THREAD_PRIORITY_IDLE: basePriority = 1
Case #THREAD_PRIORITY_LOWEST: basePriority = 4
Case #THREAD_PRIORITY_BELOW_NORMAL: basePriority = 5
Case #THREAD_PRIORITY_NORMAL: basePriority = 6
Case #THREAD_PRIORITY_ABOVE_NORMAL: basePriority = 7
Case #THREAD_PRIORITY_HIGHEST: basePriority = 8
Case #THREAD_PRIORITY_TIME_CRITICAL: basePriority = 15
EndSelect
Case #NORMAL_PRIORITY_CLASS
Select a
Case #THREAD_PRIORITY_IDLE: basePriority = 1
Case #THREAD_PRIORITY_LOWEST: basePriority = 6
Case #THREAD_PRIORITY_BELOW_NORMAL: basePriority = 7
Case #THREAD_PRIORITY_NORMAL: basePriority = 8
Case #THREAD_PRIORITY_ABOVE_NORMAL: basePriority = 9
Case #THREAD_PRIORITY_HIGHEST: basePriority = 10
Case #THREAD_PRIORITY_TIME_CRITICAL: basePriority = 15
EndSelect
Case #ABOVE_NORMAL_PRIORITY_CLASS
Select a
Case #THREAD_PRIORITY_IDLE: basePriority = 1
Case #THREAD_PRIORITY_LOWEST: basePriority = 8
Case #THREAD_PRIORITY_BELOW_NORMAL: basePriority = 9
Case #THREAD_PRIORITY_NORMAL: basePriority = 10
Case #THREAD_PRIORITY_ABOVE_NORMAL: basePriority = 11
Case #THREAD_PRIORITY_HIGHEST: basePriority = 12
Case #THREAD_PRIORITY_TIME_CRITICAL: basePriority = 15
EndSelect
Case #HIGH_PRIORITY_CLASS
Select a
Case #THREAD_PRIORITY_IDLE: basePriority = 1
Case #THREAD_PRIORITY_LOWEST: basePriority = 11
Case #THREAD_PRIORITY_BELOW_NORMAL: basePriority = 12
Case #THREAD_PRIORITY_NORMAL: basePriority = 13
Case #THREAD_PRIORITY_ABOVE_NORMAL: basePriority = 14
Case #THREAD_PRIORITY_HIGHEST: basePriority = 15
Case #THREAD_PRIORITY_TIME_CRITICAL: basePriority = 15
EndSelect
Case #REALTIME_PRIORITY_CLASS
Select a
Case #THREAD_PRIORITY_IDLE: basePriority = 16
Case #THREAD_PRIORITY_LOWEST: basePriority = 22
Case #THREAD_PRIORITY_BELOW_NORMAL: basePriority = 23
Case #THREAD_PRIORITY_NORMAL: basePriority = 24
Case #THREAD_PRIORITY_ABOVE_NORMAL: basePriority = 25
Case #THREAD_PRIORITY_HIGHEST: basePriority = 26
Case #THREAD_PRIORITY_TIME_CRITICAL: basePriority = 31
EndSelect
EndSelect
Debug "Base priority: " + Str(basePriority)
Else
Debug "Error"
EndIf
threadContinueFlag = #False