Operating systems CPU scheduling algorithms notes

This study set covers essential CPU scheduling algorithms used in operating systems, including definitions, characteristics, and examples for each algorithm. Ideal for college-level computer science students looking to understand how different scheduling strategies impact process management.

LiamJ1·64 flashcards·64 questions
collegecomputer_sciencecomputer_basics
0
Known
1 / 64
0
Learning
Front

What is CPU scheduling?

Tap to flip
Back

CPU scheduling is the process of determining which process in the ready state should be allocated CPU time. It aims to maximize CPU utilization and minimize response time.

Tap to flip
Got it
Still learning

Quiz(64 questions)

Question 1 of 64

1. What is the primary purpose of CPU scheduling?

Terms in this Study Set(64)

Fundamental Scheduling Concepts(16)

What is CPU scheduling?

CPU scheduling is the process of determining which process in the ready state should be allocated CPU time. It aims to maximize CPU utilization and minimize response time.

True or False: CPU scheduling is only for multitasking operating systems.

False. While it's crucial for multitasking, even single-task systems use scheduling to manage processes effectively.

Define 'context switch'.

A context switch is the process of storing the state of a currently running process and loading the state of another process. It allows multiple processes to share the CPU.

What is a 'ready queue'?

A ready queue is a data structure that holds all processes that are ready to execute but are waiting for CPU allocation. It allows the scheduler to manage processes efficiently.

Fill in the blank: The goal of CPU scheduling is to maximize ___ and minimize ___.

Throughput; turnaround time

List two factors influencing CPU scheduling.

- Process priority - Process burst time

What are 'burst time' and 'waiting time'?

Burst time is the total time a process needs on the CPU. Waiting time is the total time a process spends waiting in the ready queue before being executed.

Cause → Effect: High priority assigned to a process.

Effect: The process receives more CPU time compared to lower-priority processes.

Comparison: Preemptive vs Non-preemptive scheduling.

Preemptive allows interruption of running processes; Non-preemptive does not. Preemptive enhances responsiveness, while Non-preemptive avoids context switching overhead.

What is 'turnaround time'?

Turnaround time is the total time taken from submission to completion of a process. It includes waiting and execution times.

Define 'throughput'.

Throughput is the number of processes completed in a given time frame, often expressed as processes per second.

What is 'starvation' in scheduling?

Starvation occurs when a process waits indefinitely for CPU time, often due to lower priority compared to other processes.

True or False: All scheduling algorithms provide the same performance.

False. Different algorithms can lead to varying performance metrics, such as response time and CPU utilization.

What is a scheduling algorithm?

A scheduling algorithm determines the order in which processes access the CPU. Common types include First-Come, First-Served (FCFS) and Round Robin (RR).

Example: Calculate turnaround time.

Process A: Arrival Time = 0, Burst Time = 5, Completion Time = 10. Turnaround Time = Completion Time - Arrival Time = 10 - 0 = 10.

What does 'response time' measure?

Response time measures the time from process submission to the first response, crucial for interactive systems.

Preemptive Scheduling Algorithms(16)

What is preemptive scheduling?

Preemptive scheduling allows the CPU to interrupt a currently running process to give CPU time to another process.

Example of a preemptive scheduling algorithm?

Round Robin is a common preemptive scheduling algorithm that allocates a fixed time slice to each process.

True or False: Preemptive scheduling can lead to resource starvation.

True. If a process is frequently preempted, it may suffer from starvation, being unable to complete its execution.

How does Round Robin handle processes?

Processes are assigned a time quantum. After that time elapses, the CPU is preempted and given to the next process in the queue.

Compare preemptive and non-preemptive scheduling.

Preemptive: Can interrupt processes. Non-preemptive: Processes run to completion without interruption.

What is Multilevel Queue Scheduling?

This algorithm divides the ready queue into several separate queues based on priority, each with its own scheduling algorithm.

Fill in the blank: Preemptive scheduling is crucial for ____ systems.

real-time systems, where timely responses are critical.

