kern

annotate src/test_proc.S @ 89:2f555c81ae67

starting the filesystem
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 08 Dec 2011 18:19:35 +0200
parents c7bd6ec7b946
children
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@75 19 /* this will count the iterations */
nuclear@75 20 xor %ecx, %ecx
nuclear@75 21
nuclear@57 22 infloop:
nuclear@44 23 /* --- print a message --- */
nuclear@44 24 movl $SYS_HELLO, %eax
nuclear@44 25 int $SYSCALL_INT
nuclear@44 26
nuclear@57 27
nuclear@60 28 /* --- sleep for (pid * 2) seconds ---
nuclear@71 29 * grab the pid from the stack and shift it left to
nuclear@71 30 * multiply the pid by 2. Then use that as a sleep interval
nuclear@71 31 * in seconds.
nuclear@60 32 */
nuclear@71 33 movl (%esp), %ebx
nuclear@71 34 shl $1, %ebx
nuclear@44 35 movl $SYS_SLEEP, %eax
nuclear@44 36 int $SYSCALL_INT
nuclear@44 37
nuclear@75 38 inc %ecx
nuclear@75 39
nuclear@75 40 /* let process 2 quit after 2 iterations */
nuclear@75 41 cmpl $2, (%esp)
nuclear@75 42 jne 1f
nuclear@75 43 cmpl $2, %ecx
nuclear@75 44 je exit_proc
nuclear@75 45
nuclear@75 46 1:
nuclear@57 47 jmp infloop
nuclear@44 48
nuclear@75 49 exit_proc:
nuclear@75 50 movl $SYS_EXIT, %eax
nuclear@75 51 movl $0, %ebx
nuclear@75 52 int $SYSCALL_INT
nuclear@75 53
nuclear@75 54 /* shouldn't reach this, trap otherwise */
nuclear@75 55 int $3
nuclear@75 56
nuclear@44 57 .globl test_proc_end
nuclear@44 58 test_proc_end: