Lecture 2 -Multitasking In The Operating Systems Flashcards

1
Q

What is a program?

A

A program is the code a programmer writes.

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

What is a process?

A

A process is a program in execution, i.e., a particular instance of a program together with its data

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

Where does the OS store information about each process?

A

The OS stores information about each process in a process control block (PCB) or process descriptor

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

What is Multitasking?

A

Simultaneous running of two or more processes.

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

What is created by a user via a command?

A
  • When a user initiates a program, OS creates a PCB data structureto represent the execution of this program.
  • OS also allocates resources for the process.
  • Process consists of machine code in memory and PCB.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is created by a user process, called spawning a process?

A
  • The process that creates a new process is called the parent while the created process child
  • The child can also spawn new processes, forming a tree of processes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why to run two or more processes at the same time?

A
  • For convenience of the user (it is fun to work with a text editor, play chess, and watch a video at the same time)
  • For a better CPU usage (when a program sends information to a printer, the CPU stays idle; it is good to load it with another program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the denition and role of interrupts?

A
  • Interrupts: events that cause the CPU to stop the current execution and to start execute the program handling this interrupt.
  • The program (let us call it Dispatcher) performs the operation required by the interrupt (say, sending data to a printer) and decides which process is the next to run.

.

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

What is the Dispatcher?

A

After the I/O system call or interrupt handling, control is passed to the dispatcher or Low Level Scheduler. The dispatcher works as below:

1) Is the current process still the most suitable to run? If so, return control to it; Otherwise . . .
2) Save the state of the current process in the PCB
3) Retrieve the state of the most suitable process
4) Transfer control to the newly selected process, at the point indicated by the restored program counter.
* This action of storing the state of current process and (re-)starting another process is called a context change.

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

What are the two main types of interrupts, states of processes?

A

Clock interrupt:
Initiated by a clock within CPU.
The means to stop run of the current process in order to give another one the right to run.
The process stopped by the Clock interrupt gets to the READY state

I/O interrupt:
Initiated by CPU that sees an I/O instruction in the program or by the I/O device to signal completion of the I/O operation.
When I/O operation starts the corresponding process gets to the BLOCKED.
When the I/O operation completes, the process becomes READY.

The dispatcher can select a process to run only if it is READY.

The running process is said to be in the RUNNING state

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

What is the story of interrupts?

A

A process can be in states RUNNING (currently running), READY
(ready to run) and BLOCKED (awaiting of completion of I/O).
Interrupts are used to stop the currently running process.
The clock interrupt causes the process to be READY.
The I/O interrupt causes the process to be BLOCKED, upon
completion it becomes READY
The Dispatcher chooses the next process to run from the queue of
READY processes.
The question of SCHEDULING: which process to choose?

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

What is the Scheduling policy denition and type?

A

Scheduling policy determines:
The next READY process to run.
The amount of time the process is given to occupy the CPU.
Non-preemptive scheduling:
A process releases CPU only if an I/O occurs or it nishes.
In other words, the process cannot be stopped during a regular
computation
Preemptive scheduling:
A process can be stopped at any moment.
To stop the process without I/O request a clock interrupt is used.

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

What are the 3 effciency measures of scheduling policies?

A

Turnaround time.
CPU usage.
Response time

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

What is Turnaround Time?

A

Turnaround time of a particular process is its duration, i.e. the difference between the end and the start times.
Turnaround time of a group of processes is the average of their individual turnaround times.
Example:
We have 3 processes with respective start and end times
(100;200), (150;300) and (200;400).
The individual turnaround times are 100, 150, 200.
The average turnaround time is 150

A good scheduling policy keeps average turnaround time as low as possible.

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

What is CPU Usage?

A

If all the processes are blocked waiting for completion of their I/O operations, the CPU stays idle.

A good scheduling policy minimises the idleness time.

CPU usage: given some some amount of time, the percentage of time during which the CPU is busy.

Clearly, it is good if the scheduling policy maximises the CPU usage.

17
Q

What is Response time?

A

The OS can recognise some processes as user commands (requests).
In Linux, user requests are commands like cp, cd, ls, and so on.
The response time is average turnaround time of a user
request.
The turnaround time of the rest of programs is not taken into account.
This measure must be minimised in interactive systems.

18
Q

What are the 2 types of operating systems and what do they do?

A

Batch systems:
Run a series of programs without human intervention.
Examples: scientic computing, salary calculation in big
companies.
Turnaround time and CPU usage are more important measures than Response time

Interactive systems:
Designed to extensively communicate with the user.
Examples: Linux, Windows.
Response time is more important measure than the other two.

19
Q

What is the First come first served (FCFS) policy?

A

The policy is non-preemptive.
The rst READY process in the queue is given the right to
run.
The process releases the CPU when it nishes or an I/O
interrupt occurs.
If process gets blocked by the I/O interrupt, it returns to the end of the READY queue when it is unblocked.
Suitable for batch systems only.

20
Q

What are the advantages and disadvantages of the FCFS policy?

A

Advantages:
Easy to implement.
No indenite waiting (when a process can potentially wait
forever for being run)
Disadvantage: turnaround time of short processes may be much longer than their actual completion time.

21
Q

What is the shortest job first (SJF) policy

A

The policy is non-preemptive.
Requires information about the runtime of programs (the time
the program runs non-interrupted).
From the queue of READY processes chooses the one whose runtime is smallest. The rest is properties is like for FCFS.

22
Q

What are the advantages and disadvantages of the SJF policy?

A

Advantage: favourable to program with short runtimes.
Disadvantages:
Requires knowledge about runtimes.

Indenite waiting is possible: a long-time process can wait very long if new short-time processes arrive all the time.

Does not take into account the situation when a long time
process is short before completion (i.e. eectively becomes short one)

23
Q

What is the shortest remaining time rst (SRTF) policy?

A

This is a preemptive policy.
For every process, requires knowledge of the remaining
runtime if runs non interrupted.
Very similar to SJF.
The differences are:
Chooses process with the shortest remaining time instead shortest overall time.
If a process with shorter remaining time than the currently running one arrives at the queue, the currently running process is preempted.

24
Q

What are the advantages and disadvantages of the SRTF policy.

A

Advantage: even more sensitive to the short processes that the SJF.
Disadvantages: requires non-trivial knowledge and indenite waiting is still possible.

25
Q

What is the Round-Robin scheduling policy?

A

This is a preemptive policy used in interactive systems.
Each process in turn gets the CPU for a xed time quantum (typically 10 20 ms).

When the quantum nishes: the timeout event occurs and the process is returned to the back of the queue.

If the process blocks waiting for I/O, it is interrupted as well.

26
Q

Explain what the quantum duration for round-robin is?

A

Context switch: the procedure of replacement the currently running process by another one.

If the quantum is too short, comparable in time with the
context switch, a lot of time is wasted on context switches.

If the quantum is too long then the response time may
become too long.