0% found this document useful (0 votes)
4 views20 pages

Model Paper-02

operating system model paper -2

Uploaded by

thilakkc28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views20 pages

Model Paper-02

operating system model paper -2

Uploaded by

thilakkc28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

MODEL PAPER – 02

PART-A

I. Answer any Six questions each question carries 2 marks


1. Mention the role of an operating system.
File management
Device management
Process management
Memory management
Job Accounting

2. How is computer software classified?


Computer software is typically classified into two major types of programs:
Application software are programs that direct the performance of a
particular use, or application, of computers to meet the information
processing needs of end users.
Ex:
A collection of Microsoft software including MS Office, PowerPoint, Word,
Excel, and Outlook.

Systems software are programs that manage the resources of the


computer system and simplify applications programming. They include
software such as the operating system, database management systems,
networking software, translators, and software utilities.

Ex:
macOS.
Microsoft Defender.
Linux.
Windows 11
3. What do you mean by booting?

Booting is the process of starting a computer.

It can be initiated by hardware such as a button press or by a software


command. After it is switched on, a CPU has no software in its main
memory, so some processes must load software into memory before
execution.

4. How is job scheduling different from CPU scheduling?


Job Scheduling vs CPU Scheduling
The CPU scheduling is the mechanism to
The job scheduling is the mechanism
select which process has to be executed
to select which process has to be
next and allocates the CPU to that
brought into the ready queue.
process.
Synonyms
The job scheduling is also known as The CPU scheduling is also known as
the long-term scheduling. short-term scheduling.
Processed By
The job scheduling is done by the long- The CPU scheduling is done by the short-
term scheduler or the job scheduler. term scheduler or the CPU scheduler.
Process State Transition
The process transfers from new state The process transfers from ready state to
to ready state in job scheduling. running state in CPU scheduling.

5. Define a process and a program.


Program: When we execute a program that was just compiled, the OS will
generate a process to execute the program. A program is a passive entity as
it resides in the secondary memory, such as the contents of a file stored on
disk. One program can have several processes.
Process: The term process (Job) refers to program code that has been
loaded into a computer’s memory so that it can be executed by the central
processing unit (CPU). A process can be described as an instance of a
program running on a computer or as an entity that can be assigned to and
executed on a processor.

6. What is spooling?
SPOOL is an acronym for simultaneous peripheral operations on-line. It is a
kind of buffering mechanism or a process in which data is temporarily held
to be used and executed by a device, program or the system.
Ex:
In printer, the documents/files that are sent to the printer are first stored in
the memory or the printer spooler. Once the printer is ready, it fetches the
data from the spool and prints it.

7. What is context switching?


Context Switching involves storing the context or state of a process so that
it can be reloaded when required and execution can be resumed from the
same point as earlier.
This is a feature of a multitasking operating system and allows a single CPU
to be shared by multiple processes.

8. Define a deadlock with an example.


Deadlock is a situation where a set of processes are blocked because each
process is holding a resource and waiting for another resource acquired by
some other process.
Ex:
A computer has three USB drives and three processes. Each of the three
processes able to holds one of the USB drives. So, when each process
requests another drive, the three processes will have the deadlock situation
as each process will be waiting for the USB drive to release, which is
currently in use.
9. What are file attributes? List any 4 attributes of a file.
File attributes are pieces of information associated with every file and
directory that includes additional data about the file itself or its contents.
They can exist in only one of two states – Set or Cleared; like an On or Off
state.
Attributes of the File are:
a) Name: Every file carries a name by which the file is recognized in the file
system. One directory cannot have two files with the same name

b) Identifier: Along with the name, Each File has its own extension which
identifies the type of the file. For example, a text file has the extension .txt,
A video file can have the extension .mp4.

c) Type: In a File System, the Files are classified in different types such as
video files, audio files, text files, executable files, etc.,

d) Location: In the File System, there are several locations on which, the
files can be stored. Each file carries its location as its attribute.
PART-B

II. Answer any Four questions each question carries 6 marks


10. Explain the following page replacement algorithms.
(A) FIFO.
(B) LRU.
First In First Out (FIFO): This is the simplest page replacement
algorithm. In this algorithm, the operating system keeps track of all
pages in the memory in a queue, the oldest page is in the front of the
queue. When a page needs to be replaced page in the front of the
queue is selected for removal.

Ex: Consider page reference string 1, 3, 0, 3, 5, 6, 3 with 3 page


frames. Find the number of page faults.

Initially, all slots are empty, so when 1, 3, 0 came they are allocated
to the empty slots —> 3 Page Faults.
when 3 comes, it is already in memory so —> 0 Page Faults. Then 5
comes, it is not available in memory so it replaces the oldest page
slot i.e 1. —>1 Page Fault. 6 comes, it is also not available in memory
so it replaces the oldest page slot i.e 3 —>1 Page Fault. Finally, when
3 come it is not available so it replaces 0 1 page fault.
Least Recently Used: In this algorithm, page will be replaced which is
least recently used.

Ex: Consider the page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2,


3 with 4 page frames. Find number of page faults.

Initially, all slots are empty, so when 7 0 1 2 are allocated to the


empty slots —> 4 Page faults
0 is already their so —> 0 Page fault. when 3 came it will take the
place of 7 because it is least recently used —>1 Page fault
0 is already in memory so —> 0 Page fault.
4 will takes place of 1 —> 1 Page Fault
Now for the further page reference string —> 0 Page fault because
they are already available in the memory.

10. Write a detail note on directory structures.


A directory is a container that is used to contain folders and files. It
organizes files and folders in a hierarchical manner.
There are several logical structures of a directory, these are given
below.

Single-level directory –
The single-level directory is the simplest directory structure. In it, all
files are contained in the same directory which makes it easy to support
and understand.
A single level directory has a significant limitation, however, when the
number of files increases or when the system has more than one user.
Since all the files are in the same directory, they must have a unique
name. If two users call their dataset test, then the unique name rule
violated.

Two-level directory –
As we have seen, a single level directory often leads to confusion of
files names among different users. The solution to this problem is to
create a separate directory for each user.
In the two-level directory structure, each user has their own user files
directory (UFD). The UFDs have similar structures, but each lists only
the files of a single user.

Tree-structured directory –
Once we have seen a two-level directory as a tree of height 2, the
natural generalization is to extend the directory structure to a tree of
arbitrary height.
This generalization allows the user to create their own subdirectories
and to organize their files accordingly.
12. With a common example compare FCFS algorithm with SJF algorithm and
justify which algorithm is advantageous to use.

First Come First Served (FCFS) Shortest Job First (SJF)

First Come First Served (FCFS) Shortest Job First (SJF) executes the
executes the processes in the order in processes based upon their burst
which they arrive i.e. the process that time i.e. in ascending order of their
arrives first is executed first. burst times.

SJF is also non-preemptive but its


preemptive version is also there
called Shortest Remaining Time First
FCFS is non preemptive in nature. (SRTF) algorithm.

FCFS results in quite long waiting time


for the processes and thus increases The average waiting time for given
average waiting time. set of processes is minimum.

FCFS leads to the convoy effect. It does not lead to the convoy effect.

The real difficulty with SJF is knowing


FCFS algorithm is the easiest to the length of the next CPU request or
implement in any system. burst.
First Come First Served (FCFS) Shortest Job First (SJF)

A process may have to wait for quite


long to get executed depending on the A long process may never get
burst time of the processes that have executed and the system may keep
arrived first. executing the short processes.

FCFS lead to lower device and CPU SJF leads to higher effectiveness of
utilization thereby decreasing the the system due to lower average
efficiency of the system. waiting time.

In case of SJF, elapsed time should


be recorded, results in more
FCFS results in minimal overhead. overhead on the processor.

FCFS does not suffers from starvation SJF suffers from starvation.

13. Explain in detail about deadlock detection.


Deadlock Detection :
1. If resources have a single instance –
In this case for Deadlock detection, we can run an algorithm to check for the cycle
in the Resource Allocation Graph. The presence of a cycle in the graph is a
sufficient condition for deadlock.

