launcher:

* automatic detection of the number of launched programs
    (first string in old autorun.dat is deleted)
  * negative delay for a program means that launcher must wait for termination

git-svn-id: svn://kolibrios.org@1013 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Evgeny Grechnikov (Diamond)
2009-01-30 00:09:58 +00:00
parent 31d57b3a45
commit 5d270880da

View File

@@ -26,31 +26,32 @@ START: ; start of execution
; mov ebx, 10 ; mov ebx, 10
; mcall ; mcall
mcall 18,15 ; mcall 18,15
mov eax, 70 ; load AUTORUN.DAT mov eax, 70 ; load AUTORUN.DAT
mov ebx, autorun_dat_info mov ebx, autorun_dat_info
mcall mcall
add ebx, file_data
mov [fileend], ebx
call get_number ; this cycle does not contain an obvious exit condition,
mov [number_of_files], eax ; but auxiliary procedures (like "get_string") will exit
;dps "NUMBER OF FILES: " ; at EOF
;dpd eax
;dps <13,10>
call next_line
start_program: start_program:
;dps <"STARTING A PROGRAM",13,10> call skip_spaces
cmp al,'#'
jz skip_this_string
call clear_strings call clear_strings
mov edi, program mov edi, program
call get_string call get_string
mov edi, parameters mov edi, parameters
call get_string call get_string
call get_number call get_number
;dps <"STARTING A PROGRAM",13,10>
call run_program call run_program
skip_this_string:
call next_line call next_line
dec [number_of_files] jmp start_program
jnz start_program
exit: exit:
or eax, -1 or eax, -1
@@ -62,10 +63,34 @@ START: ; start of execution
mcall 70, start_info mcall 70, start_info
pop ebx pop ebx
; if delay is negative, wait for termination
; of the spawned process
test ebx, ebx
js must_wait_for_termination
; otherwise, simply wait
mov eax, 5 mov eax, 5
mcall mcall
ret ret
must_wait_for_termination:
mov esi, eax ; save slot for the future
; get process slot
mov ecx, eax
mcall 18, 21
; if an error has occured, exit
test eax, eax
jz child_exited
mov ecx, eax
; wait
wait_for_termination:
mcall 5, 1
mov ebx, processinfo
mcall 9
cmp word [ebx+50], 9 ; the slot was freed?
jz child_exited
cmp dword [ebx+30], esi ; the slot is still occupied by our child?
jz wait_for_termination
child_exited:
ret
clear_strings: ; clears buffers clear_strings: ; clears buffers
pushad pushad
@@ -91,6 +116,8 @@ START: ; start of execution
;dps <13,10> ;dps <13,10>
add esi, file_data add esi, file_data
.start: .start:
cmp esi, [fileend]
jae exit
lodsb lodsb
cmp al, ' ' cmp al, ' '
je .finish je .finish
@@ -108,8 +135,18 @@ START: ; start of execution
mov esi, [position] mov esi, [position]
add esi, file_data add esi, file_data
xor eax, eax xor eax, eax
cmp byte [esi], '-'
jnz @f
inc eax
inc esi
inc [position]
@@:
push eax
xor eax, eax
xor ebx, ebx xor ebx, ebx
.start: .start:
cmp esi, [fileend]
jae .finish
lodsb lodsb
sub al, '0' sub al, '0'
cmp al, 9 cmp al, 9
@@ -119,17 +156,24 @@ START: ; start of execution
inc [position] inc [position]
jmp .start jmp .start
.finish: .finish:
pop eax
dec eax
jnz @f
neg ebx
@@:
mov eax, ebx mov eax, ebx
pop esi ebx pop esi ebx
ret ret
skip_spaces: skip_spaces:
pushad push esi
xor eax, eax xor eax, eax
mov esi, [position] mov esi, [position]
add esi, file_data add esi, file_data
.start: .start:
cmp esi, [fileend]
jae .finish
lodsb lodsb
cmp al, ' ' cmp al, ' '
jne .finish jne .finish
@@ -141,33 +185,33 @@ START: ; start of execution
;mov edx, tmp ;mov edx, tmp
;call debug_outstr ;call debug_outstr
;dps <13,10> ;dps <13,10>
popad pop esi
ret ret
next_line: next_line:
pushad
mov esi, [position] mov esi, [position]
add esi, file_data add esi, file_data
.start: .start:
cmp esi, [fileend]
jae exit
lodsb lodsb
cmp al, 13 cmp al, 13
je .finish je .finish
cmp al, 10
je .finish
inc [position] inc [position]
jmp .start jmp .start
.finish: .finish:
add [position], 2 inc [position]
inc esi cmp esi, [fileend]
jae exit
lodsb lodsb
cmp al, '#'
je .skipline
cmp al, 13 cmp al, 13
jne .donotskip je .finish
.skipline: cmp al, 10
call next_line je .finish
.donotskip: ret
popad
ret
@@ -195,6 +239,7 @@ I_END:
program rb 61 ; 60 + [0] char program rb 61 ; 60 + [0] char
parameters rb 61 parameters rb 61
number_of_files dd ? processinfo rb 1024
fileend dd ?
file_data rb 16*512 file_data rb 16*512