Subversion Repositories Kolibri OS

Rev

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

Rev 129 Rev 384
Line 20... Line 20...
20
        add   eax,100
20
        add   eax,100
21
        mov   [next_usage_update],eax
21
        mov   [next_usage_update],eax
22
        call  updatecputimes
22
        call  updatecputimes
23
     .nocounter:
23
     .nocounter:
Line 24... Line 24...
24
 
24
 
25
        cmp   [0xffff], byte 1
25
        cmp   [DONT_SWITCH], byte 1
Line 26... Line 26...
26
        jne   .change_task
26
        jne   .change_task
27
 
27
 
28
        mov   al,0x20   ; send End Of Interrupt signal
28
        mov   al,0x20   ; send End Of Interrupt signal
Line 29... Line 29...
29
        mov   dx,0x20
29
        mov   dx,0x20
Line 30... Line 30...
30
        out   dx,al
30
        out   dx,al
31
 
31
 
Line 32... Line 32...
32
        mov   [0xffff], byte 0
32
        mov   [DONT_SWITCH], byte 0
Line 60... Line 60...
60
        pushfd
60
        pushfd
61
        cli
61
        cli
62
        pushad
62
        pushad
Line 63... Line 63...
63
 
63
 
-
 
64
        call  update_counters
-
 
65
; \begin{Mario79}
-
 
66
        cmp     [dma_task_switched], 1
-
 
67
        jne     .find_next_task
-
 
68
        mov     [dma_task_switched], 0
-
 
69
        mov     ebx, [dma_process]
-
 
70
        cmp     [CURRENT_TASK], ebx
-
 
71
        je      .return
-
 
72
        mov     edi, [dma_slot_ptr]
-
 
73
        mov     [CURRENT_TASK], ebx
-
 
74
        mov     [TASK_BASE], edi
-
 
75
        jmp     @f
-
 
76
.find_next_task:
64
        call  update_counters
77
; \end{Mario79}
65
        call  find_next_task
78
        call  find_next_task
66
        test  eax, eax    ; the same task -> skip switch
79
        test  eax, eax    ; the same task -> skip switch
67
        jnz    .return
80
        jnz    .return
68
 
81
@@:
69
        mov   [0xffff],byte 1
82
        mov   [DONT_SWITCH],byte 1
Line 70... Line 83...
70
        call  do_change_task
83
        call  do_change_task
71
 
84
 
72
     .return:
85
     .return:
Line 88... Line 101...
88
   event_sched         dd ?
101
   event_sched         dd ?
89
endg
102
endg
Line 90... Line 103...
90
 
103
 
91
 
104
 
92
update_counters:
105
update_counters:
93
        mov   edi, [0x3010]
106
        mov   edi, [TASK_BASE]
94
        mov   ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
107
        mov   ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
95
        call  _rdtsc
108
        call  _rdtsc
96
        sub   eax, ebx
109
        sub   eax, ebx
Line 104... Line 117...
104
;         eax = 1  if the task is the same
117
;         eax = 1  if the task is the same
105
;         edi = address of the data for the task in ebx
118
;         edi = address of the data for the task in ebx
106
;         [0x3000] = ebx and [0x3010] = edi
119
;         [0x3000] = ebx and [0x3010] = edi
107
;         corrupts other regs
120
;         corrupts other regs
108
find_next_task:
121
find_next_task:
109
        mov   ebx, [0x3000]
122
        mov   ebx, [CURRENT_TASK]
110
        mov   edi, [0x3010]
123
        mov   edi, [TASK_BASE]
111
        mov   [prev_slot], ebx
124
        mov   [prev_slot], ebx
Line 112... Line 125...
112
 
125
 
113
      .waiting_for_termination:
126
      .waiting_for_termination:
114
      .waiting_for_reuse:
127
      .waiting_for_reuse:
115
      .waiting_for_event:
128
      .waiting_for_event:
116
      .suspended:
129
      .suspended:
117
        cmp   ebx, [0x3004]
130
        cmp   ebx, [TASK_COUNT]
118
        jb    @f
131
        jb    @f
119
        mov   edi, 0x3000
132
        mov   edi, CURRENT_TASK
120
        xor   ebx, ebx
133
        xor   ebx, ebx
Line 121... Line 134...
121
      @@:
134
      @@:
122
 
135
 
Line 135... Line 148...
135
        cmp   al, 4
148
        cmp   al, 4
136
        je    .waiting_for_termination
149
        je    .waiting_for_termination
137
        cmp   al, 9
150
        cmp   al, 9
138
        je    .waiting_for_reuse
151
        je    .waiting_for_reuse
Line 139... Line 152...
139
 
152
 
140
        mov   [0x3000],ebx
153
        mov   [CURRENT_TASK],ebx
Line 141... Line 154...
141
        mov   [0x3010],edi
154
        mov   [TASK_BASE],edi
142
 
155
 
143
        cmp   al, 5
156
        cmp   al, 5
144
        jne   .noevents
157
        jne   .noevents
145
        call  get_event_for_app
158
        call  get_event_for_app
146
        test  eax, eax
159
        test  eax, eax
147
        jz    .waiting_for_event
160
        jz    .waiting_for_event
148
        mov   [event_sched], eax
161
        mov   [event_sched], eax
149
        mov   [edi+TASKDATA.state], byte 0
162
        mov   [edi+TASKDATA.state], byte 0
150
      .noevents:
163
      .noevents:
151
      .found:
164
      .found:
152
        mov   [0x3000],ebx
165
        mov   [CURRENT_TASK],ebx
153
        mov   [0x3010],edi
166
        mov   [TASK_BASE],edi
Line 154... Line 167...
154
        call  _rdtsc
167
        call  _rdtsc
155
        mov   [edi+TASKDATA.counter_add],eax
168
        mov   [edi+TASKDATA.counter_add],eax
Line 176... Line 189...
176
updatecputimes:
189
updatecputimes:
Line 177... Line 190...
177
 
190
 
178
        mov  eax,[idleuse]
191
        mov  eax,[idleuse]
179
        mov  [idleusesec],eax
192
        mov  [idleusesec],eax
180
        mov  [idleuse],dword 0
193
        mov  [idleuse],dword 0
181
        mov  ecx, [0x3004]
194
        mov  ecx, [TASK_COUNT]
182
        mov  edi, 0x3020
195
        mov  edi, TASK_DATA
183
      .newupdate:
196
      .newupdate:
184
        mov  ebx,[edi+TASKDATA.counter_sum]
197
        mov  ebx,[edi+TASKDATA.counter_sum]
185
        mov  [edi+TASKDATA.cpu_usage],ebx
198
        mov  [edi+TASKDATA.cpu_usage],ebx
186
        mov  [edi+TASKDATA.counter_sum],dword 0
199
        mov  [edi+TASKDATA.counter_sum],dword 0