In the above diagram, resource 1 and resource 2 have single instances. There is a
cycle R1 → P1 → R2 → P2. So, Deadlock is Confirmed.
2. If there are multiple instances of resources –
Detection of the cycle is necessary but not sufficient condition for deadlock
detection, in this case, the system may or may not be in deadlock varies according
to different situations.
The wait-for graph can't be used for a resource allocation system containing
multiple instances of each resource type. Hence, a different algorithm is
employed which carries certain data structures. The data structures in the
algorithm are,
Available: It is an array of length m. It represents the number of available
resources of each type
Allocation: It is an n x m matrix which represents the number of resources of each
type currently allocated to each process.
Request: It is an n*m matrix that is used to indicate the request of each process:
if Request[i][j] equals to k, then process Pi is requesting k more instances of
resource type Ri
Allocation and request are taken as vectors and referred to as Allocation and
Request.
The given detection algorithm is simply used to investigate every possible
allocation sequence for the process that remain to be completed.
Step1: Let Work and Finish be vectors of length m and a, respectively. Initialize
Work Available
Finish(i) false for 1-0, 1-1.
If Allocationi is not equal to 0,then Finish[i]=false; else Finish(i)=true
Step 2: Find an index i such that both
Finish[i]==false
Request<= Work
If no such exist then go to step 4.
Step 3: Perform the following:
Work= Work+ Allocationi
Finish[i]=true
Go to step 2.
Step 4: If Finish[i]== false for some 1,0<=i<n, then it means the system is in a
deadlocked state Moreover, if Finish[i]==false, then process Pi is deadlocked
This algorithm may require an order of mxn2 operations in order to determine
whether the system is in a deadlocked state.

14. Write in detail about the system calls.


A system call is a way for programs to interact with the operating
system.
 A computer program makes a system call when it makes a
request to the operating system’s kernel.
 System call provides the services of the operating system to
the user programs via Application Program Interface (API).
 It provides an interface between a process and operating
system to allow user-level processes to request services of the
operating system.
 System calls are the only entry points into the kernel system.
All programs needing resources must use system calls.
Services Provided by System Calls :
 Process creation and management
 Main memory management
 File Access, Directory and File system management
 Device handling(I/O)
 Protection
 Networking, etc.
Types of System Calls :
 Process control: end, abort, create, terminate, allocate and
free memory.
 File management: create, open, close, delete, read file etc.
 Device management
 Information maintenance
 Communication

15. Explain the different kinds of schedulers.


Schedulers are special system software which handle process
scheduling in various ways. Their main task is to select the jobs to be
submitted into the system and to decide which process to run .
The three types of schedulers are
Long Term Scheduler:
 It is also called a job scheduler.
 A long-term scheduler determines which programs are admitted
to the system for processing.
 It selects processes from the queue and loads them into memory
for execution. Process loads into the memory for CPU scheduling.
 The primary objective of the job scheduler is to provide a
balanced mix of jobs, such as I/O bound and processor bound.
Short Term Scheduler:
 It is also called as CPU scheduler.
 Its main objective is to increase system performance in
accordance with the chosen set of criteria.
 It is the change of ready state to running state of the process.
 CPU scheduler selects a process among the processes that are
ready to execute and allocates CPU to one of them.
 Short-term schedulers, also known as dispatchers, make the
decision of which process to execute next. Short-term
schedulers are faster than long-term schedulers.
Medium Term Scheduler:
 Medium-term scheduling is a part of swapping.
 It removes the processes from the memory.
 It reduces the degree of multiprogramming.
 The medium-term scheduler is in-charge of handling the
swapped out-processes.
 A running process may become suspended if it makes an I/O
request. A suspended processes cannot make any progress
towards completion. In this condition, to remove the process
from memory and make space for other processes, the
suspended process is moved to the secondary storage.

PART-C
III. Answer any Three questions each question carries 8 marks

16. Explain in detail the role of operating system in process management, and file
management. Input-output management.
Process Management:
 Control access to shared resources like file, memory, I/O and CPU.
 Control execution of applications.
 The creation, execution and deletion of both user and system processes.
 Cancel or resume a process.
 Schedule a process
 The provision of mechanisms for process synchronization &
communication.
 The provision of mechanisms for deadlock handling.
File Management:
 File and directory creation and deletion.
 Manipulating files and directories.
 Provide access to files.
 Mapping files onto secondary storage.
 Backup files on stable storage media. 6. Protection and security of the
files.
Input-Output Management:
 Open, close and write device drivers
 Communicate, control and monitor the device driver.
 It offers a buffer caching system
 It provides drivers for particular hardware devices.
 To run the device driver software for specific hardware devices as and
when required
17. Explain inter-process communication in detail.
Inter-process communication is the mechanism provided by the
operating system that allows processes to communicate with each
other. This communication could involve a process letting another
process know that some event has occurred or the transferring of data
from one process to another.

Approaches to Interprocess Communication


The different approaches to implement interprocess communication are given as
follows −
 Pipe
A pipe is a data channel that is unidirectional. Two pipes can be used to create
a two-way data channel between two processes. This uses standard input
and output methods. Pipes are used in all POSIX systems as well as Windows
operating systems.
 Socket
