






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Time
Process A Process B Process C
Time
Process A Process B Process C
kernel virtual memory (code, data, heap, stack)
memory mapped region for shared libraries
run-time heap (managed by malloc)
user stack (created at runtime)
0 unused
%esp (stack pointer)
memory invisible to user code
brk
0xc
0x
0x
read/write segment (.data, .bss) read-only segment (.init, .text, .rodata)
loaded from the executable file
0xffffffff
Bye
Bye
Bye
Bye
L0 Bye
Bye
Bye
Bye
linux> ./forks 7 & [1] 6639 Running Parent, PID = 6639 Terminating Child, PID = 6640 linux> ps PID TTY TIME CMD 6585 ttyp9 00:00:00 tcsh 6639 ttyp9 00:00:03 forks 6640 ttyp9 00:00:00 forks
void fork7() { if (fork() == 0) { /* Child / printf("Terminating Child, PID = %d\n", getpid()); exit(0); } else { printf("Running Parent, PID = %d\n", getpid()); while (1) ; / Infinite loop */ } }
HC Bye
CT Bye