What happens in Shortest Remaining Time First?

The CPU is allocated to the process with the least remaining time, allowing preemption for shorter tasks.

Describe the effect of time quantum size.

A small time quantum increases context switching and overhead. A large time quantum can lead to longer wait times.

True or False: Preemptive scheduling improves responsiveness.

True. Processes can be allocated CPU time quickly, enhancing overall system responsiveness.

Example of Starvation in preemptive scheduling?

A low-priority process may be continuously preempted by higher-priority processes, delaying its execution indefinitely.

What is the role of priority in preemptive scheduling?

Processes with higher priority can preempt lower-priority processes, ensuring that critical tasks receive timely CPU access.

How does a process enter the ready queue?

When a process is created or becomes runnable, it is added to the ready queue, awaiting CPU allocation.

What is Context Switching?

The process of saving the state of a currently running process and loading the state of the next process to run.

True or False: Preemptive scheduling always leads to better performance.

False. While it improves responsiveness, it can increase context switching overhead, potentially degrading performance.

What is the primary benefit of preemptive scheduling?

It allows high-priority processes to execute promptly, improving system responsiveness and efficiency.

Non-preemptive Scheduling Algorithms(16)

What is Non-Preemptive Scheduling?

Non-preemptive scheduling allows a running process to complete its execution without interruption. Once CPU allocation is given, it won't be taken away until the process finishes.

Advantages of Non-Preemptive Scheduling?

- Simplicity of implementation - Reduced context switching - Predictable process behavior

True or False: Non-preemptive scheduling is more responsive than preemptive scheduling.

False. Non-preemptive scheduling can lead to longer wait times for other processes, making it less responsive.

Example of Non-Preemptive Scheduling Algorithm?

First-Come, First-Served (FCFS) is a classic example, where processes are executed in the order they arrive.

What is First-Come, First-Served (FCFS)?

A non-preemptive scheduling algorithm where the first process that arrives is the first to be executed until completion.

How does FCFS handle process completion?

Processes are completed in the order of their arrival. For example, if Process A arrives before Process B, A will finish before B.

What is Shortest Job Next (SJN)?

SJN, or Shortest Job First (SJF), is a non-preemptive algorithm that selects the process with the smallest execution time next.

Comparison: FCFS vs SJN?

FCFS is simpler but can lead to longer average wait times. SJN can minimize waiting time but requires knowledge of process lengths.

What happens in Non-Preemptive Round Robin?

Non-preemptive Round Robin does not exist. Round Robin is inherently preemptive since it allocates time slices.

True or False: Non-preemptive scheduling is suitable for batch processing.

True. Non-preemptive scheduling works well in environments where tasks are predictable, such as batch processing.

What is Priority Scheduling?

In Priority Scheduling, processes are assigned priorities, and the one with the highest priority is executed first. Non-preemptive levels ensure a running process isn't interrupted.

Cause → Effect: Low priority in Non-Preemptive Scheduling?

Processes with low priority may experience starvation as high-priority processes continue to execute.

Fill in the blank: Non-preemptive scheduling is less effective in environments with __________ processes.

interactive processes.

What is the ideal scenario for Non-Preemptive Scheduling?

Best for systems with long, non-interactive jobs where predictability and minimal context switching are desired.

Example of process wait in Non-Preemptive Scheduling?

If Process A takes 10 seconds and Process B takes 3 seconds, B must wait 10 seconds before execution starts.

True or False: Non-preemptive algorithms always maximize CPU utilization.

False. They can lead to lower CPU utilization during long wait times for lower priority processes.

Advanced Scheduling Techniques(16)

Multilevel Queue Scheduling

This algorithm divides the ready queue into multiple queues, each with different priority levels. - Examples: foreground and background processes.

True or False: Round Robin is suitable for real-time systems.

False. Round Robin does not guarantee timely execution, which is crucial for real-time systems.

What is the purpose of Feedback Scheduling?

Feedback Scheduling dynamically adjusts the priority of processes based on their behavior and execution time, helping to optimize CPU usage.

First-Come, First-Served vs. Shortest Job First

First-Come, First-Served (FCFS) serves processes in the order they arrive, while Shortest Job First (SJF) prioritizes the shortest tasks. - SJF minimizes waiting time.

What is Lottery Scheduling?

Lottery Scheduling assigns tickets to processes; the CPU is allocated to a randomly selected ticket holder, promoting fairness in resource allocation.

True or False: Priority Scheduling can lead to starvation.

True. Lower-priority processes may wait indefinitely if higher-priority processes continually arrive.

What are Real-Time Scheduling Algorithms?

These algorithms ensure processes meet strict timing constraints. - Examples: Rate Monotonic Scheduling, Earliest Deadline First.

Compare Static vs. Dynamic Priority Scheduling.

Static priority does not change, while dynamic priority can adjust based on process behavior or system load, improving responsiveness.

Fill in the blank: In _____ Scheduling, I/O-bound processes get higher priority.

Multilevel Feedback Queue. This helps improve overall system responsiveness.

What is the main goal of Fair Share Scheduling?

To allocate CPU time fairly among users or groups, ensuring that all have equitable access to resources.

Cause → Effect: High-priority aging.

Cause: Continuous arrival of high-priority processes. Effect: Low-priority processes may starve and not execute.

What is the key concept behind Weighted Fair Queuing?

Weighted Fair Queuing allows processes to share bandwidth fairly based on assigned weights, ensuring efficient network resource allocation.

True or False: Earliest Deadline First is optimal for periodic tasks.

True. It can guarantee the timely execution of periodic tasks if the total utilization is below a certain threshold.

What is the advantage of using Hybrid Scheduling?

Hybrid Scheduling combines multiple algorithms to capitalize on their strengths, improving overall system performance and responsiveness.

Example: Calculate wait time in SJF scheduling.

Processes: P1 (2ms), P2 (4ms), P3 (1ms). Wait times: P1 = 0, P2 = 2, P3 = 6. Average wait = 2ms.

What is the purpose of Completely Fair Scheduler?

The Completely Fair Scheduler (CFS) aims to allocate CPU time fairly among all processes by using a time-sharing mechanism. - Operates based on virtual runtime. - Balances responsiveness and throughput. - Suitable for desktop and server environments.

Questions in this Study Set(64)

1. What is the primary purpose of CPU scheduling?

A.To allocate CPU time to processes efficiently
B.To manage memory allocation
C.To control input/output devices
D.To monitor network traffic

2. What is the main characteristic of Multilevel Queue Scheduling?

A.It divides processes into queues based on priority levels.
B.It processes all tasks in a single queue without differentiation.
C.It assigns fixed time slots to all processes equally.
D.It prioritizes I/O-bound processes exclusively.

3. What characterizes Non-Preemptive Scheduling?

A.Running processes are not interrupted until completion.
B.Processes can be interrupted at any time.
C.Processes are prioritized based on their execution times.
D.All processes are executed in a random order.

4. What does preemptive scheduling allow the operating system to do?

A.Interrupt a running process
B.Run all processes to completion
C.Prioritize low-priority tasks
D.Avoid context switching

5. Which of the following best describes a context switch?

A.The process of saving and loading process states
B.A method for prioritizing processes
C.An operation to terminate a process
D.A technique to increase CPU speed

6. True or False: Round Robin scheduling is ideal for CPU-bound tasks.

A.True
B.False
C.Not suitable
D.Only for I/O-bound

7. Which of the following is a benefit of Non-Preemptive Scheduling?

A.Increased responsiveness to user inputs.
B.Reduction in context switching overhead.
C.Higher overall CPU utilization.
D.Ability to handle interactive processes efficiently.

8. Which of the following is a characteristic of the Round Robin scheduling algorithm?

A.Processes are assigned a fixed time slice
B.It prioritizes processes based on their memory usage
C.It runs processes indefinitely
D.Processes are executed based on arrival time only

9. What happens if a process has a high priority in scheduling?