The socket is the endpoint for sending or receiving data in a network. This is
true for data sent between processes on the same computer or data sent
between different computers on the same network. Most of the operating
systems use sockets for interprocess communication.
 File
A file is a data record that may be stored on a disk or acquired on demand by
a file server. Multiple processes can access a file as required. All operating
systems use files for data storage.
 Signal
Signals are useful in interprocess communication in a limited way. They are
system messages that are sent from one process to another. Normally,
signals are not used to transfer data but are used for remote commands
between processes.
 Shared Memory
Shared memory is the memory that can be simultaneously accessed by
multiple processes. This is done so that the processes can communicate with
each other. All POSIX systems, as well as Windows operating systems use
shared memory.
 Message Queue
Multiple processes can read and write data to the message queue without
being connected to each other. Messages are stored in the queue until their
recipient retrieves them. Message queues are quite useful for interprocess
communication and are used by most operating systems.

18. Explain the (a) SSTF


(b) SCAN disk scheduling algorithms.
SSTF: In SSTF (Shortest Seek Time First), requests having shortest seek time
are executed first. So, the seek time of every request is calculated in
advance in the queue and then they are scheduled according to their
calculated seek time. As a result, the request near the disk arm will get
executed first. SSTF is certainly an improvement over FCFS as it decreases
the average response time and increases the throughput of system. Let us
understand this with the help of an example.
Example:
Suppose the order of request is- (82,170,43,140,24,16,190)
And current position of Read/Write head is : 50
So, total seek time:
=(50-43)+(43-24)+(24-16)+(82-16)+(140-82)+(170-140)+(190-170)
=208
SCAN: In SCAN algorithm the disk arm moves into a particular direction and
services the requests coming in its path and after reaching the end of disk,
it reverses its direction and again services the request arriving in its path.
So, this algorithm works as an elevator and hence also known as elevator
algorithm. As a result, the requests at the midrange are serviced more and
those arriving behind the disk arm will have to wait.
Example:
Suppose the requests to be addressed are-82,170,43,140,24,16,190. And
the Read/Write arm is at 50, and it is also given that the disk arm should
move “towards the larger value”.
Therefore, the seek time is calculated as:
=(199-50)+(199-16)
=332
19. Explain in detail about the concept of demand paging.
The demand paging system is similar to the swapping paging system in that
processes are mostly stored in the main memory (usually on the hard disk).
As a result, demand paging is a procedure that addresses the problem
above just by shifting pages on demand. Lazy swapper is another name for
this ( It never swaps the page into the memory unless it is needed).
A pager is a kind of swapper that deals with the individual pages of a
process.
Demand Paging is a method in which a page is only brought into main
memory when the CPU requests it. At first, just those pages are loaded
directly required by the operation. Pages that are never accessed are thus
never loaded into physical memory.

Working:
When the CPU requests access to any page, the page table is used to find
the page in the main memory. If the page is found on the main memory, it
is good, and if it is not, then a page fault occurs.
Page fault is when the CPU wants to access the page from the main
memory, but it is not present in the main memory. Then, how to overcome
this?

For this swapped-in is used, the swapped-in is used to swap from the
secondary memory. Swapped-in refers to moving a program back to the
hard drive from the main memory, or RAM. However, if the page is already
in the main memory, it is retrieved from there. The secondary memory is
loaded with other pages. There are also valid and invalid bits, which are
used to check whether the page is present in the main memory. Valid bits
mean that the page is legal and present in the memory, and invalid bits
mean the page is not valid or it is not present in the memory.

20. Write a detailed note on any three directory structures


Single-level directory –
The single-level directory is the simplest directory structure. In it, all
files are contained in the same directory which makes it easy to support
and understand.
A single level directory has a significant limitation, however, when the
number of files increases or when the system has more than one user.
Since all the files are in the same directory, they must have a unique
name. If two users call their dataset test, then the unique name rule
violated.

Two-level directory –
As we have seen, a single level directory often leads to confusion of
files names among different users. The solution to this problem is to
create a separate directory for each user.
In the two-level directory structure, each user has their own user files
directory (UFD). The UFDs have similar structures, but each lists only
the files of a single user.

Tree-structured directory –
Once we have seen a two-level directory as a tree of height 2, the
natural generalization is to extend the directory structure to a tree of
arbitrary height.
This generalization allows the user to create their own subdirectories
and to organize their files accordingly.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy