Processes & Signals Flashcards

1
Q

What’s a process?

A
  1. An implementation of the abstract machine concept
  2. A running instance of an executable, invoked by a user
    – Can have multiple independent processes of the same executable
  3. A schedulable entity, on the CPU

Also called Task or Job sometimes

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

How does the Process address space looks like?

A

מכתובות נמוכות לגבוהות:
text segment אחריו data segment אחר כך אולי עוד כל מיני סגמנטים ואז הערימה ובסוף בכתובות הגבוהות המחסנית.
המחסנית גדלה כלפי מטה והערימה כלפי מעלה.

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

Can a process access its own PCB?

A

No. because the pcb is in kernel space.

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

What happens to a process after it dies?

A

It becomes a zombie

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

What syscall a parent uses to clear zombie children from the system?

A

wait

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

What flag is needed for wait to not block the parent?

A

WNOHANG

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

What are the steps of fork?

A
  1. fork() initializes a new PCB
  2. Creates a complete copy of parents space in the child.
  3. Return twice:
    – At the parent, with pid>0
    – At the child, with pid=0
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the steps of exec invokation?

A

– Stops the execution of the invoking process
– Loads the executable ‘programPath’
– Starts ‘programPath’, with ‘argv’ as its argv
– Never returns (unless fails)
– Replaces the new process; doesn’t create a new process
• In particular, PID and PPID are the same before/after exec*()

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

Who wait()-s upon an “orphan” process?

A

In linux, Init.
If a parent process terminates, then its zombie children (if any) are
adopted by init

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

What are signals & signal handlers?

A

Signal = notification “sent” to a process
– To asynchronously notify it that some event occurred
• Upon receiving a signal
– The process stops whatever it is doing & handles it
• Default signal handling action
– Either die or ignore (depends on the type of the signal)

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

What does the kill -s n pid utility does?

A

sends signal number n to process pid.

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

What 2 signals the process can’t ignore?

A

– SIGKILL = terminate the receiving process

– SIGSTOP = suspend the receiving process

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

Explain the difference between signal and interrupt by following criteria:

  1. When do they occur?
  2. Who (i) triggers them and (ii) defines their semantics
  3. Who handles them, who blocks them
A
  1. – Both can be asynchronous
    – But signals are invoked only when returning from kernel to user, and
    interrupts can really fire anytime
  2. – Interrupts: hardware – devices (async) or cores (sync)
    – Signals: software (OS) – HW is unaware
  3. – Interrupts: OS
    – Signals: processes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How is blocking signals implemented?

A

– The PCB maintains a set of currently blocked signals
– Which can be manipulated by users via the following syscall
• int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
– ‘how’ = SIG_BLOCK (+=), SIG_UNBLOCK (-=), SIG_SETMASK (=)
– ‘set’ can be maipulated with sigset ops sigetmptyset(sigset_t *set),
sigfillset(sigset_t *), sigaddset(sigset_t *set, int signum),
sigismember(sigset_t *set, int signum)

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