A.It receives less CPU time than normal processes
B.It gets executed before lower-priority processes
C.It will never be scheduled
D.It will always complete first

10. What does Feedback Scheduling aim to achieve?

A.Optimize CPU usage by adjusting process priorities dynamically.
B.Ensure equal time distribution among all processes.
C.Prevent starvation of lower-priority processes.
D.Assign static priorities based on process types.

11. True or False: Non-Preemptive Scheduling typically leads to shorter wait times for all processes.

A.True
B.False
C.Depends on process priority.
D.Only true for interactive processes.

12. True or False: One disadvantage of preemptive scheduling is potential resource starvation.

A.True
B.False
C.Only in non-preemptive systems
D.Only for low-priority tasks

13. Which of the following is NOT a common CPU scheduling algorithm?

A.Round Robin
B.Shortest Job First
C.First-Come, First-Served
D.First-Priority, Last-Served

14. How do First-Come, First-Served and Shortest Job First differ?

A.FCFS serves in order of arrival, while SJF serves the shortest tasks first.
B.FCFS is more efficient than SJF in all scenarios.
C.SJF is a type of FCFS scheduling.
D.Both prioritize tasks based on arrival time.

15. What is an example of a Non-Preemptive Scheduling algorithm?

A.Shortest Job First (SJF)
B.Round Robin Scheduling
C.Multilevel Queue Scheduling
D.Priority-based Preemptive Scheduling

16. How does Shortest Remaining Time First (SRTF) operate?

A.It runs the process with the least remaining time first
B.It runs processes in the order they arrive
C.It runs all processes until the longest one is complete
D.It gives equal time to all processes

17. Define 'throughput' in the context of CPU scheduling.

A.The total time taken for a process to complete
B.The number of processes completed in a given time
C.The average waiting time of processes
D.The time from submission to first response

18. What is the main principle of Lottery Scheduling?

A.Processes are assigned tickets for CPU access.
B.It guarantees equal CPU time to every process.
C.Processes are prioritized based on their identifiers.
D.It uses a round-robin approach for all processes.

19. In Non-Preemptive Scheduling, how is process execution determined?

A.By the shortest execution time.
B.By the order of arrival.
C.By process priority levels.
D.Randomly chosen among all processes.

20. What is a key difference between preemptive and non-preemptive scheduling?

A.Preemptive can interrupt, non-preemptive cannot
B.Non-preemptive is faster overall
C.Preemptive schedules processes based on priority only
D.Non-preemptive uses fixed time slices

21. True or False: Context switching is always beneficial for CPU scheduling.

A.True
B.False
C.Only in preemptive scheduling
D.Only in non-preemptive scheduling

22. True or False: Priority Scheduling guarantees that all processes will execute in a timely manner.

A.True
B.False
C.Only for high-priority tasks
D.Depends on the system load

23. Which statement about Shortest Job Next (SJN) is true?

A.It prioritizes processes based on arrival time.
B.It can lead to increased wait times for longer processes.
C.It guarantees the highest CPU utilization.
D.It is a preemptive scheduling algorithm.

24. What is Multilevel Queue Scheduling designed to do?

A.Separate processes into different queues based on priority
B.Allocate equal CPU time to all processes
C.Run processes in the order they arrive
D.Eliminate context switching

25. What is 'waiting time' for a process?

A.The time a process spends in the ready queue
B.The time spent in execution
C.The time from submission to completion
D.The time it takes to switch contexts

26. What defines Real-Time Scheduling Algorithms?

A.They ensure tasks meet strict timing constraints.
B.They focus on maximizing CPU utilization.
C.They are suitable for all types of processes.
D.They use random selection for task execution.

27. What happens when a low-priority process is executed in Non-Preemptive Scheduling?

A.It will always run to completion first.
B.It may starve if higher-priority processes are available.
C.It is guaranteed to run after high-priority processes.
D.It can be preempted by other processes.

28. What is the impact of a small time quantum in preemptive scheduling?

A.Increased context switching
B.Decreased CPU utilization
C.Longer wait times for processes
D.Less overhead in scheduling

