Scheduling Flashcards

1
Q

What is a scheduler?

A

A is a software that helps schedule the processes in an operating system. It helps to keep all computer resources busy and allows multiple users to share system resources effectively.

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

A process may leave the CPU for one the following reasons:

A
  1. Completes execution
  2. Requests a resource
  3. Voluntarily release CPU
  4. Involuntarily releases CPU
    (preempted)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Scheduling Policy

A

decides when thread leaves and
which thread is selected to replace it

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

Scheduling Mechanism

A

determines how the process
manager carries out its duties

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

Scheduling Mechanism has 3 parts

A
  1. Enqueuer
  2. Dispatcher
  3. Context switcher
  4. Enqueuer
    Places a pointer to thread descriptor into ready list (priority placement may happen then or later when thread is selected)
  5. Dispatcher Selects one ready thread and allocates CPU to that thread by performing context switch
  6. Context switcher Saves the contents of all CPU registers (PC, IR, condition status) for the thread being moved out and places the new thread in.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does a CPU scheduler do

A

Selects from among the processes in ready queue, and allocates a CPU core to one of them

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

CPU scheduling decisions may take place when a process:

A
  1. Switches from running to waiting state
  2. Switches from running to ready state
  3. Switches from waiting to ready
  4. Terminates

For situations 1 and 4, there is no choice in terms of scheduling. A new process (if one exists in the ready queue) must be selected for execution.

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

The dispatcher

A

Responsible for the context switch of the current task to a new task.

  • This involves:
  • Switching context
  • Switching to user mode
  • Jumping to the proper location in the user program to restart that program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Dispatch latenc

A

Time it takes for the dispatcher to stop one process and start another running

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

Preemptive and Nonpreemptive Scheduling

A

Ponpreemptive no choice (1 and 4)
Preemptive have a choice (2 and 3)

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

Register Overhead:

A

Each register must be saved and restored during a context switch to ensure that a process can resume execution exactly where it left off. This involves reading the current register values and storing them in a safe location (usually in the process’s control block in memory), then loading the next process’s saved register values back into the registers.

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

Context Switch Phases:

A
  1. Save process 1’s context
  2. Load dispatcher’s context
  3. Save dispatcher’s context
  4. Load process 2’s context
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Switching Cost

A
  • 50 nanoseconds to store 1 unit of data
  • 32 bit bus / 50 nanoseconds for each register
  • 32 general registers and 8 status registers
     40 x 50 nanaseconds = 2 microseconds
  • 2 microseconds more to load another thread
  • Total time: over 4 microseconds (including dispatch in and out)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Preemptive Scheduling and Race Conditions

A
  • Preemptive scheduling can result in race conditions when data are shared among several processes.
  • Consider the case of two processes that share data. While one process is updating the data, it is preempted so that the second process can run. The second process then tries to read the data, which are in an inconsistent state.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Scheduling Algorithm Optimization Criteria

A
  • Max CPU utilization
  • Max throughput
  • Min turnaround time
  • Min waiting time
  • Min response time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Scheduling Criteria

A

Service Time t(pi): amount of time a process needs to be in running state (allocated the CPU) before it is completed.

Wait time W(pi): total amount of time a process needed to wait in a non-running state from the moment it is ready until it is completed.

Response time R(pi): total amount of time from the moment the process is ready until it is considered for the first time by the CPU (allocated the CPU for the first time).

Turnaround time TAT(pi): the amount of time between the process first enters the ready state until the moment the process exits the running state for the last time (terminated)

17
Q

First Come First Served (FCFS) Scheduling

A

FCFS is the simplest scheduling algorithm. There is a single rule; schedule the first process to arrive, and let it run to completion.

18
Q

PCB

A

Process Control Block

19
Q

IS FCFS a Preemptive or Nonpreemptive?

A

Nonpreemptive

20
Q

Shortest Job Next (SJN)

A

Is a scheduling policy that selects for execution the waiting process with the smallest execution time

21
Q

Shortest Job Next (SJN) Preemptive or Nonpreemptive?

A

It can be both a preemptive and non-preemptive algorithm.

22
Q

Waiting Time equation

A

=Total waiting time- time process executed- Arrival time

23
Q

Priority Scheduling

A

Scheduling algorithm that schedules processes according to the priority assigned to each of the processes. Higher priority processes are executed before lower priority processes.

24
Q

What is Aging

A

Is a scheduling technique used to prevent starvation in operating systems. It involves gradually increasing the priority of processes that have been waiting for a long time.

25
Q

Round Robin (RR) Scheduling

A

Tasks are selected in a fixed sequence for execution. On each clock tick, the current task is discontinued and the next is allowed to start execution. in a circular queue fashion.

26
Q

Round Robin (RR) explained

A
  • Each process gets a small unit of CPU time (time quantum q), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue.
  • If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.

– Typically, higher average turnaround than SJF, but better response
* q should be large compared to context switch time
* q usually 10 milliseconds to 100 milliseconds,
* Context switch < 10 microseconds

27
Q

Multilevel queue scheduling

A

A type of CPU scheduling in which the processes in the ready state are divided into different groups, each group having its own scheduling needs

28
Q

Multilevel Queue Ready queue:

A

Partitioned into separate queues, eg:
* foreground (interactive)
* background (batch)

  • Each queue has its own scheduling algorithm:
  • foreground – RR
  • background – FCFS
29
Q

 Scheduling must be done between the queues:

A
  • Fixed priority scheduling; (i.e., serve all from foreground then from background). Possibility of starvation.
  • Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e., 80% to foreground in RR
  • 20% to background in FCFS
30
Q

Multilevel Feedback Queue

A
  • A process can move between the various queues
31
Q

Multilevel-feedback-queue scheduler defined by the following parameters:

A
  • Number of queues
  • Scheduling algorithms for each queue
  • Method used to determine when to upgrade a process
  • Method used to determine when to demote a process
  • Method used to determine which queue a process will enter when that process needs service
32
Q
A