Operating System Flashcards

1
Q

What is an operating system? What is software? types of software, explain it? What type is OS?

A

OS is an interface between hardware and software.
Software is tested programs + documentation.
User - > Application software -> System software -> hardware.
OS is system software.

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

What are the functions of OS? Explain them. The goal of OS?

A
  1. Resource management
    a. CPU: process management (scheduling)
    b. Memory management (RAM).
    c. Storage Management (Hard Disk): File System.
    d I/O devices.
  2. Security and protection.

Goal: Efficiency and Convenience.

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

Types of Interfaces?

A

GUI : Graphical: System call.

CUI: Character: System command.

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

Types of OS and explain them

A
  1. Batch process: Non interactive systme, operator needed.
    during loading unloading I/O CPU is idle.
  2. Multi programming OS. [non premptive]
  3. Multitasking OS or timesharing or Multi prog w round robin or fair share.
    based on time quantum. Each task gets an equal opportunity.
  4. Multiprocessing OS. [ more than one 1 CPU]
  5. Real time. [ soft or hard]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Response time of a job:

A

It is the length of time from the release time of a job to the instant when it finishes.

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

Absolute and relative deadline?

A

The maximum allowable response time of a job is called its relative deadline.
The absolute deadline of a job is equal to its relative deadline plus its release time.

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

Active and passive resources?

Identical and heterogeneous resources?

A

Processors are also known as active resources. They are essential for the execution of a job. A job must have one or more processors in order to execute and proceed towards completion. Example: computer, transmission links.
Resources are also known as passive resources. A job may or may not require a resource during its execution. Example: memory, mutex
Two resources are identical if they can be used interchangeably else they are heterogeneous.

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

Reference model of the real-time system:

A

Our reference model is characterized by three elements:

A workload model: It specifies the application supported by the system.
A resource model: It specifies the resources available to the application.
Algorithms: It specifies how the application system will use resources.

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

Types of tasks in a Real-Time System?

A

The system is subjected to real-time, i.e. response should be guaranteed within a specified timing constraint or system should meet the specified deadline.
1. Periodic tasks.
Denoted by 4 tuple: Ti = < Φi, Pi, ei, Di > These tasks repeat itself after fixed time interval.

Φi – (phase). Phase is the release time of the first job in the task. Default: zero.
Pi – (Period) The time interval between the release times of two consecutive jobs.
ei – Execution time of the task.
Di – Relative deadline of the task.

  1. Dynamic tasks:

It is a sequential program that is invoked by the occurrence of an event. These are classified further.

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

Hyper Period of a set of periodic tasks?

A

LCM of periods of all the tasks in that set. For example, two tasks T1 and T2 having period 4 and 5 respectively will have a hyper period, H = lcm(p1, p2) = lcm(4, 5) = 20.

The hyper period is the time after which pattern of job release times starts to repeat.

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

Dynamic Tasks?

Hint: Classification

A

In both, jobs are released at arbitrary time intervals, i.e randomly.

Aperiodic:
Soft deadline or no deadlines.

Sporadic: Hard deadline.
A sporadic task is denoted by three tuples: Ti =(ei, gi, Di)
Where
ei – the execution time of the task.
gi – the minimum separation between the occurrence of two consecutive instances of the task.
Di – the relative deadline of the task.

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

Jitter:

A

Sometimes actual release time of a job is not known. Only know that ri is in a range [ ri-, ri+ ]. This range is known as release time jitter. Here ri– is how early a job can be released and ri+ is how late a job can be released. Only the range [ ei-, ei+ ] of the execution time of a job is known. Here ei– is the minimum amount of time required by a job to complete its execution and ei+ is the maximum amount of time required by a job to complete its execution.

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

Antisymmetric relation: (Discrete Math)

A

If aRb and bRa then a=b.

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

PoSET:

Hint: it consists of? formalizes what? represented how?

A

Reflexive, Transitive, Antisymmetric. Defines notion of comparison.
It consists of a set with a binary relation indicating that for certain elements, one preceds the another in ordering.
Represented using Hasse diagrams.

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

Precedence Constraint of Jobs:

