OS - scheduling Flashcards

1
Q

what does the scheduler determine?

A
    1. Who will run*
    1. When it will run*
    1. For how long*
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Regarding scheduling; what does “fairness” refer to?

A

Comparable processes should get comparable service.

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

Regarding scheduling; what does “efficiency” refer to?

A

keep CPU and I/O device busy

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

Regarding scheduling; what does “response time” refer to?

A

Response time is the total amount of time it takes to respond to a request for service. That service can be anything from a memory fetch, to a disk IO, to a complex database query, or loading a full web page. Ignoring transmission time for a moment, the response time is the sum of the service time and wait time.

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

Regarding scheduling; what does “turnaround time” refer to?

A

Average time required for a job to complete, from submission time to completion.

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

Regarding scheduling; what does “waiting time” refer to?

A

minimize the average time in ready queue over processes

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

Regarding scheduling; what does “Throughput” refer to?

A

number of completed jobs per time unit.

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

Why is there a conflict between response time and turnaround time?

A

The process’ state changes to “running”, for the first time, quite fast. it takes a lot of time for it to finish its job though.

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

Why is there a conflict between Fairness and Throughput?

A
  • process 1: size x*
  • process 2: size x*
  • process 3: size 200x*
  • according to fairness - process 3 should get 100 times more CPU time than process 1 and 2. According to Throughput: we can have process 1 and 2 completed much faster if we gave them more CPU.*
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an “interactive computing”

A

This term refers to software which accepts input from the users as it runs. Non-interactive programs, by comparison, operate without user intervention; compilers and batch processing applications that are pre-programmed to run independently

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

What is a script?

A

A programming language for a special run-time environment(terminal) that automates the execution of tasks. the tasks could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted(rather than compiled)

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

What is a batch file?

A

A script file which consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file.

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

Provide an example of CPU utilization vs turnaround time conflict

A
  • 5 interactive jobs: 10% CPU, 20% Disk, 70% terminal; total time for each job 10 sec.
  • Batch job b: 90% CPU, 10% disk. total time 50 sec.

Option A:

  • Choose batch job and one of the interactive jobs to work in parallel:
  • CPU 100% utilized and Disk 30% utillized.

Option B:

  • Choose 5 interactive jobs to work in parallel:
  • Disk 100% utilized and CPU just 50% utilized but more jobs finish their work in less time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  • 5 jobs i1…i5,* each takes: 10% CPU 20% Disk, and 10 sec to complete.
  • One job b takes 90% CPU 10% Disk and 50 sec to complete.*
  • case 1: running i1..i5 in parallel and then b.
  • case 2: running b and each of i’s(in turn) in parallel.

What is the CPU utilization and Turnaround time for case 1 and 2?

A

Case 1:

  • UT=(10*0.5+50*0.9)/60
  • TA=(10*5+60*1)/6

Case 2:

  • UT=(50*(0.9+0.1))/50
  • TA=(10+20+30+40+50+50)/6
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what’s the difference between preemptive SJF(Shortest job First) and non-preemptive SJF?

A

if all processes arrive at the same time both behave the same. if not, Non-preemptive chooses the shortest job within the existing process and it doesn’t change its decision even if a shorter job process has arrived. in contrast, preemptive SJF will switch jobs if a shorter jobs has arrived.

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

What is the Round Robin method?

A

Each process gets a small unit of CPU time(time -quantum), usually 10-100 milliseconds.

17
Q

how much is a millisecond?

A

1/1000 second

18
Q

why does Round-Robin approaches FCFS(First-come-first-served) as the time quantum grows?

A

because if the time quantum is quite big, the process would finish their jobs before they are ask to(due to termination, I/O, or voluntarily).

19
Q

If the time quantum is about the time it takes for switching then …?

A

we’ll have relatively a large waste of CPU time(50%) but a good response time

20
Q

If time quantum is much longer than the time it takes for switching then …?

A

we’ll have long response(waiting) time but better CPU utilization

21
Q

Assume context switch takes 5 ms. compute the time wasted on switching for 100 ms quantum time?

A

overall time: context switch + quantum time = 5 + 100. switch/overall = 5/105 = 1/21 -> less than 5% which is a quite good ratio

22
Q

what is the guaranteed scheduling?

A

Scheduling that guarantees fairness by monitoring the amount of CPU time spent by each user and allocating resources accordingly.

23
Q

What is the main drawback of priority scheduling? how can we avoid that?

A

starvation. Can be avoided by changing priorities dynamically: increase priorities of waiting processes at each clock tick.

24
Q
    1. What is I/O bound process?*
    1. What is CPU bound process?*
A

A process who’s completion time is determined principally by:

  1. The period spent waiting for I/O
  2. The speed of the CPU
25
Q

How can we increase the priorities of I/O bound?

A

we can set priority to be 1/f where f is the fraction of time-quantum used. for instance; if q = 100 ms, and the process used only 25 ms then f = 1/4 and it’ll have priority 4.

26
Q

What is a Two-Level Scheduling?

A

It has to do with swapped out processes: One low-level CPU scheduler for in-memory processes and another High-level scheduler which is responsible for swapping,

27
Q

What is the critera for which the swapping scheduler swaps?

A
    1. Elapsed time since process swapped in/out*
    1. CPU time allocated to process*
    1. process memory size*
    1. process priority*
28
Q

What is Unix?

A
  • A family of multi-tasking, multi-user OS.*
  • first written in assembly and then in C.*
29
Q

what is xv6?

A

modern reimplementation of the Sixth Edition Unix in ANSI C for multiprocessor x86 systems.

30
Q

How is scheduling performed in Unix

A
  • Two-Level Scheduling:*
    1. Low level(CPU) scheduler uses multiple queue for each priority: processes in the kernel have negative priorities and user mode processes have positive priorities(lower is higher). Blocked processes are removed from queue but when the event occurs they’re back to top priority. *Each queue is Robin-Round handled.*
    1. High level(memory) scheduler moves processes from memory to disk and back, to ensure that all processes recieve their share of CPU time*
31
Q

Think of examples to processes in the kernel…

A
  • By priority, recall - lower is higher:*
  • -5: waiting for a disk*
  • -4: waiting for disk buffer*
  • -3: waiting for terminal input*
  • -2: waiting for terminal output*
  • -1: waiting for child to exit*
32
Q

How red-black tree, per-CPU data structure, helps maintain CFS(completely Fair Scheduler)?

A

Red-Black Tree is a tree where left children of node correspond to threads with less vruntime(CPU time) and right children to more vruntime. Leaves don’t play any role. Periodically, increment running thread’s vruntime, and compare to current leftmost node, if it is still minimal - continue running it, if not - insert to the tree and run minimal vruntime thread.

33
Q

How CFS (completely Fair Scheduler) time slice work?

A

It varies according to target latency parameter and number of ready threads. If too many ready threads decrease time slice such that it may cause constant context switch, then time-slice is fixed to minimum(1 ms) and target latency is increased accordingly. In addition, CFS changes rate at which a running thread’s virtual time passes according to priority.