Ch. 2 - Processes Flashcards

1
Q

fork()

A

Creates an identical copy of the calling process with the same data, values, and registers. The new process is the child process and it has a different pid than its parent.

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

wait()

A

Allows a parent process to check the running status of the child and wait until it is complete.

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

Uniprogram Systems

A

Current program must finish before the next program can be executed.

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

Multi-programming Systems

A

CPU switches automatically from process to process. The CPU only runs one process at any given time.

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

How can several processes share one CPU?

A

-Fair Scheduling (every process gets to run eventually)
-Protection (different processes cannot modify each other’s state)
-Resource sharing

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

What is the dispatcher responsible for?

A

The dispatcher schedules processes. It runs a process for a short period of time then stops the process and saves its state. Finally, the dispatcher loads the state of another process and runs the process.

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

List the different states of a process

A

New (give program resources)
Ready (ready for execution)
Active (process currently executing)
Blocked (voluntary stop)
Stopped (involuntary stop)
Exiting (process leaving CPU)

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

How does the dispatcher regain control of the CPU?

A

“Sleeping Beauty Approach” - Trust the process to wake up the dispatcher when it is done
“Alarm Clock” - Wake up the dispatcher after a certain amount of time has passed (superior approach)

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

What is an issue of using the “sleeping beauty approach” to give the dispatcher control of the CPU?

A

A process may loop indefinitely. Thus, it never finishes so it never wakes up the dispatcher.

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

Context Switching

A

OS saves the state of the active process and restores the state of the interrupt service routine (ISR)

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

Why must the OS disable all interrupts while saving the state of an active process?

A

If the OS is interrupted, it cannot save the state as it must service the interrupt which could also be interrupted.

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

What are the 2 ways of creating a new process? Which method is more efficient?

A

Building a process from scratch
Cloning an existing process

Cloning an existing process is faster as no disk read is necessary.

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

fork() return values

A

Returns the PID of the process that was created
Value greater than 0 - parent process
Value = 0 - child process
Value less than 0 - fork() failed

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

Zombie Process

A

A process that has completed execution but still has an entry in the PCB

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

What are the reasons why a process can enter the exiting state?

A

Normal Completion - exit() or abort called explicitly or implicitly.
Abnormal Termination - programming error, runtime error, I/O error, process killed.

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

What happens when the stack and heap in memory intersect?

A

You have no more memory to allocate

17
Q

What are the similarities between threads and processes?

A

Every thread/process has a state.
Every thread/process has its own stack
Execute sequentially
Can issue system calls

18
Q

What are the differences between threads and processes

A

Creating a thread is less expensive (no process spawned)
Threads within a process share resources while processes have different address spaces
Threads within a process are not independent and not protected against each other

19
Q

Thread Safe Code

A

Code that functions correctly during simultaneous execution by multiple threads.