Operating System QB
Operating System QB
Ans:-Operating System is an interface between the user and the hardware and enables the
interaction of a computer’s hardware and software.
Also, an operating system is a software which performs all the basic tasks like file
management, memory management, storage management, process management, handling
input and output, and controlling peripheral devices such as disk drives and printers.
Functions:-
1. DEVICE MANAGEMENT –
Operating System manages device communication via their respective drivers.
2. FILE MANAGEMENT –
The operating system allocates and de-allocates resources. It regulates which process gets
the file and for what duration. Also, it keeps track of information, location, uses, status etc.
3. MEMORY MANAGEMENT –
Memory management refers to the management of primary or main memory. Main memory
provides fast storage which can be accessed directly by CPU.
4. PROCESS MANAGEMENT –
Every program running on a computer is a process whether it is in the background or in
frontend. The operating system is responsible for making multiple tasks to run at the same
time (multitasking).
5. MASTERMIND –
Mastermind is one term we can rightfully use for Operating system. Reason – Operating
system performs a multitude of functions which only can be performed by super-intelligent
mind hence the term “Mastermind”.
6. STORAGE MANAGEMENT –
Operating System controls all Storage Operations. Some of these include – how to store
data or files into the computers and how users will access the files. The operating system is
Responsible for Storing and Accessing the Files. Creation of Files, Creation of Directories
and Reading and Writing the data of Files and Directories and also Copy the contents of the
Files and the Directories from One Place to Another Place.
b)What is Dispatcher in OS
Ans:-A dispatcher is a special program that comes into play after the scheduler. When the
short term scheduler selects from the ready queue, the Dispatcher performs the task of
allocating the selected process to the CPU. A running process goes to the waiting state for
IO operation etc., and then the CPU is allocated to some other process. This switching of
CPU from one process to the other is called context switching.
Ans:-An Operating System provides services to both the users and to the programs.
● Program execution
● I/O operations
● File System manipulation
● Communication
● Error Detection
● Resource Allocation
● Protection
Program execution
Operating systems handle many kinds of activities from user programs to system programs
like printer spooler, name servers, file server, etc. Each of these activities is encapsulated as
a process.
A process includes the complete execution context (code to execute, data to manipulate, registers, OS
resources in use). Following are the major activities of an operating system with respect to program
management −
I/O Operation
An I/O subsystem comprises of I/O devices and their corresponding driver software. Drivers
hide the peculiarities of specific hardware devices from the users.
An Operating System manages the communication between user and device drivers.
● I/O operation means read or write operation with any file or any specific I/O device.
● Operating system provides the access to the required I/O device when required.
A file system is normally organized into directories for easy navigation and usage. These directories
may contain files and other directions. Following are the major activities of an operating system with
respect to file management −
Communication
In case of distributed systems which are a collection of processors that do not share
memory, peripheral devices, or a clock, the operating system manages communications
between all the processes. Multiple processes communicate with one another through
communication lines in the network.
The OS handles routing and connection strategies, and the problems of contention and security.
Following are the major activities of an operating system with respect to communication −
Error handling
Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in the memory
hardware. Following are the major activities of an operating system with respect to error handling −
Resource Management
In case of multi-user or multi-tasking environment, resources such as main memory, CPU cycles and
files storage are to be allocated to each user or job. Following are the major activities of an operating
system with respect to resource management −
Protection
Considering a computer system having multiple users and concurrent execution of multiple
processes, the various processes must be protected from each other's activities.
Protection refers to a mechanism or a way to control the access of programs, processes, or users to the
resources defined by a computer system. Following are the major activities of an operating system
with respect to protection −
ans:-This type of operating system does not interact with the computer directly. There is an
operator which takes similar jobs having the same requirement and group them into batches.
It is the responsibility of the operator to sort jobs with similar needs.
e)What is buffering?
Ans:-The buffer is an area in the main memory used to store or hold the data temporarily. In
other words, buffer temporarily stores data transmitted from one place to another, either
between two devices or an application. The act of storing data temporarily in the buffer is
called buffering.
f)what is the role of process scheduler? explain different types of scheduling queue?
Ans:-Process Scheduling handles the selection of a process for the processor on the basis
of a scheduling algorithm and also the removal of a process from the processor. It is an
important part of multiprogramming operating system.
There are many scheduling queues that are used in process scheduling. When the
processes enter the system, they are put into the job queue. The processes that are ready to
execute in the main memory are kept in the ready queue. The processes that are waiting for
the I/O device are kept in the I/O device queue.
The different schedulers that are used for process scheduling are −
The long-term scheduler controls the degree of multiprogramming. It must select a careful
mixture of I/O bound and CPU bound processes to yield optimum system throughput. If it
selects too many CPU bound processes then the I/O devices are idle and if it selects too
many I/O bound processes then the processor has nothing to do.
The job of the long-term scheduler is very important and directly affects the system for a long
time.
The short-term scheduler executes much more frequently than the long-term scheduler as a
process may execute only for a few milliseconds.
The choices of the short term scheduler are very important. If it selects a process with a long
burst time, then all the processes after that will have to wait for a long time in the ready
queue. This is known as starvation and it may happen if a wrong decision is made by the
short-term scheduler.
Ans:-shows the state transition diagram for the process states defined above:
Logically, the first two state are similar. In both case the process is willing to run, but in the
ready state there is no CPU temporarily available for it.
● A process in the running state has all of the resources that it needs for further
execution, including a processor.
● The long term scheduler picks up a new process from second memory and loads it
into the main memory when there are sufficient resources available.
● The process is now in ready state, waiting for its execution.
● Process waiting for some event such as completion of I/O operation, synchronization
signal, etc.
● A process moves from waiting state to ready state if the event the
process has been waiting for, occurs.
● The process is now ready for execution.
● The process is in secondary memory but not yet ready for execution.
● The process moves from Blocked to Ready state if the event, the process has been
waiting for occurs.
Ans:-
1. CPU utilisation: The main objective of any CPU scheduling algorithm is to keep the
CPU as busy as possible. Theoretically, CPU utilisation can range from 0 to 100 but
in a real-time system, it varies from 40 to 90 percent depending on the load upon the
system.
2. Throughput:A measure of the work done by the CPU is the number of processes
being executed and completed per unit of time. This is called throughput. The
throughput may vary depending upon the length or duration of the processes.
3. Turnaround time: For a particular process, an important criterion is how long it takes
to execute that process. The time elapsed from the time of submission of a process
to the time of completion is known as the turnaround time. Turn-around time is the
sum of times spent waiting to get into memory, waiting in the ready queue, executing
in CPU, and waiting for I/O. The formula to calculate Turn Around Time =
Compilation Time – Arrival Time.
4. Waiting time: A scheduling algorithm does not affect the time required to complete
the process once it starts execution. It only affects the waiting time of a process i.e.
time spent by a process waiting in the ready queue. The formula for calculating
Waiting Time = Turnaround Time – Burst Time.
5. Response time: In an interactive system, turn-around time is not the best criteria. A
process may produce some output fairly early and continue computing new results
while previous results are being output to the user. Thus another criteria is the time
taken from submission of the process of request until the first response is produced.
This measure is called response time. The formula to calculate Response Time =
CPU Allocation Time(when the CPU was allocated for the first) – Arrival Time
6. Completion time: This is the time when the process completes its execution.
k)Explain Layered Operating System in brief with diagram?
Ans:- Architecture of Layered Structure
This type of operating system was created as an improvement over the early monolithic
systems. The operating system is split into various layers in the layered operating system,
and each of the layers has different functionalities. There are some rules in the
implementation of the layers as follows.
● A particular layer can access all the layers present below it, but it cannot access
them. That is, layer n-1 can access all the layers from n-2 to 0, but it cannot access
the nth
● Layer 0 deals with allocating the processes, switching between processes when
interruptions occur or the timer expires. It also deals with the basic multiprogramming
of the CPU.
Thus if the user layer wants to interact with the hardware layer, the response will be traveled
through all the layers from n-1 to 1. Each layer must be designed and implemented such that
it will need only the services provided by the layers below it.
There are six layers in the layered operating system. A diagram demonstrating these layers
is as follows:
1. Hardware: This layer interacts with the system hardware and coordinates with all the
peripheral devices used, such as a printer, mouse, keyboard, scanner, etc. These
types of hardware devices are managed in the hardware layer.
The hardware layer is the lowest and most authoritative layer in the layered
operating system architecture. It is attached directly to the core of the system.
2. CPU Scheduling: This layer deals with scheduling the processes for the CPU. Many
scheduling queues are used to handle processes. When the processes enter the
system, they are put into the job queue.
The processes that are ready to execute in the main memory are kept in the ready
queue. This layer is responsible for managing how many processes will be allocated
to the CPU and how many will stay out of the CPU.
3. Memory Management: Memory management deals with memory and moving
processes from disk to primary memory for execution and back again. This is
handled by the third layer of the operating system. All memory management is
associated with this layer. There are various types of memories in the computer like
RAM, ROM.
If you consider RAM, then it is concerned with swapping in and swapping out of
memory. When our computer runs, some processes move to the main memory
(RAM) for execution, and when programs, such as calculator, exit, it is removed from
the main memory.
4. Process Management: This layer is responsible for managing the processes, i.e.,
assigning the processor to a process and deciding how many processes will stay in
the waiting schedule. The priority of the processes is also managed in this layer. The
different algorithms used for process scheduling are FCFS (first come, first served),
SJF (shortest job first), priority scheduling, round-robin scheduling, etc.
5. I/O Buffer: I/O devices are very important in computer systems. They provide users
with the means of interacting with the system. This layer handles the buffers for the
I/O devices and makes sure that they work correctly.
Suppose you are typing from the keyboard. There is a keyboard buffer attached with
the keyboard, which stores data for a temporary time. Similarly, all input/output
devices have some buffer attached to them. This is because the input/output devices
have slow processing or storing speed. The computer uses buffers to maintain the
good timing speed of the processor and input/output devices.
6. User Programs: This is the highest layer in the layered operating system. This layer
deals with the many user programs and applications that run in an operating system,
such as word processors, games, browsers, etc. You can also call this an application
layer because it is concerned with application programs.
It is very important for process management as the data structuring for processes is done in
terms of the PCB. It also defines the current state of the operating system.
Process State
This specifies the process state i.e. new, ready, running, waiting or terminated.
Process Number
This shows the number of the particular process.
Program Counter
This contains the address of the next instruction that needs to be executed in the process.
Registers
This specifies the registers that are used by the process. They may include accumulators,
index registers, stack pointers, general purpose registers etc.
Accounting information
The time limits, account numbers, amount of CPU used, process numbers etc. are all a part
of the PCB accounting information.