kern

annotate 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
rev   line source
nuclear@51 1 #define ASM
nuclear@51 2 #include <syscall.h>
nuclear@44 3
nuclear@44 4 .text
nuclear@44 5 .globl test_proc
nuclear@44 6 test_proc:
nuclear@57 7 /* fork another process */
nuclear@57 8 movl $SYS_FORK, %eax
nuclear@57 9 int $SYSCALL_INT
nuclear@57 10
nuclear@71 11 /* test copy-on-write by pushing the pid to the stack
nuclear@71 12 * then use this value from the stack times 2 as a sleep
nuclear@71 13 * interval in the loop.
nuclear@71 14 */
nuclear@71 15 movl $SYS_GETPID, %eax
nuclear@71 16 int $SYSCALL_INT
nuclear@69 17 push %eax
nuclear@69 18
nuclear@57 19 infloop:
nuclear@44 20 /* --- print a message --- */
nuclear@44 21 movl $SYS_HELLO, %eax
nuclear@44 22 int $SYSCALL_INT
nuclear@44 23
nuclear@57 24
nuclear@60 25 /* --- sleep for (pid * 2) seconds ---
nuclear@71 26 * grab the pid from the stack and shift it left to
nuclear@71 27 * multiply the pid by 2. Then use that as a sleep interval
nuclear@71 28 * in seconds.
nuclear@60 29 */
nuclear@71 30 movl (%esp), %ebx
nuclear@71 31 shl $1, %ebx
nuclear@44 32 movl $SYS_SLEEP, %eax
nuclear@44 33 int $SYSCALL_INT
nuclear@44 34
nuclear@57 35 jmp infloop
nuclear@44 36
nuclear@44 37 .globl test_proc_end
nuclear@44 38 test_proc_end: