OS Viva questions
OS Viva questions
Process Management
Memory Management
Device Management
File Management
Others (Security, Coordination, Accounting, etc)
Process Management
The OS decides which process gets processed when and for how
much time through process scheduling. It also helps different
processes coordinate when they are working with shared resources
and data. It also takes care of handling deadlock scenarios where one
process is waiting on the other process to release a resource and vice
versa.
Memory Management
The OS tracks the status of each memory location and decides which
process is allocated which memory locations, when, and for how long.
Device Management
The OS manages communication with devices through drivers. It
tracks the status of each device and decides which process gets to
communicate with the device, when, and for how long.
File Management
The OS allows users or programs to create, read, update or delete
files and directories. It also keeps track of all the meta details about
the files and directories through a file system.
5) What is Multiprogramming?
Multiprogramming is a technique through which a CPU can execute
multiple jobs thereby increasing CPU utilization. This is generally done
by keeping multiple jobs in the memory and then using some
scheduling algorithm to decide which job is picked when.
6) What is Multitasking?
Multitasking is an extension of multiprogramming in which more than
one job is done at the same time. This is done by switching between
tasks based on the user interaction or based on assigned time. The
switching is very fast, so we do not see any lag when switching
between different applications.
7) What is Multiprocessing?
Multiprocessing is a technique in which there are two or more CPUs
(processors) within the same computer. This allows us to run different
processes on the same computer at the same time. There are certain
components shared between the different processors like memory,
clock, etc.
8) What is a Process?
A process is an instance of a computer program that is getting
executed. A computer program is passive and contains a set of
instructions (code) stored in the file system. A process is active and
works by loading the program into memory and executing it.
Each thread shares the same code, data, and heap blocks but will
have its own stack. Threads are often called lightweight processes
because they have their own stack memory.
Complex Design
Race Conditions
Deadlocks
Starvation
Livelock
Difficulty to test and debug
Thread Context Switch
Let's say that the person simultaneously does a transaction using net
banking. The same thing would happen here. Since both of them are
happening simultaneously, the balance variable may be outdated in
one of the transactions. This will allow the user to withdraw more
money than the initial account balance.
Implementation
wait () {
flag--;
signal () {
flag++;
}
Example