W3 - Processes (Part II) Flashcards

(81 cards)

1
Q

What two problems does process scheduling solve?

A
  • When to switch to another process
  • Which process to choose next from among the ones that are ready to run.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the goal of response time in process scheduling?

A

Minimise average and maximum wait time to make programs responsive.

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

What is throughput in process scheduling?

A

Maximising the number of processes completed in a given time.

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

What is turnaround time in process scheduling?

A

The total time from when a process is submitted to when it finishes execution.

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

How is turnaround time related to throughput?

A

Minimising turnaround time (the time from submission to completion) improves throughput.

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

What does efficiency/utilisation aim to achieve in scheduling?

A

Efficient use of resources by avoiding CPU idle time.

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

What is process starvation, and how should scheduling address it?

A

A process being denied execution or resources for too long; scheduling should prevent it.

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

How should time be shared among processes?

A

Fairly, depending on the type of process (batch jobs vs interactive).

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

In scheduling, when is throughput more important?

A

For batch jobs with lots of computations.

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

In scheduling, when is response time more important?

A

For interactive programs.

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

What are the main aims of process scheduling?

A

Minimise response time (programs must be responsive)

Maximise throughput (more processes finished by reducing turnaround time)

Maximise efficiency/utilisation (avoid idle time for CPU)

Prevent starvation

Share time fairly, prioritising throughput for batch jobs and response time for interactive jobs.

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

For batch (CPU-intensive) processes, what matters most in scheduling?

A

Throughput — completing as many processes as possible.

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

For interactive (I/O-intensive) processes, what matters most in scheduling?

A

Response time — quick reactions to user or I/O events.

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

Can a process change characteristics over time?

A

Yes, processes can shift between CPU-intensive and I/O-intensive behavior.

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

What is real-time scheduling concerned with?

A

Guaranteeing deadlines are met (e.g., braking before hitting a wall).

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

How does First-Come-First-Served (FCFS) scheduling assign the CPU?

A

Processes are assigned the CPU in the order they request it.

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

What happens when a new process arrives in FCFS?

A

It is added to the end of the Ready queue.

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

How does FCFS scheduling track processes?

A

It uses a single ready queue. Newly arrived processes are placed at the end of the queue.

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

Can a running process be preempted in FCFS because it runs too long?

A

No, FCFS is non-preemptive — a process keeps the CPU until it finishes or is interrupted by I/O.

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

Which type of process does FCFS favor?

A

CPU-intensive processes (because they hold the CPU longer).

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

What is a major problem with FCFS scheduling?

A

Short processes can get stuck waiting behind long processes.

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

Why is FCFS simple to implement?

A

It just needs a simple linked list queue.

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

When does FCFS work better?

A

When all processes are the same (or similar) length.

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

What are the key points of First-Come-First-Served (FCFS) scheduling?

A

Processes served in request order

No forced interruption for long-running processes

Favors CPU-intensive processes

Short processes can suffer delays

Simple linked list queue implementation

