In-class activity 1 Flashcards

1
Q

Give one example of fork() in common applications

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

when a process is created using fork(), the ____ is not inherited by the child process

A
  • process id
  • parent’s list of file descriptor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what happens if you call exec before fork in a shell

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how is a system call different from a typical procedure call

A

system calls have a mode switch from user mode to kernel mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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.

A

Any random number

limit on the maximum number of pids, they will be reused after a certain time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If we put the parent process to sleep, and meanwhile, the child process exits. What will happen in this scenario?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the purpose of calling wait(NULL) instead of wait()

A

wait(null) blocks the parent process until any of its children exit, otherwise the child might become an orphan process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

do changes of a global variable in a parent process change the variable in the child process

A

no, they both have their own copies

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Fill in the correct boolean expression to complete the fragments.
if ( … )
printf( “I am not an orphan child \n” );

A

getppid() != -1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly