In-class activity 1 Flashcards
Give one example of fork() in common applications
- when we double-click on an icon, a program (new process) opens in a new window
- running a sub-process on a shell creates a new command with a fork
when a process is created using fork(), the ____ is not inherited by the child process
- process id
- parent’s list of file descriptor
what happens if you call exec before fork in a shell
the code doesn’t work because the shell’s address space is replaced with the exec’s command, and the shell will terminate once the command is terminated
how is a system call different from a typical procedure call
system calls have a mode switch from user mode to kernel mode
Assume that the root process has pid = 1000; what can you say about the pid of a child?
a) It will be greater than 1001
b) Any number greater than 1000
c) It Could be any random number.
Any random number
limit on the maximum number of pids, they will be reused after a certain time
If we put the parent process to sleep, and meanwhile, the child process exits. What will happen in this scenario?
The child will become a zombie process (A process that has finished the execution but still has an entry in the process table to report to its parent process)
what is the purpose of calling wait(NULL) instead of wait()
wait(null) blocks the parent process until any of its children exit, otherwise the child might become an orphan process
do changes of a global variable in a parent process change the variable in the child process
no, they both have their own copies
Fill in the correct boolean expression to complete the fragments.
if ( … )
printf( “I am not an orphan child \n” );
getppid() != -1