Rev 9611 | Rev 9715 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9611 | Rev 9709 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 9611 $ |
8 | $Revision: 9709 $ |
9 | 9 | ||
10 | 10 | ||
Line 278... | Line 278... | ||
278 | ; If bl == SCHEDULE_ANY_PRIORITY = 0, loop over all NR_SCHED lists. |
278 | ; If bl == SCHEDULE_ANY_PRIORITY = 0, loop over all NR_SCHED lists. |
279 | ; Otherwise, loop over first [APPDATA.priority] lists. |
279 | ; Otherwise, loop over first [APPDATA.priority] lists. |
280 | test bl, bl |
280 | test bl, bl |
281 | jz .start |
281 | jz .start |
282 | mov ebx, [current_slot] |
282 | mov ebx, [current_slot] |
283 | mov edi, [TASK_BASE] |
- | |
284 | mov eax, [ebx+APPDATA.priority] |
283 | mov eax, [ebx+APPDATA.priority] |
285 | test eax, eax |
284 | test eax, eax |
286 | jz .unlock_found |
285 | jz .unlock_found |
287 | mov [esp], eax |
286 | mov [esp], eax |
288 | .start: |
287 | .start: |
Line 291... | Line 290... | ||
291 | mov ebx, [scheduler_current+ecx*4] |
290 | mov ebx, [scheduler_current+ecx*4] |
292 | test ebx, ebx |
291 | test ebx, ebx |
293 | jz .priority_next |
292 | jz .priority_next |
294 | .task_loop: |
293 | .task_loop: |
295 | mov ebx, [ebx+APPDATA.in_schedule.next] |
294 | mov ebx, [ebx+APPDATA.in_schedule.next] |
296 | ;mov al, [ebx+APPDATA.state] |
295 | mov al, [ebx+APPDATA.state] |
297 | mov edi, ebx ; |
- | |
298 | shr edi, 3 ; |
- | |
299 | add edi, TASK_TABLE - (SLOT_BASE shr 3) ; on delete |
- | |
300 | mov al, [edi+TASKDATA.state] ; |
- | |
301 | test al, al |
296 | test al, al |
302 | jz .task_found ; state == 0 |
297 | jz .task_found ; state == 0 |
303 | cmp al, 5 |
298 | cmp al, 5 |
304 | jne .task_next ; state == 1,2,3,4,9 |
299 | jne .task_next ; state == 1,2,3,4,9 |
305 | ; state == 5 |
300 | ; state == 5 |
Line 315... | Line 310... | ||
315 | cmp eax, [ebx+APPDATA.wait_timeout] |
310 | cmp eax, [ebx+APPDATA.wait_timeout] |
316 | jb .task_next |
311 | jb .task_next |
317 | xor eax, eax |
312 | xor eax, eax |
318 | @@: |
313 | @@: |
319 | mov [ebx+APPDATA.wait_param], eax ; retval for wait |
314 | mov [ebx+APPDATA.wait_param], eax ; retval for wait |
320 | mov [edi+TASKDATA.state], TSTATE_RUNNING ; on delete |
- | |
321 | mov [ebx+APPDATA.state], TSTATE_RUNNING |
315 | mov [ebx+APPDATA.state], TSTATE_RUNNING |
322 | .task_found: |
316 | .task_found: |
323 | mov [scheduler_current+ecx*4], ebx |
317 | mov [scheduler_current+ecx*4], ebx |
324 | ; If we have selected a thread with higher priority |
318 | ; If we have selected a thread with higher priority |
325 | ; AND rescheduling is due to IRQ, |
319 | ; AND rescheduling is due to IRQ, |
Line 336... | Line 330... | ||
336 | spin_unlock_irqrestore SchedulerLock |
330 | spin_unlock_irqrestore SchedulerLock |
337 | .found: |
331 | .found: |
338 | ; the line below assumes APPDATA is 256 bytes long and SLOT_BASE is |
332 | ; the line below assumes APPDATA is 256 bytes long and SLOT_BASE is |
339 | ; aligned on 0x10000 |
333 | ; aligned on 0x10000 |
340 | mov byte [current_slot_idx], bh |
334 | mov byte [current_slot_idx], bh |
341 | mov [TASK_BASE], edi |
- | |
- | 335 | ||
342 | rdtsc ;call _rdtsc |
336 | rdtsc ;call _rdtsc |
343 | mov [ebx-sizeof.APPDATA+APPDATA.counter_add], eax; for next using update_counters |
337 | mov [ebx-sizeof.APPDATA+APPDATA.counter_add], eax; for next using update_counters |
344 | ;mov [edi+TASKDATA.counter_add], eax; for next using update_counters |
338 | ;mov [edi+TASKDATA.counter_add], eax; for next using update_counters |
345 | cmp ebx, [current_slot] |
339 | cmp ebx, [current_slot] |
346 | ret |
340 | ret |
Line 350... | Line 344... | ||
350 | .priority_next: |
344 | .priority_next: |
351 | inc ecx |
345 | inc ecx |
352 | cmp ecx, [esp] |
346 | cmp ecx, [esp] |
353 | jb .priority_loop |
347 | jb .priority_loop |
354 | mov ebx, [current_slot] |
348 | mov ebx, [current_slot] |
355 | mov edi, [TASK_BASE] |
- | |
356 | jmp .unlock_found |
349 | jmp .unlock_found |
357 | endp |
350 | endp |
Line 358... | Line 351... | ||
358 | 351 |