How to represent these constraints?

A

Precedence constraints are there when jobs are to be executed in a specific order.
Represented using partially order relation. A job Ji is a predecessor of job Jj if Ji < Jj i.e. Jj cannot begin its execution until Ji completes.
An efficient way to represent precedence constraints is by using a directed graph G = (J,

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

Multithreading:

A

Thread is a basic unit of CPU utilization.
Multithreading is an execution model that allows a single process to have multiple code segments (i.e., threads) running concurrently within the “context” of that process.
e.g. VLC media player, where one thread is used for opening the VLC media player, one thread for playing a particular song and another thread for adding new songs to the playlist.

Another advantage of multi-threading is that it is less costly. Creating brand new processes and allocating resources is a time-consuming task, but since threads share resources of the parent process, creating threads and switching between them is comparatively easy.

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

types of RAM:

8

A
DRAM: Dynamic. TIny capacitors, who lose energy so need refreshing.
Inexpensive.
Slower.
Used for Main Memory.
Can store any bits per chip.
SRAM: Static. D flip flop.
Expensive, faster.
Used for the cache.
Consumes more power and heats up also.
Can't store many bits per chip.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Types of ROM:

A

PROM: programable Read-only memory. Once the user programs it, data can’t be changed again.
EPROM: erasable PROM. UV light can erase data.
EEPROM: Electrically EPROM. exposing to an electric field can erase parts of a chip.

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

Difference between 32-bit and 64-bit operating systems:

A

In computing, there are two types of processors existing, i.e., 32-bit and 64-bit processors. These types of processors tell us how much memory a processor can access from a CPU register.
A 32-bit system can access 2^32 different memory addresses, i.e 4 GB of RAM or physical memory ideally, it can access more than 4 GB of RAM also.
A 64-bit system can access 2^64 different memory addresses, i.e actually 18-Quintillion bytes of RAM. In short, any amount of memory greater than 4 GB can be easily handled by it.

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

What is a process? process Vs program?

A

A process is a program in execution. The process is an active entity and the program is a passive entity.

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

What does a process look like in memory? States of the process?

A

Stack: Contains temp data.

Heap: for dynamic allocation
Data Segment: Contains global variables
Text Segment: Contains executable instructions.

21
Q

Process Control Block:

A
Context of process.
A process control block (PCB) contains information about the process, i.e. registers, quantum, priority, etc.
It has various attributes like:
1. Process ID.
2. CPU register
3. I/O status info.
4. Process state.
5. Scheduling info.
6. Accounts info.

Each block of memory contains information about the process state, program counter, stack pointer, status of opened files, scheduling algorithms, etc

22
Q

Context switching:

A

The process of saving the context of one process and loading the context of another process is known as Context Switching. In simple terms, it is like loading and unloading the process from the running state to the ready state.

23
Q

Mode switch?

A

A mode switch occurs when the CPU privilege level is changed, for example when a system call is made or a fault occurs. The kernel works in more a privileged mode than a standard user task. If a user process wants to access things that are only accessible to the kernel, a mode switch must occur. The currently executing process need not be changed during a mode switch.
A mode switch typically occurs for a process context switch to occur. Only the kernel can cause a context switch.

24
Q

CPU-Bound vs I/O-Bound Processes:

A

A CPU-bound process requires more CPU time or spends more time in the running state.
An I/O-bound process requires more I/O time and less CPU time. An I/O-bound process spends more time in the waiting state.

25
Q
  1. The time taken to switch between user and kernel modes of execution is t1 while the time taken to switch between two processes is t2. Which of the following is TRUE? (GATE-CS-2011)
    (A) t1 > t2
    (B) t1 = t2
    (C) t1 < t2
    (D) nothing can be said about the relation between t1 and t2.
A

C. Process switching involves a mode switch. Context switching can occur only in kernel mode.

26
Q
1. Which of the following need not necessarily be saved on a context switch between processes? (GATE-CS-2000) 
(A) General purpose registers 
(B) Translation lookaside buffer 
(C) Program counter 
(D) All of the above
A

In a process context switch, the state of the first process must be saved somehow, so that when the scheduler gets back to the execution of the first process, it can restore this state and continue. The state of the process includes all the registers that the process may be using, especially the program counter, plus any other operating system-specific data that may be necessary. A translation look-aside buffer (TLB) is a CPU cache that memory management hardware uses to improve virtual address translation speed. A TLB has a fixed number of slots that contain page table entries, which map virtual addresses to physical addresses. On a context switch, some TLB entries can become invalid, since the virtual-to-physical mapping is different. The simplest strategy to deal with this is to completely flush the TLB.

27
Q

Prcoess Table:

A

The process table is an array of PCB’s, which means logically contains a PCB for all of the current processes in the system.

28
Q

Types of process schedulers:

hint: ideal LTS?

A
  1. Long term scheduler: New to ready. It controls the Degree of Multi-programming, i.e., the number of processes present in the ready state at any point in time. It is important that the long-term scheduler make a careful selection of both IO and CPU bound processes. The job scheduler increases efficiency by maintaining a balance between the two.
  2. Short term or CPU scheduler: Ready to run. It just selects the process. The CPU scheduler is responsible for ensuring there is no starvation owing to high burst time processes.
  3. Medium-term scheduler: Suspend and resume.
    does swapping from disk to main memory. It reduces the degree of multiprogramming(how?).
29
Q

Dispatcher?

A

A dispatcher is responsible for loading the process selected by the Short-term scheduler on the CPU (Ready to Running State) Context switching is done by the dispatcher only. A dispatcher does the following:
Switching context.
Switching to user mode.
Jumping to the proper location in the newly loaded program.

30
Q

Preemptive:

A

Preemptive scheduling is used when a process switches from the running state to the ready state or from the waiting state to the ready state.

31
Q

Non-preemptive:

A

Non-preemptive Scheduling is used when a process terminates, or a process switches from running to the waiting state. In this scheduling, once the resources (CPU cycles) are allocated to a process, the process holds the CPU till it gets terminated or reaches a waiting state. In the case of non-preemptive scheduling does not interrupt a process running CPU in the middle of the execution. Instead, it waits till the process completes its CPU burst time, and then it can allocate the CPU to another process.

32
Q

Response ratio?

A

Response ratio = (waiting time + burst time)/Burst time.

33
Q

Measure time spent between context switch?

A

In order to solve this problem, we would like to record the timestamps of the first and last instructions of the swapping processes. The context switch time is the difference between the two processes.

The key is that the delivery of a data token induces a context switch. Let Td and Tr be the time it takes to deliver and receive a data token, respectively, and let Tc be the amount of time spent in a context switch. In step 2, P1 records the timestamp of the delivery of the token, and in step 9, it records the timestamp of the response. The amount of time elapsed, T, between these events, may be expressed by:

T = 2 * (Td + Tc + Tr)
This formula arises because of the following events:

P1 sends the token (3)
CPU context switches (4)
P2 receives it (5)
P2 then sends the response token (6)
CPU context switches (7)
and finally, P1 receives it (8)
34
Q

What is the convoy effect?

A

Convoy Effect is a phenomenon associated with the First Come First Serve (FCFS) algorithm, in which the whole Operating System slows down due to a few slow processes.

Suppose there is one CPU intensive (large burst time) process in the ready queue, and several other processes with relatively fewer burst times but are Input/Output (I/O) bound (Need I/O operations frequently).

the I/O bound processes are made to wait as the CPU intensive process still hasn’t finished. This leads to I/O devices being idle.

When the CPU intensive process gets over, it is sent to the I/O queue so that it can access an I/O device.
Meanwhile, the I/O bound processes get their required CPU time and move back to the I/O queue.
However, they are made to wait because the CPU intensive process is still accessing an I/O device. As a result, the CPU is sitting idle now

35
Q

Belady’s Anomaly

A

Bélády’s anomaly is the name given to the phenomenon where increasing the number of page frames results in an increase in the number of page faults for a given memory access pattern.

36
Q

A solution to starvation:

A

Ageing is a technique of gradually increasing the priority of processes that wait in the system for a long time.

37
Q

HRRN:

Highest response ratio next

(disadvan?)

A
  • like SJF but without starvation.
  • it selects a process with the highest response ratio
  • Non-preemptive
  • Allows decreasing WT of long jobs.

Disadvan:
- We can’t know burst time ahead of time in reality

38
Q

Multilevel Queue CPU scheduling:

A

Here the ready queue is divided into separate queue for each class of process. Classes like system, interactive, batch processes.

Each Q has its own scheduling algorithm. like RR for first 2 and FCFS for batch.
here system priority greater than interactive and interactive’s greater than batch.

Starvation may occur if high priority Q is never empty.

39
Q

Scheduling among queues in multilevel Q CPu scheduling:

A
  1. Fixed Priority preemptive: lower priority Q’s job will run only when higher priority q are empty.
  2. Time slicing: each queue gets a certain portion of CPU time and can use it to schedule its own processes. For instance, queue 1 takes 50 percent of CPU time queue 2 takes 30 percent and queue 3 gets 20 percent of CPU time.
40
Q

Multilevel Feedback Queue Scheduling:

why chose MLFQ?

A
  • Processes are allowed to move between queues.
    if a process does not complete in a time quantum then it is shifted to the lower priority queue.
    (for the first 2, for last we were using FCFS)
    A process in a lower priority queue can only execute only when higher priority queues are empty.
    A process running in the lower priority queue is interrupted by a process arriving in the higher priority queue.
    No need of knowing the burst time in advance, if it takes longer we can adjust as mentioned.
    This optimizes the TAT and reduces the response time.
41
Q

Process synchronization?

A

On the basis of synchronization, processes are categorized as one of the following two types:

Independent Process : Execution of one process does not affects the execution of other processes.
Cooperative Process : Execution of one process affects the execution of other processes.
Process Synchronization is a technique which is used to coordinate the process that use shared Data.

42
Q

Race condition:

A

Several processes access and process the manipulations over the same data concurrently, then the outcome depends on the particular order in which the access takes place.
A race condition is a situation that may occur inside a critical section. This happens when the result of multiple thread execution in the critical section differs according to the order in which the threads execute.

43
Q

Critical Section:

A

When more than one processes access a same code segment that segment is known as critical section.

In simple terms a critical section is group of instructions/statements or region of code that need to be executed atomically

Could be done by acquiring lock, just by one thread.

44
Q

Critical Section problems must satisfy these three requirements:

A

Mutual Exclusion –
It states that no other process is allowed to execute in the critical section if a process is executing in the critical section.
Progress –
When no process is in the critical section, then any process from outside that request execution can enter the critical section without any delay. Only those processes can enter that have requested and have a finite time to enter the process.
Bounded Waiting –
An upper bound must exist on the number of times a process enters so that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.

45
Q

Inter-Process Communication

How can processes communicate with each other?

A

IPC is a mechanism that allows processes to communicate with each other and synchronize their actions.

Through:

  1. Shared memory: via a shared variable.
  2. Message passing: establish a communication link then send messages.
46
Q

When can deadlock arise?

A

If the following 4 holds: (necessary)

  1. Mutual Exclusion: 2 or more processes are non-shareable.
  2. Circular Wait: A set of processes are waiting for each other in circular form.
  3. Hold and Wait: a process is holding a resource and waiting.
  4. No Preemption.
47
Q

How to handle deadlock:

A
  1. Let the deadlock occur, which is rare, and reboot the system.
  2. Prevent deadlock from happening by negating 1 of 4 conditions. avoidance of deadlock (bankers algorithm).
  3. Let deadlock occur, do preemption. detect and recovery.
48
Q

Deadlock detection and prevention:

A

Detection: Cycle in resource allocation graph is sufficient for deadlock, in case of single instance of resources.

Recovery:

  • Killing processes which are involved in deadlock one by one.
  • Resource preemption. (starvation possible)
49
Q

What is Banker’s algorithm?

A

The banker’s algorithm is a resource allocation and deadlock avoidance algorithm that tests for safety by simulating the allocation for predetermined maximum possible amounts of all resources, then makes an “s-state” check to test for possible activities, before deciding whether allocation should be allowed to continue.