Notes From CS Undergrad Courses FSU
This project is maintained by awa03
fork
system call familypid_t pid;
if((pid = fork()) == 0) {
while(1){
print("childs return value %d: I want to play.\n", pid);
}
} else {
while(1) {
print("parent's return value %d: After the project.\n", pid);
}
}
pid_t pid;
if((pid = fork()) == 0) {
while(1){
print("childs return value %d: I want to play.\n", pid);
}
} else {
while(1) {
print("parent's return value %d: After the project.\n", pid);
}
}
childs return value 0: I want to play.\n
childs return value 0: I want to play.\n
childs return value 0: I want to play.\n
...// context switch
parent's return value 3218: After the project.
parent's return value 3218: After the project.
parent's return value 3218: After the project.
...// context switch
childs return value 0: I want to play.\n
childs return value 0: I want to play.\n
childs return value 0: I want to play.\n
exec
system callexec
starts a program by overwriting the current processpthread_create()
instead of using fork()