Subversion Repositories Kolibri OS

Rev

Rev 9910 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9910 Rev 9932
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2023. 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: 9910 $
8
$Revision: 9932 $
9
 
9
 
10
 
10
 
Line 66... Line 66...
66
;  event_sched         dd ?
66
;  event_sched         dd ?
67
endg
67
endg
Line 68... Line 68...
68
 
68
 
69
align 4
69
align 4
70
update_counters:
-
 
71
        ;mov     edi, [TASK_BASE]
70
update_counters:
72
        mov     esi, [current_slot]
71
        mov     esi, [current_slot]
73
        rdtsc
72
        rdtsc
74
        ;sub     eax, [edi+TASKDATA.counter_add] ; time stamp counter add
73
        sub     eax, [esi + APPDATA.counter_add] ; time stamp counter add
75
        ;add     [edi+TASKDATA.counter_sum], eax ; counter sum
-
 
76
        sub     eax, [esi - sizeof.APPDATA + APPDATA.counter_add] ; time stamp counter add
-
 
77
        add     [esi - sizeof.APPDATA + APPDATA.counter_sum], eax ; counter sum
74
        add     [esi + APPDATA.counter_sum], eax ; counter sum
Line 78... Line 75...
78
        ret
75
        ret
79
 
76
 
80
align 4
77
align 4
81
updatecputimes:
-
 
82
        mov     ecx, [thread_count]
78
updatecputimes:
83
        ;mov     edi, TASK_DATA
79
        mov     ecx, [thread_count]
84
        mov     esi, SLOT_BASE
80
        mov     esi, SLOT_BASE
85
  .newupdate:
81
  .newupdate:
86
        xor     eax, eax
-
 
87
        ;xchg    eax, [edi+TASKDATA.counter_sum]
82
        xor     eax, eax
88
        ;mov     [edi+TASKDATA.cpu_usage], eax
-
 
89
        xchg    eax, [esi + APPDATA.counter_sum]
83
        add     esi, sizeof.APPDATA
90
        ;add     edi, 0x20
-
 
91
        mov     [esi + APPDATA.cpu_usage], eax
84
        xchg    eax, [esi + APPDATA.counter_sum]
92
        add     esi, sizeof.APPDATA
85
        mov     [esi + APPDATA.cpu_usage], eax
Line 93... Line 86...
93
        loop    .newupdate
86
        loop    .newupdate
94
        ret
87
        ret
Line 95... Line 88...
95
 
88
 
96
;TODO: Надо бы убрать использование do_change_task из V86...
89
;TODO: Надо бы убрать использование do_change_task из V86...
97
; и после этого перенести обработку TASKDATA.counter_add/sum в do_change_task
90
; и после этого перенести обработку APPDATA.counter_add/sum в do_change_task
98
 
91
 
Line 264... Line 257...
264
;   bl = SCHEDULE_HIGHER_PRIORITY:
257
;   bl = SCHEDULE_HIGHER_PRIORITY:
265
;        consider only threads with strictly higher priority than the current one,
258
;        consider only threads with strictly higher priority than the current one,
266
;        keep running the current thread if other ready threads have the same or lower priority
259
;        keep running the current thread if other ready threads have the same or lower priority
267
;retval:
260
;retval:
268
;   ebx = address of the APPDATA for the selected task (slot-base)
261
;   ebx = address of the APPDATA for the selected task (slot-base)
269
;   edi = address of the TASKDATA for the selected task
-
 
270
;   ZF  = 1  if the task is the same
262
;   ZF  = 1  if the task is the same
271
;warning:
263
;warning:
272
;   [current_slot_idx] = bh , [TASK_BASE] = edi -- as result
264
;   [current_slot_idx] = bh -- as result
273
;   [current_slot] is not set to new value (ebx)!!!
265
;   [current_slot] is not set to new value (ebx)!!!
274
;scratched: eax,ecx
266
;scratched: eax,ecx
275
proc find_next_task
267
proc find_next_task
276
        call    update_counters
268
        call    update_counters
277
        spin_lock_irqsave SchedulerLock
269
        spin_lock_irqsave SchedulerLock
Line 294... Line 286...
294
.task_loop:
286
.task_loop:
295
        mov     ebx, [ebx + APPDATA.in_schedule.next]
287
        mov     ebx, [ebx + APPDATA.in_schedule.next]
296
        mov     al, [ebx + APPDATA.state]
288
        mov     al, [ebx + APPDATA.state]
297
        test    al, al
289
        test    al, al
298
        jz      .task_found     ; state == 0
290
        jz      .task_found     ; state == 0
299
        cmp     al, 5
291
        cmp     al, TSTATE_WAITING
300
        jne     .task_next      ; state == 1,2,3,4,9
292
        jne     .task_next      ; state == 1,2,3,4,9
301
      ; state == 5
293
      ; state == 5
302
        pushad  ; more freedom for [APPDATA.wait_test]
294
        pushad  ; more freedom for [APPDATA.wait_test]
303
        call    [ebx + APPDATA.wait_test]
295
        call    [ebx + APPDATA.wait_test]
304
        mov     [esp + 28], eax
296
        mov     [esp + 28], eax
Line 333... Line 325...
333
        ; the line below assumes APPDATA is 256 bytes long and SLOT_BASE is
325
        ; the line below assumes APPDATA is 256 bytes long and SLOT_BASE is
334
        ; aligned on 0x10000
326
        ; aligned on 0x10000
335
        mov     byte [current_slot_idx], bh
327
        mov     byte [current_slot_idx], bh
Line 336... Line 328...
336
 
328
 
337
        rdtsc   ;call  _rdtsc
-
 
338
        mov     [ebx - sizeof.APPDATA + APPDATA.counter_add], eax; for next using update_counters
329
        rdtsc   ;call  _rdtsc
339
        ;mov     [edi+TASKDATA.counter_add], eax; for next using update_counters
330
        mov     [ebx + APPDATA.counter_add], eax; for next using update_counters
340
        cmp     ebx, [current_slot]
331
        cmp     ebx, [current_slot]
341
        ret
332
        ret
342
.task_next:
333
.task_next:
343
        cmp     ebx, [scheduler_current+ecx*4]
334
        cmp     ebx, [scheduler_current+ecx*4]