Process Management 1-2 Flashcards

1
Q

What does fork do in a system process?

A

It creates a copy of itself, creates a new process by trapping OS and making it mostly duplicate

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

How many times does fork return when called?

A

Returns twice with each process @ the next instruction)

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

pid_t fork();

A

a system wide unique process identifier.
childs pid value is returned in the parent and parents pid is returned in the childs.

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

What is a forks order of execution?

A

nondeterministic , parent and child run concurrently.

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

Post fork, what relation do the parent and child functions have to each other?

A

They are identical but separate.OS allocates and maintains separate data /state

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

what if fork fails?

A

most syscalls will return -1 on failure

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

What happens to all terminating processes?

A

They turn into zombies, They become dead but still tracked by OS. -pid remains in use -exit status can be queried

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

Reaping processes

A

All processes are responsible for reaping their own immediate children processes

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

How do you kill a zombie process?

A

By killing/ terminating the parent process

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

What happens when the process is orphaned? ( The parent process is killed)

A

They are adopted by the OS kernel, reaping its children.

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

Why is it especially important for long running processes to reap their children?

A

Its important because zombie processes still consume system memory resources. if the parent terminates without reaping the children, then the kernel invokes the init process to reap them

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

Who reaps the parent?

A

The shell

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

what happens when the process is terminated and has more than 1 child?

A

reaps a zombie child
- returns reaped child’s pid and exit status
info via pointer

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

what happens when the process has no children when pid_ wait is called?

A

return -1 immediately populate errno

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

why are fork and exec separate calls?

A

They are separate because we might want to tweak the process before running a program in it.

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

What are task management features?

A

They allow the shell to run track and manage multiple processes at once

17
Q

Difference between foreground and background processes?

A

fg processes: “blocks” additional commands from being run
bg processes can run multiple at once.

18
Q

what are signals and there aspects?

A

They are messages delivered by the kernel to user processes.
Aspects of signal processing:
1. sending a signal to a process
2. registering a handler for a given signal
3. delivering a signal (kernel mechanism)
4. designing a signal handler

19
Q

What happens if a signal is received as its handler is running?

A

mark it as pending, but don’t run the
handler again! (signal currently blocked)

20
Q

what happens if a signal is sent many
times before its handler is run?

A

nothing because we can’t que signals.

21
Q

what happens if a signal is received as
a handler for a lower priority one is
already running?

A

we preempt the lower priority handler
(and resume it — if possible — later)

22
Q

What operations can signals interrupt?

A

They can interrupt any non atomic operations.

23
Q

First design goal on signal handlers?

A

Minimize use of global variables, use mostly primitive data

24
Q

Second design goal for signal handlers?

A

prefer separate handlers for different signals.

25
Q

what is the importance of a signal handler being re-entrant?

A

It can be called again when already executing.

26
Q

what are three important lessons to take into consideration for signal handlers?

A
  1. Signals can be delivered at any time
  2. Sometimes Causing it to execute in overlapping fashion with itself when handling multiple signals
  3. The execution of the sig handlers can overlap , any functions called may have overlapping execution.
27
Q

What is a direct approach that ensures certain sequence of events cannot be interrupted when there is insidious race condition caused by concurrency?
(can’t predict when child will terminate /
when signal will arrive)

A

block the signal

28
Q

What is another instance in which a signal can be blocked?

A

when the program is forced to call non- reentrant functions from signal handlers.