29. Which statement correctly describes turnaround time?

A.It is the time taken from process submission to its completion
B.It is the time a process waits in the ready queue
C.It is the number of processes completed in a time frame
D.It is the time taken for the first response

30. In terms of priority, how does Static Scheduling differ from Dynamic Scheduling?

A.Static does not change, while dynamic can adjust based on conditions.
B.Static always gives higher priority to I/O-bound tasks.
C.Dynamic scheduling is faster than static scheduling.
D.Both can change priorities based on time.

31. Which scenario illustrates a drawback of Non-Preemptive Scheduling?

A.An interactive application responds quickly to user input.
B.A long-running task delays the execution of a shorter task.
C.Multiple processes are simultaneously executed.
D.Processes are executed based on their defined priorities.

32. True or False: Preemptive scheduling enhances system responsiveness.

A.True
B.False
C.Only for real-time systems
D.Only for batch processing

33. What is the effect of starvation in CPU scheduling?

A.Processes complete their tasks quickly
B.Processes wait indefinitely for CPU time
C.All processes have equal access to CPU
D.Processes are prioritized randomly

34. Fill in the blank: In _____ Scheduling, processes are assigned higher priority based on their recent CPU usage.

A.Multilevel Feedback Queue
B.Round Robin
C.First-Come, First-Served
D.Shortest Job First

35. True or False: Non-Preemptive Scheduling is ideal for real-time systems.

A.True
B.False
C.Only for soft real-time systems.
D.Depends on system configuration.

36. Which of the following scenarios illustrates starvation in preemptive scheduling?

A.A low-priority process is continuously preempted by high-priority processes
B.All processes run to completion without interruption
C.A process waits for a resource for an extended time
D.A high-priority process completes faster than expected

37. What does 'response time' measure in an operating system?

A.The time from submission to first response
B.The total execution time of a process
C.The total time spent waiting in the ready queue
D.The time taken to switch processes

38. What is the goal of Fair Share Scheduling?

A.To ensure equitable CPU time allocation among users.
B.To prioritize system processes over user processes.
C.To maximize throughput for high-priority tasks.
D.To minimize context switching.

39. Which of the following is NOT a characteristic of Non-Preemptive Scheduling?

A.Processes run to completion without interruptions.
B.It allows immediate context switching between processes.
C.It can lead to process starvation.
D.It is simpler to implement compared to preemptive algorithms.

40. In preemptive scheduling, what role does process priority play?

A.Higher priority processes can interrupt lower priority processes
B.All processes are treated equally regardless of priority
C.Lower priority processes run first
D.Priority does not affect scheduling

41. Which of the following statements about preemptive scheduling is true?

A.It allows a process to continue running until completion
B.It can interrupt a currently running process
C.It guarantees lower waiting times for all processes
D.It does not require context switching

42. Cause → Effect: Continuous arrival of high-priority processes results in?

A.Starvation of lower-priority processes.
B.Faster execution of all processes.
C.Increased context switching.
D.Equal priority for all processes.

43. What is a potential consequence of using Non-Preemptive Scheduling in a mixed workload?

A.All processes will execute quickly.
B.Interactive processes may suffer from delays.
C.It maximizes the CPU usage at all times.
D.It guarantees that all priorities are respected.

44. How does a process typically enter the ready queue?

A.When it is created or becomes runnable
B.Only when it is the highest priority
C.When it is finished executing
D.When it waits for I/O operations

45. What is the relationship between burst time and waiting time?

A.Higher burst time leads to less waiting time
B.They are directly correlated
C.Higher burst time can increase waiting time
D.They are independent of each other

46. What is the key concept behind Weighted Fair Queuing?

A.Processes share bandwidth based on assigned weights.
B.All processes receive equal bandwidth.
C.Weight is determined by process ID.
D.Bandwidth is shared randomly.

47. What type of environment benefits most from Non-Preemptive Scheduling?

A.An environment with many short, interactive tasks.
B.A batch processing system with long-running jobs.
C.A system emphasizing quick response times.
D.A highly dynamic web server environment.

48. What does context switching involve?

A.Saving and loading process states
B.Allocating CPU time to the longest process
C.Running processes in a single queue
D.Eliminating the need for scheduling algorithms

49. In CPU scheduling, what does a ready queue represent?

A.A list of processes that are currently executing
B.A queue of processes waiting for I/O operations
C.A data structure holding processes ready for CPU allocation
D.A collection of completed processes

50. True or False: Earliest Deadline First (EDF) scheduling is optimal for periodic task execution.

A.True
B.False
C.Only for sporadic tasks
D.Depends on task characteristics

51. What is the overall CPU utilization like in Non-Preemptive Scheduling?

A.Always maximized.
B.Lower during long processes.
C.Consistently high regardless of input.
D.Always high in interactive scenarios.

52. True or False: Preemptive scheduling guarantees improved performance.

A.True
B.False
C.Only for high-priority processes
D.Only in batch systems

53. True or False: All CPU scheduling algorithms are designed to optimize the same performance metric.

A.True
B.False
C.Only in real-time systems
D.Only in batch processing systems

54. What is a key benefit of using Hybrid Scheduling?

A.It combines strengths of multiple algorithms for better performance.
B.It creates a single queue for all processes.
C.It limits the number of processes in the system.
D.It only uses the fastest scheduling method.

55. How does Non-Preemptive Scheduling affect system predictability?

A.It makes system behavior unpredictable.
B.It enhances predictability due to fixed execution order.
C.It eliminates all wait times.
D.It depends on the number of processes.

56. What is a primary advantage of preemptive scheduling?

A.Allows high-priority processes to execute promptly
B.Runs all processes at the same time
C.Reduces the need for context switching
D.Eliminates the risk of starvation

57. Which of the following factors does NOT influence CPU scheduling?

A.Process priority
B.Process burst time
C.User's geographic location
D.I/O operations

58. In the context of Shortest Job First, how do you calculate average wait time?

A.By summing individual wait times and dividing by the number of processes.
B.By taking the longest wait time of all processes.
C.By averaging the CPU burst times of all processes.
D.By considering only the shortest task.

59. Which of the following scenarios best illustrates the issue of starvation in Non-Preemptive Scheduling?

A.A high-priority process is executed frequently.
B.All processes are given equal time slices.
C.A low-priority process is indefinitely delayed.
D.Processes are prioritized based on arrival time.

60. Which of the following is NOT a preemptive scheduling algorithm?

A.Round Robin
B.Shortest Remaining Time First
C.First-Come, First-Served
D.Multilevel Queue Scheduling

61. What is the main difference between preemptive and non-preemptive scheduling?

A.Preemptive can interrupt processes, while non-preemptive cannot.
B.Non-preemptive allows processes to share CPU time equally, while preemptive does not.
C.Preemptive scheduling is used only in real-time systems, while non-preemptive is not.
D.Non-preemptive scheduling allows for context switching, while preemptive does not.

62. What is the main aim of the Completely Fair Scheduler (CFS)?

A.To allocate CPU time fairly among all processes.
B.To prioritize real-time processes exclusively.
C.To minimize the CPU time for low-priority tasks.
D.To maximize throughput for all tasks.

63. Which of the following statements best describes a disadvantage of Non-Preemptive Scheduling?

A.It can lead to longer wait times for lower priority processes.
B.It guarantees that all processes will complete in a timely manner.
C.It allows processes to be interrupted at any time.
D.It ensures maximum CPU utilization at all times.

64. What occurs when a higher-priority process arrives in a preemptive scheduling system?

A.The currently running process is interrupted and the higher-priority process is given CPU time.
B.The currently running process continues until it finishes its execution.
C.The system automatically increases the priority of the running process.
D.The CPU ignores the new process and keeps running the current one.

Related Study Sets

Create Your Own Study Set

Upload a PDF, paste your notes, or describe a topic – AI generates flashcards, quizzes and more in seconds.