forked from KolibriOS/kolibrios
[KERNEL] #4 Preparing to merge legacy TASKDATA into APPDATA:
- use thread state constants instead of hardcoded values - other small style fixes git-svn-id: svn://kolibrios.org@8874 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
dae63eba04
commit
8ef75d4496
@ -479,6 +479,8 @@ struct BOX
|
|||||||
height dd ?
|
height dd ?
|
||||||
ends
|
ends
|
||||||
|
|
||||||
|
; Fields, marked as R now not used, but will be used soon,
|
||||||
|
; when legacy TASKDATA structure will be deleted
|
||||||
struct APPDATA
|
struct APPDATA
|
||||||
app_name rb 11
|
app_name rb 11
|
||||||
rb 5
|
rb 5
|
||||||
@ -504,17 +506,17 @@ struct APPDATA
|
|||||||
wait_test dd ? ;+96 +++
|
wait_test dd ? ;+96 +++
|
||||||
wait_param dd ? ;+100 +++
|
wait_param dd ? ;+100 +++
|
||||||
tls_base dd ? ;+104
|
tls_base dd ? ;+104
|
||||||
event_mask dd ? ;+108 ; stores event types allowed for task
|
event_mask dd ? ;+108 ; R stores event types allowed for task
|
||||||
tid dd ? ;+112 ; thread id
|
tid dd ? ;+112 ; R thread id
|
||||||
draw_bgr_x dd ? ;+116
|
draw_bgr_x dd ? ;+116
|
||||||
draw_bgr_y dd ? ;+120
|
draw_bgr_y dd ? ;+120
|
||||||
state db ? ;+124 ; thread state
|
state db ? ;+124 ; R thread state
|
||||||
db ? ;+125
|
db ? ;+125
|
||||||
dw ? ;+126
|
dw ? ;+126
|
||||||
wnd_shape dd ? ;+128
|
wnd_shape dd ? ;+128
|
||||||
wnd_shape_scale dd ? ;+132
|
wnd_shape_scale dd ? ;+132
|
||||||
mem_start dd ? ;+136 ;;
|
mem_start dd ? ;+136 ; R
|
||||||
counter_sum dd ? ;+140 ;;
|
counter_sum dd ? ;+140 ; R
|
||||||
saved_box BOX ;+144
|
saved_box BOX ;+144
|
||||||
ipc_start dd ? ;+160
|
ipc_start dd ? ;+160
|
||||||
ipc_size dd ? ;+164
|
ipc_size dd ? ;+164
|
||||||
@ -531,8 +533,8 @@ struct APPDATA
|
|||||||
wnd_clientbox BOX ;+216
|
wnd_clientbox BOX ;+216
|
||||||
priority dd ? ;+232
|
priority dd ? ;+232
|
||||||
in_schedule LHEAD ;+236
|
in_schedule LHEAD ;+236
|
||||||
counter_add dd ? ;+244 ;;
|
counter_add dd ? ;+244 ; R
|
||||||
cpu_usage dd ? ;+248 ;;
|
cpu_usage dd ? ;+248 ; R
|
||||||
dd ? ;+252
|
dd ? ;+252
|
||||||
ends
|
ends
|
||||||
|
|
||||||
@ -557,6 +559,7 @@ struct TASKDATA
|
|||||||
cpu_usage dd ? ;+28
|
cpu_usage dd ? ;+28
|
||||||
ends
|
ends
|
||||||
|
|
||||||
|
; Thread states:
|
||||||
TSTATE_RUNNING = 0
|
TSTATE_RUNNING = 0
|
||||||
TSTATE_RUN_SUSPENDED = 1
|
TSTATE_RUN_SUSPENDED = 1
|
||||||
TSTATE_WAIT_SUSPENDED = 2
|
TSTATE_WAIT_SUSPENDED = 2
|
||||||
@ -565,7 +568,7 @@ TSTATE_TERMINATING = 4
|
|||||||
TSTATE_WAITING = 5
|
TSTATE_WAITING = 5
|
||||||
TSTATE_FREE = 9
|
TSTATE_FREE = 9
|
||||||
|
|
||||||
; constants definition
|
; Window constants:
|
||||||
WSTATE_NORMAL = 00000000b
|
WSTATE_NORMAL = 00000000b
|
||||||
WSTATE_MAXIMIZED = 00000001b
|
WSTATE_MAXIMIZED = 00000001b
|
||||||
WSTATE_MINIMIZED = 00000010b
|
WSTATE_MINIMIZED = 00000010b
|
||||||
@ -581,7 +584,8 @@ ZPOS_DESKTOP = -2
|
|||||||
ZPOS_ALWAYS_BACK = -1
|
ZPOS_ALWAYS_BACK = -1
|
||||||
ZPOS_NORMAL = 0
|
ZPOS_NORMAL = 0
|
||||||
ZPOS_ALWAYS_TOP = 1 ;ZPOS_ALWAYS_TOP is always last and has max number!
|
ZPOS_ALWAYS_TOP = 1 ;ZPOS_ALWAYS_TOP is always last and has max number!
|
||||||
; structures definition
|
|
||||||
|
; Window structure:
|
||||||
struct WDATA
|
struct WDATA
|
||||||
box BOX
|
box BOX
|
||||||
cl_workarea dd ?
|
cl_workarea dd ?
|
||||||
|
@ -1008,7 +1008,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
|
|||||||
|
|
||||||
mov dword [edi+4], ebx
|
mov dword [edi+4], ebx
|
||||||
mov eax, [TASK_BASE]
|
mov eax, [TASK_BASE]
|
||||||
mov eax, [eax+0x04] ;eax - our PID
|
mov eax, [eax+TASKDATA.pid] ;eax - our PID
|
||||||
add edi, edx
|
add edi, edx
|
||||||
mov [edi], eax
|
mov [edi], eax
|
||||||
mov ecx, [msg_size]
|
mov ecx, [msg_size]
|
||||||
|
@ -309,7 +309,7 @@ proc find_next_task
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
@@:
|
@@:
|
||||||
mov [ebx+APPDATA.wait_param], eax ; retval for wait
|
mov [ebx+APPDATA.wait_param], eax ; retval for wait
|
||||||
mov [edi+TASKDATA.state], 0
|
mov [edi+TASKDATA.state], TSTATE_RUNNING
|
||||||
.task_found:
|
.task_found:
|
||||||
mov [scheduler_current+ecx*4], ebx
|
mov [scheduler_current+ecx*4], ebx
|
||||||
; If we have selected a thread with higher priority
|
; If we have selected a thread with higher priority
|
||||||
|
@ -48,7 +48,7 @@ mutex_lock:
|
|||||||
dec eax
|
dec eax
|
||||||
jz @F
|
jz @F
|
||||||
|
|
||||||
mov [edx+TASKDATA.state], 1
|
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED
|
||||||
call change_task
|
call change_task
|
||||||
jmp .forever
|
jmp .forever
|
||||||
@@:
|
@@:
|
||||||
@ -80,7 +80,7 @@ mutex_unlock:
|
|||||||
je @F
|
je @F
|
||||||
|
|
||||||
mov eax, [eax+MUTEX_WAITER.task]
|
mov eax, [eax+MUTEX_WAITER.task]
|
||||||
mov [eax+TASKDATA.state], 0
|
mov [eax+TASKDATA.state], TSTATE_RUNNING
|
||||||
@@:
|
@@:
|
||||||
popfd
|
popfd
|
||||||
ret
|
ret
|
||||||
@ -114,7 +114,7 @@ down_read:
|
|||||||
mov eax, [TASK_BASE]
|
mov eax, [TASK_BASE]
|
||||||
mov [esp+MUTEX_WAITER.task], eax
|
mov [esp+MUTEX_WAITER.task], eax
|
||||||
mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_READ
|
mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_READ
|
||||||
mov [eax+TASKDATA.state], 1
|
mov [eax+TASKDATA.state], TSTATE_RUN_SUSPENDED
|
||||||
|
|
||||||
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
|
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ down_write:
|
|||||||
mov edx, [TASK_BASE]
|
mov edx, [TASK_BASE]
|
||||||
mov [esp+MUTEX_WAITER.task], edx
|
mov [esp+MUTEX_WAITER.task], edx
|
||||||
mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_WRITE
|
mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_WRITE
|
||||||
mov [edx+TASKDATA.state], 1
|
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED
|
||||||
|
|
||||||
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
|
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ down_write:
|
|||||||
test eax, [ecx+RWSEM.count]
|
test eax, [ecx+RWSEM.count]
|
||||||
jz @F
|
jz @F
|
||||||
|
|
||||||
mov [edx+TASKDATA.state], 1
|
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED
|
||||||
call change_task
|
call change_task
|
||||||
jmp .forever
|
jmp .forever
|
||||||
@@:
|
@@:
|
||||||
@ -178,7 +178,7 @@ up_read:
|
|||||||
je @F
|
je @F
|
||||||
|
|
||||||
mov eax, [eax+MUTEX_WAITER.task]
|
mov eax, [eax+MUTEX_WAITER.task]
|
||||||
mov [eax+TASKDATA.state], 0
|
mov [eax+TASKDATA.state], TSTATE_RUNNING
|
||||||
@@:
|
@@:
|
||||||
popfd
|
popfd
|
||||||
ret
|
ret
|
||||||
@ -202,7 +202,7 @@ up_write:
|
|||||||
jnz .wake
|
jnz .wake
|
||||||
|
|
||||||
mov eax, [eax+MUTEX_WAITER.task]
|
mov eax, [eax+MUTEX_WAITER.task]
|
||||||
mov [eax+TASKDATA.state], 0
|
mov [eax+TASKDATA.state], TSTATE_RUNNING
|
||||||
.done:
|
.done:
|
||||||
popfd
|
popfd
|
||||||
ret
|
ret
|
||||||
@ -220,7 +220,7 @@ up_write:
|
|||||||
mov ebx, [eax+MUTEX_WAITER.list.next]
|
mov ebx, [eax+MUTEX_WAITER.list.next]
|
||||||
list_del eax
|
list_del eax
|
||||||
mov edx, [eax+MUTEX_WAITER.task]
|
mov edx, [eax+MUTEX_WAITER.task]
|
||||||
mov [edx+TASKDATA.state], 0
|
mov [edx+TASKDATA.state], TSTATE_RUNNING
|
||||||
inc esi
|
inc esi
|
||||||
cmp edi, ebx
|
cmp edi, ebx
|
||||||
je .wake_done
|
je .wake_done
|
||||||
|
@ -152,7 +152,7 @@ exc_c: ; exceptions (all but 7th - #NM)
|
|||||||
; not debuggee => say error and terminate
|
; not debuggee => say error and terminate
|
||||||
call show_error_parameters
|
call show_error_parameters
|
||||||
sti
|
sti
|
||||||
mov [edx + TASKDATA.state], byte 4 ; terminate
|
mov [edx + TASKDATA.state], TSTATE_TERMINATING ; terminate
|
||||||
call wakeup_osloop
|
call wakeup_osloop
|
||||||
call change_task
|
call change_task
|
||||||
; If we're here, then the main OS thread has crashed before initializing IDLE thread.
|
; If we're here, then the main OS thread has crashed before initializing IDLE thread.
|
||||||
@ -187,7 +187,7 @@ exc_c: ; exceptions (all but 7th - #NM)
|
|||||||
call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc
|
call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc
|
||||||
add esp, 12
|
add esp, 12
|
||||||
mov edx, [TASK_BASE]
|
mov edx, [TASK_BASE]
|
||||||
mov byte [edx+TASKDATA.state], 1 ; suspended
|
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED ; suspended
|
||||||
call change_task ; SEE: core/shed.inc
|
call change_task ; SEE: core/shed.inc
|
||||||
restore_ring3_context
|
restore_ring3_context
|
||||||
iretd
|
iretd
|
||||||
@ -419,7 +419,7 @@ destroy_thread:
|
|||||||
jnz @F
|
jnz @F
|
||||||
pop esi
|
pop esi
|
||||||
shl esi, BSF sizeof.TASKDATA
|
shl esi, BSF sizeof.TASKDATA
|
||||||
mov [TASK_TABLE+esi+TASKDATA.state], 9
|
mov [TASK_TABLE+esi+TASKDATA.state], TSTATE_FREE
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
push edx ;save .process
|
push edx ;save .process
|
||||||
@ -639,7 +639,7 @@ destroy_thread:
|
|||||||
lea esi, [WIN_POS+eax*2]
|
lea esi, [WIN_POS+eax*2]
|
||||||
movzx edi, word [esi] ; edi = process
|
movzx edi, word [esi] ; edi = process
|
||||||
shl edi, BSF sizeof.TASKDATA
|
shl edi, BSF sizeof.TASKDATA
|
||||||
cmp [TASK_TABLE + edi + TASKDATA.state], byte 9 ; skip dead slots
|
cmp [TASK_TABLE + edi + TASKDATA.state], TSTATE_FREE ; skip free slots
|
||||||
je .check_next_window
|
je .check_next_window
|
||||||
add edi, window_data
|
add edi, window_data
|
||||||
; \begin{diamond}[19.09.2006]
|
; \begin{diamond}[19.09.2006]
|
||||||
@ -714,7 +714,7 @@ destroy_thread:
|
|||||||
popa
|
popa
|
||||||
mov edi, esi ; do not run this process slot
|
mov edi, esi ; do not run this process slot
|
||||||
shl edi, BSF sizeof.TASKDATA
|
shl edi, BSF sizeof.TASKDATA
|
||||||
mov [edi+TASK_TABLE + TASKDATA.state], byte 9
|
mov [edi+TASK_TABLE + TASKDATA.state], TSTATE_FREE
|
||||||
; debugger test - terminate all debuggees
|
; debugger test - terminate all debuggees
|
||||||
mov eax, 2
|
mov eax, 2
|
||||||
mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot
|
mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot
|
||||||
|
@ -493,13 +493,12 @@ pid_to_slot:
|
|||||||
.loop:
|
.loop:
|
||||||
;ecx = offset of current process info entry
|
;ecx = offset of current process info entry
|
||||||
;ebx = maximum permitted offset
|
;ebx = maximum permitted offset
|
||||||
; state 9 means "not used"
|
cmp [TASK_TABLE+ecx+TASKDATA.state], TSTATE_FREE
|
||||||
cmp byte [TASK_TABLE+ecx+TASKDATA.state], TSTATE_FREE
|
|
||||||
jz .endloop ;skip empty slots
|
jz .endloop ;skip empty slots
|
||||||
cmp [TASK_TABLE+ecx+TASKDATA.pid], eax;check PID
|
cmp [TASK_TABLE+ecx+TASKDATA.pid], eax;check PID
|
||||||
jz .pid_found
|
jz .pid_found
|
||||||
.endloop:
|
.endloop:
|
||||||
add ecx, 32
|
add ecx, sizeof.TASKDATA
|
||||||
cmp ecx, ebx
|
cmp ecx, ebx
|
||||||
jle .loop
|
jle .loop
|
||||||
|
|
||||||
@ -895,7 +894,7 @@ common_app_entry:
|
|||||||
cmp [ebx+APPDATA.debugger_slot], 0
|
cmp [ebx+APPDATA.debugger_slot], 0
|
||||||
je .exit
|
je .exit
|
||||||
mov eax, [TASK_BASE]
|
mov eax, [TASK_BASE]
|
||||||
mov [eax+TASKDATA.state], 1
|
mov [eax+TASKDATA.state], TSTATE_RUN_SUSPENDED
|
||||||
call change_task
|
call change_task
|
||||||
.exit:
|
.exit:
|
||||||
popad
|
popad
|
||||||
@ -987,7 +986,7 @@ proc set_app_params stdcall,slot:dword, params:dword, flags:dword
|
|||||||
|
|
||||||
inc dword [process_number]
|
inc dword [process_number]
|
||||||
mov eax, [process_number]
|
mov eax, [process_number]
|
||||||
mov [ebx+4], eax ;set PID
|
mov [ebx+TASKDATA.pid], eax ;set PID
|
||||||
|
|
||||||
;set draw data to full screen
|
;set draw data to full screen
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
|
Loading…
Reference in New Issue
Block a user