Chapter 5 - Interlude: Process API Flashcards

1
Q

what does fork() do - system call

A

It copies the calling process, creating a new process (the child)

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

What does the new (child) process get after fork()?

A

Its own address space, registers, and program counter.

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

What does fork() return to the parent process?

A

The PID (Process ID) of the child – a positive value

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

Why can output vary when using fork()?

A

Because execution is non-deterministic – whether the parent or child runs first depends on the CPU scheduler

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

What does fork() return to the child process? - and what return if error

A

0 - negative value

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

What does the CPU scheduler do?

A

It decides which process gets to run and when

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

What happens when a parent calls wait()?

A

It blocks (pauses) until the child process terminates, then returns the child’s PID.

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

How does wait() ensure deterministic output?

A

Whether the child runs first or second, the parent blocks at wait(), so the child always prints before the parent.

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

What does exec() do?

A

It replaces the current process with a new program — code, data, etc., but keeps the same PID.

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

How does redirection work in a shell?

A

Through manipulation of file descriptors before calling exec()

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

What is a signal?

A

A message sent to a process to notify it of an event.

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

What can signals do to a process?

A

kill, pause, resume, trigger custom behaviour

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