kern

diff src/test_proc.S @ 71:c7bd6ec7b946

changed test_proc to modify memory after the fork in order to try out copy-on-write, by pushing the result of getpid on the stack.
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 13 Oct 2011 05:22:35 +0300
parents b45e2d5f0ae1
children 8b21fe04ba2c
line diff
     1.1 --- a/src/test_proc.S	Wed Oct 12 14:46:00 2011 +0300
     1.2 +++ b/src/test_proc.S	Thu Oct 13 05:22:35 2011 +0300
     1.3 @@ -8,6 +8,12 @@
     1.4  	movl $SYS_FORK, %eax
     1.5  	int $SYSCALL_INT
     1.6  
     1.7 +	/* test copy-on-write by pushing the pid to the stack
     1.8 +	 * then use this value from the stack times 2 as a sleep
     1.9 +     * interval in the loop.
    1.10 +	 */
    1.11 +	movl $SYS_GETPID, %eax
    1.12 +	int $SYSCALL_INT
    1.13  	push %eax
    1.14  
    1.15  infloop:
    1.16 @@ -15,20 +21,14 @@
    1.17  	movl $SYS_HELLO, %eax
    1.18  	int $SYSCALL_INT
    1.19  
    1.20 -	/* --- call getpid ---
    1.21 -	 * we'll use the process id, multiplied by two as a
    1.22 -	 * sleep interval, to avoid having the two test processes
    1.23 -	 * sleep for identical amounts of time.
    1.24 -	 */
    1.25 -	movl $SYS_GETPID, %eax
    1.26 -	int $SYSCALL_INT
    1.27 -	movl %eax, %ebx
    1.28 -	shl $1, %ebx
    1.29  
    1.30  	/* --- sleep for (pid * 2) seconds --- 
    1.31 -	 * ebx (the argument to sleep) already contains the
    1.32 -	 * correct value
    1.33 +	 * grab the pid from the stack and shift it left to
    1.34 +	 * multiply the pid by 2. Then use that as a sleep interval
    1.35 +	 * in seconds.
    1.36  	 */
    1.37 +	movl (%esp), %ebx
    1.38 +	shl $1, %ebx
    1.39  	movl $SYS_SLEEP, %eax
    1.40  	int $SYSCALL_INT
    1.41