Best if process lengths are similar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is preemption in process scheduling?
The act of interrupting a running process and forcibly taking the CPU away to give it to another process.
26
What is the problem with FCFS scheduling?
Long processes increase average waiting and completion times, causing short processes to wait unnecessarily.
27
What is non-preemptive scheduling?
Once a process starts running, it keeps the CPU until it finishes, blocks for I/O, or voluntarily gives up the CPU.
28
Is FCFS preemptive or non-preemptive?
Non-preemptive.
29
What is preemptive scheduling?
The currently running process can be interrupted and forced to give up the CPU.
30
When can preemption occur?
When a new process arrives, on an interrupt, or periodically based on a timer.
31
What is the key difference between non-preemptive and preemptive scheduling?
In non-preemptive scheduling, processes keep the CPU until done or blocked; in preemptive scheduling, processes can be interrupted and the CPU reassigned.
32
What is Round Robin (RR) scheduling?
A preemptive scheduling method where each process is given a fixed time slice (time quantum) before being preempted and moved to the back of the queue.
33
How does Round Robin scheduling use preemption?
It uses a periodic clock interrupt (time slicing) to ensure each process gets a turn to run for a set amount of time before being preempted.
34
What happens after a process in Round Robin scheduling completes its time slice?
The process moves to the back of the queue, and the next ready process is selected to run.
35
What kind of processes does Round Robin scheduling favor, and why?
Round Robin scheduling is better for shorter jobs and when jobs have varying lengths, as it gives each process a fair share of CPU time.
36
Why is Round Robin considered more fair than FCFS?
Round Robin ensures that each process gets a fair amount of CPU time, while FCFS can favor longer jobs and cause shorter jobs to wait.
37
Burst Time
The time a process needs to run on the CPU
38
38
38
38
39
AIn Round Robin scheduling, what happens if a process finishes its burst time before its allocated time slice is over?
The process is removed from the queue after finishing, and the next process in line gets the CPU.
40
Waiting Time Formula
Turnaround Time - Burst Time
41
Turnaround Time
The total time from when a process is submitted until it finishes (includes both execution time and waiting time).
42
What happens if the time quantum (q) in Round Robin scheduling is set too long?
Computationally heavy processes are favored, leading to poor responsiveness, as processes may use the entire quantum before performing I/O.
43
What happens if the time quantum (q) in Round Robin scheduling is set too short?
The system may spend more time performing context switches than executing the processes, which leads to inefficiency.
44
What is the typical range for time quantum (q) in Round Robin scheduling?
Time quantum values typically range from 10 ms to 100 ms.
45
What is the typical overhead for context switching in Round Robin scheduling?
The typical overhead for context switching is between 0.1 ms and 1 ms, leading to roughly 1% overhead in total.
46
What is the main goal of multi-level feedback queues in process scheduling?
The goal is to optimize turnaround time (by prioritizing shorter jobs) and minimize response time (to ensure system responsiveness).
47
Why is predicting how long a process will run for a challenge in multi-level feedback queues?
The OS does not know in advance how long a process will run, making it difficult to allocate priorities based on execution time.
48
How does the multi-level feedback queue improve system responsiveness?
By adjusting the priority of processes, the system ensures that interactive processes are prioritized, making the system feel more responsive for the user.
49
What types of priority values can be assigned to processes in multi-level feedback queues?
Processes can be assigned static or dynamic priority values.
50
How are dynamic priorities managed in multi-level feedback queues?
The OS adjusts a process’s priority up or down based on heuristics like interactivity and burst behavior. For example, Linux scheduler links priority to the amount of CPU time a process has used—less CPU time = higher priority.
51
How does multi-level feedback queues handle different priority levels?
Multiple ready queues represent each priority level, allowing processes to be handled according to their assigned priority.
52
How does the multi-level feedback queue scheduler select a process for execution?
The scheduler starts at the highest priority queue (e.g., RQ2). If there are processes in the queue, one is selected using a scheduling policy (e.g., Round Robin). If RQ2 is empty, it moves to the next lower priority queue (e.g., RQ1).
53
What is the problem with lower-priority processes in multi-level feedback queues?
Starvation can occur, where lower-priority processes may never get CPU time if the higher-priority queues are always full.
54
How does the system address starvation in multi-level feedback queues?
The priority of processes can change over time. For example, processes that have run for less time may receive a priority boost, or all processes may get a boost after a certain period.
55
What happens when Priority(A) > Priority(B) in multi-level feedback queues?
Process A runs, and Process B does not.
56
What happens when Priority(A) = Priority(B) in multi-level feedback queues?
Processes A and B run in Round Robin.
57
What happens when a process enters the system in a multi-level feedback queue?
The process enters at the highest priority queue.
58
What happens if a process uses up its entire time slice in a multi-level feedback queue?
The process moves to a lower-priority queue, and its priority is reduced (regardless of how many times it has given up the CPU)
59
How does the system prevent starvation in multi-level feedback queues?
Periodically, all processes are moved back to the highest-priority queue.
60
How common is MLFQ scheduling?
It is used in many desktop operating systems.
61
What does multi-level feedback queue scheduling tend to favour?
It tends to favour newer and shorter jobs, as well as I/O-bound processes over CPU-bound processes.
62
What issue may occur with the turnaround time of longer processes in multi-level feedback queues?
The turnaround time of longer processes may stretch out as they move down priority levels, potentially leading to starvation if new jobs are constantly entering the system.
63
How does MLFQ compensate for the turnaround time of longer processes stretching out as they move down to lower priority levels?
The time slice can vary according to the priority queue.
64
How can the time slice vary in multi-level feedback queues? Give an example.
The time slice can vary based on the priority queue. For example, the highest priority queue might have a time slice of 10ms, the second priority queue 20ms, and the third 40ms.
65
What is Process ID (or PID)?
A unique identifier assigned to each process.
66
Can a process create a process?
Yes, using the fork() system call.
67
What does the fork() system call do?
Creates a copy of the current process with a new PID. The new process is the child process, and is created by the parent process.
68
Explain all possible sets of return values from fork()
Returns an integer. A value greater than 0 means it is running in the parent process, and the number returned is the PID of the new child. A value equal to 0 means it is running in the child process. A value less than 0 is an error that must be handled in the original process, and means it is running in the original process.
69
What exactly gets duplicated when calling fork()?
The state of the original process is duplicated in both the parent and child processes, including memory, file descriptors, etc...
70
How does Python interface with system calls for process control?
Python provides an interface to standard UNIX library calls via the os module.
71
What does the os.fork() function do in Python?
The os.fork() function creates a copy of the current process and starts it running, similar to the fork() system call.
72
What is the purpose of os.execv() in Python?
It changes the program being run by the current process, replacing its code with the new program.
73
What does the os.waitpid() function do?
It allows the parent process to wait for a child process to finish, similar to the wait() system call.
74
What is the signal.signal() function used for in Python?
It sends a notification to another process (via the signal module) corresponding to the signal() system call.
75
How do Python's os module functions relate to POSIX system calls?
Python's os module functions, such as os.fork(), os.execv(), os.waitpid(), and signal.signal(), correspond to the standard POSIX system calls like fork(), exec(), wait(), and signal().
76
How do you catch an exception from calling os.fork() in python?
Use try-catch. The type of error to catch is OSError.
77
What is "Copy On Write" (COW) in the context of fork()?
COW delays or prevents copying the parent's address space when a fork() is called. Instead of duplicating resources, the parent and child share the same memory until one of them attempts to write to it, at which point a copy is made. This prevents unnecessary copying particularly when the child executes a new program with exec().
78