Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3625 → Rev 3626

/kernel/branches/Kolibri-acpi/core/sched.inc
31,6 → 31,7
call irq_eoi
; btr dword[DONT_SWITCH], 0
; jc .return
mov bl, SCHEDULE_ANY_PRIORITY
call find_next_task
jz .return ; if there is only one running process
call do_change_task
58,6 → 59,7
.find_next_task:
; \end{Mario79}
end if
mov bl, SCHEDULE_ANY_PRIORITY
call find_next_task
jz .return ; the same task -> skip switch
@@:
324,8 → 326,16
ret
endp
 
SCHEDULE_ANY_PRIORITY = 0
SCHEDULE_HIGHER_PRIORITY = 1
;info:
; Find next task to execute
;in:
; bl = SCHEDULE_ANY_PRIORITY:
; consider threads with any priority
; bl = SCHEDULE_HIGHER_PRIORITY:
; consider only threads with strictly higher priority than the current one,
; keep running the current thread if other ready threads have the same or lower priority
;retval:
; ebx = address of the APPDATA for the selected task (slot-base)
; edi = address of the TASKDATA for the selected task
337,6 → 347,18
proc find_next_task
call update_counters
spin_lock_irqsave SchedulerLock
push NR_SCHED_QUEUES
; If bl == SCHEDULE_ANY_PRIORITY = 0, loop over all NR_SCHED lists.
; Otherwise, loop over first [APPDATA.priority] lists.
test bl, bl
jz .start
mov ebx, [current_slot]
mov edi, [TASK_BASE]
mov eax, [ebx+APPDATA.priority]
test eax, eax
jz .unlock_found
mov [esp], eax
.start:
xor ecx, ecx
.priority_loop:
mov ebx, [scheduler_current+ecx*4]
370,6 → 392,18
mov [edi+TASKDATA.state], 0
.task_found:
mov [scheduler_current+ecx*4], ebx
; If we have selected a thread with higher priority
; AND rescheduling is due to IRQ,
; turn the current scheduler list one entry back,
; so the current thread will be next after high-priority thread is done.
mov ecx, [esp]
cmp ecx, NR_SCHED_QUEUES
jz .unlock_found
mov eax, [current_slot]
mov eax, [eax+APPDATA.in_schedule.prev]
mov [scheduler_current+ecx*4], eax
.unlock_found:
pop ecx
spin_unlock_irqrestore SchedulerLock
.found:
mov [CURRENT_TASK], bh
383,10 → 417,11
jnz .task_loop
.priority_next:
inc ecx
cmp ecx, NR_SCHED_QUEUES
cmp ecx, [esp]
jb .priority_loop
hlt
jmp $-1
mov ebx, [current_slot]
mov edi, [TASK_BASE]
jmp .unlock_found
endp
 
if 0