kern

changeset 75:8b21fe04ba2c

testing of the exit syscall
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 15 Oct 2011 08:07:09 +0300
parents d3601789d638
children 0fe6eef16335
files src/proc.c src/test_proc.S
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/src/proc.c	Sat Oct 15 08:06:58 2011 +0300
     1.2 +++ b/src/proc.c	Sat Oct 15 08:07:09 2011 +0300
     1.3 @@ -215,6 +215,8 @@
     1.4  
     1.5  	p = get_current_proc();
     1.6  
     1.7 +	printf("process %d exit(%d)\n", p->id, status);
     1.8 +
     1.9  	/* TODO deliver SIGCHLD to the parent */
    1.10  
    1.11  	/* find any child processes and make init adopt them */
     2.1 --- a/src/test_proc.S	Sat Oct 15 08:06:58 2011 +0300
     2.2 +++ b/src/test_proc.S	Sat Oct 15 08:07:09 2011 +0300
     2.3 @@ -16,6 +16,9 @@
     2.4  	int $SYSCALL_INT
     2.5  	push %eax
     2.6  
     2.7 +	/* this will count the iterations */
     2.8 +	xor %ecx, %ecx
     2.9 +
    2.10  infloop:
    2.11  	/* --- print a message --- */
    2.12  	movl $SYS_HELLO, %eax
    2.13 @@ -32,7 +35,24 @@
    2.14  	movl $SYS_SLEEP, %eax
    2.15  	int $SYSCALL_INT
    2.16  
    2.17 +	inc %ecx
    2.18 +
    2.19 +	/* let process 2 quit after 2 iterations */
    2.20 +	cmpl $2, (%esp)
    2.21 +	jne 1f
    2.22 +	cmpl $2, %ecx
    2.23 +	je exit_proc
    2.24 +
    2.25 +1:
    2.26  	jmp infloop
    2.27  
    2.28 +exit_proc:
    2.29 +	movl $SYS_EXIT, %eax
    2.30 +	movl $0, %ebx
    2.31 +	int $SYSCALL_INT
    2.32 +
    2.33 +	/* shouldn't reach this, trap otherwise */
    2.34 +	int $3
    2.35 +
    2.36  	.globl test_proc_end
    2.37  test_proc_end: