kern

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