0% found this document useful (0 votes)
4 views

Model Paper-03 (1)

The document outlines key concepts related to operating systems, including their functions, types of scheduling, process management, and deadlock handling methods. It discusses various algorithms for memory allocation and file organization, as well as the layered approach to operating system structure. The content is structured into parts with questions and answers, covering both theoretical and practical aspects of operating systems.
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 views

Model Paper-03 (1)

The document outlines key concepts related to operating systems, including their functions, types of scheduling, process management, and deadlock handling methods. It discusses various algorithms for memory allocation and file organization, as well as the layered approach to operating system structure. The content is structured into parts with questions and answers, covering both theoretical and practical aspects of operating systems.
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/ 19

MODEL PAPER-03

PART-A
I. Answer any Six questions each question carries 2 marks

1. Describe the operating system functions?


 File management
 Process management
 Memory management
 Secondary storage management
 I/O device management
 Network management
 Command interpreter system

2. Explain simple batch system?


A batch operating system is a type of operating system that allows multiple
users to use it at the same time, without direct communication between
them. This is done by having the users submit their jobs to the operating
system, which then processes them one at a time.

3. Define process?
A process is a program in execution and it is more than a program code called
as text section and this concept works under all the operating system
because all the task perform by the operating system needs a process to
perform the task. The process executes when it changes the state.

4. What are the 3 different types of scheduling queues?


 Job queue
 Ready queue
 Device queue

5. What is deadlock?
Deadlock is a situation where two or more processer are waiting for some
event to happen but such that don’t happen is a deadlock condition, and the
processers are said to be in a deadlock condition.

6. What are different methods for handling deadlock?


 Ignoring the issue
 Deadlock detection and recovery
 Deadlock avoidance
 Deadlock prevention

7. What are internal fragmentation?


Internal fragmentation occurs when the memory is distributed into fixed-
sized blocks. If the memory allocated to the process is slightly larger than the
memory demanded, then the difference between allocated and demanded
memory is known as internal fragmentation.

8. List the various file attributes?


 Name
 Identifier
 Type
 Location
 Size
 Protection
 Time and date

9. What is a directory?
A directory is a container that is used to contain folders and files. It organizes
files and folders in a hierarchical manner.
There are 5 types of directory structures:
 Single-level directory structure
 Two-level directory structure
 Tree/Hierarchical directory structure
 Acyclic-graph directory structure
 General-graph directory structure
PART-B
II. Answer any Four questions each question carries 6 marks
10. Differentiate between process and thread.

Process
 Process means any program is in execution.
 The process takes more time to terminate.
 It takes more time for creation.
 It also takes more time for context switching.
 The process is less efficient in terms of communication.
 Multiprogramming holds the concepts of multi-process.
 The process is isolated.
 The process is called the heavyweight process.
 Process switching uses an interface in an operating system.
 If one process is blocked then it will not affect the

execution of other processes.

Thread:

 Thread means a segment of a process.


 The thread takes less time to terminate.
 It takes less time for creation.
 It takes less time for context switching.
 Thread is more efficient in terms of communication.
 We don’t need multi programs in action for multiple threads because a
single process consists of
multiple threads.
 Threads share memory.
 A Thread is lightweight as each thread in a process shares code, data, and
resources.
 Thread switching does not require calling an operating system and
causes an interrupt to the kernel.
 If a user-level thread is blocked, then all other user-

level threads are blocked.


11. Explain FCFS scheduling algorithm with example.

 FCFS stands for First Come First Serve.


 In the FCFS scheduling algorithm, the job that arrived first in the ready
queue is allocated to the CPU and then the job that came second, and so
on.
 We can say that the ready queue acts as a FIFO (First In First Out)
queue thus the arriving jobs/processes are placed at the end of the
queue.
 FCFS is a non-preemptive scheduling algorithm as a process holds
the CPU until it either terminates or performs I/O.
12. What are the various objectives and functions of

operating system?

Functions of OS :

 Security : The operating system uses password protection to protect user


data and similar other techniques. It also prevents unauthorized access to
programs and user data.

 Control over system performance : Monitors overall system health to


help improve performance. Records the response time between service
requests and system response to having a complete view of the system
health. This can help improve performance by providing important
information needed to troubleshoot problems.

 Job accounting : Operating system Keeps track of time and resources used
by various tasks and users, this information can be used to track resource
usage for a particular user or group of users.

 Error detecting aids : The operating system constantly monitors the


system to detect errors and avoid the malfunctioning of a computer
system.

 Coordination between other software and users : Operating systems also


coordinate and assign interpreters, compilers, assemblers, and other
software to the various users of the computer systems.

 Memory Management : The operating system manages the Primary


Memory or Main Memory. Main memory is made up of a large array of
bytes or words where each byte or word is assigned a certain address. Main
memory is fast storage and it can be accessed directly by the CPU. For a
program to be executed, it should be first loaded in the main memory. An
 Device Management : An OS manages device communication via their
respective drivers. It performs the following activities for device
management. Keeps track of all devices connected to the system.
Designates a program responsible for every device known as the
Input/Output controller. Decides which process gets access to a certain
device and for how long. Allocates devices in an effective and efficient way.
Objectives of OS :
 Efficiency : The operating system increases the production efficiency. This
is because the system configuration takes less time. By default, the
operating system handles system tasks such as allocating resources to
processes and resolving conflicts between different programs and users.
This saves the user time and results in a more efficient result.

 Hardware abstraction : The operating system performs a good job of


concealing the computer’s intricate details. The user can fully utilise the
computer hardware without having to cope with the accompanying
difficulties. The operating system coordinates communication between
user programs and computer hardware.

 Convenience : In the absence of an operating system, users would have


to deal with the hardware directly without access to the pre-configured
utility packages that come with an operating system. This would make
using a computer extremely inconvenient. Operating systems allow users
to go right to work on the tasks they want to do without dealing with the
burden of setting up the system beforehand.

 System resource management : The operating system serves as a neutral


arbitrator. It serves a management role in the computer system by
ensuring equitable resource distribution among various operations and
consumers.

13. What are the major activities of operating system with regard to Process
management?
 Process Creation : When you first turn on your computer, the operating
system opens processes to run services for everything from the print
spooler to computer security. When you log in to the computer and start
programs, the programs create dependent processes . A process is not the
program itself, but rather the instructions that the CPU uses to execute the
program. A process either belongs to Windows or to some other program
that you have installed.

 Processing State : The state of a process may be “created,” “running,”


“waiting,” or “blocked.” You can say that a process is “waiting” the
moment after you start its parent program, and before it has been
processed by the CPU. A process is “running” when the CPU is processing
it. You can consider a process “blocked” if the computer does not have
enough memory to process it or if files associated with the process cannot
be located. All operating systems have some sort of process handling
system, though they have different names for each state.

 Process Synchronization : Once processes are running, the operating


system needs a way to ensure that no two processes access the same
resources at the same time. Specifically, no two processes can attempt to
execute the same area of code at once. If two processes did attempt to
execute this code at the same time, a crash could occur as they attempt to
call the same files and send the same instructions to the CPU at the same
time. If two processes need to run the same code, one must wait for the
other to finish before proceeding.

 Process Communication : The computer must ensure that processes can


communicate with the CPU and with each other. For example, a program
can have many processes, and each process can have a different
permission level. A permission level is simply an indication of the level of
access a process should have to the system. Process communication
ensures that the computer can determine the permissions of each process.
This is very important in preventing malware from deleting system files or
adding instructions to the operating system itself.

 Deadlock Prevention : Finally, the computer must have a way to ensure


that processes do not become deadlocked. Deadlock occurs when two
processes each require a resource that the other is currently using, and so
neither process can finish what it is doing. The resources cannot be
released, and programs lock up. You can also refer to this situation as a
“circular wait.” Operating systems prevent deadlock in different ways, but
the most common method is to force a process to declare the resources it
will need before it can start up. Alternatively, a process may be forced to
request resources in blocks, and then release the resources as it finishes
with them.

14. What are the different methods of handling deadlock?


 Deadlock Prevention : The strategy of deadlock prevention is to
design the system in such a way that the possibility of deadlock is
excluded. The indirect methods prevent the occurrence of one of
three necessary conditions of deadlock i.e., mutual exclusion, no
pre-emption, and hold and wait. The direct method prevents the
occurrence of circular wait. Prevention techniques – Mutual
exclusion – are supported by the OS. Hold and Wait – the condition
can be prevented by requiring that a process requests all its required
resources at one time and blocking the process until all of its
requests can be granted at the same time simultaneously.

 Deadlock Avoidance : The deadlock avoidance Algorithm works by


proactively looking for potential deadlock situations before they
occur. It does this by tracking the resource usage of each process and
identifying conflicts that could potentially lead to a deadlock. If a
potential deadlock is identified, the algorithm will take steps to
resolve the conflict, such as rolling back one of the processes or pre-
emptively allocating resources to other processes.

 Deadlock Detection : Deadlock detection is used by employing an


algorithm that tracks the circular waiting and kills one or more
processes so that the deadlock is removed. The system state is
examined periodically to determine if a set of processes is
deadlocked. A deadlock is resolved by aborting and restarting a
process, relinquishing all the resources that the process held.
i. This technique does not limit resource access or restrict process
action.
ii. Requested resources are granted to processes whenever
possible.
iii. It never delays the process initiation and facilitates online
handling.
iv. The disadvantage is the inherent pre-emption losses.

 Deadlock Ignorance : In the Deadlock ignorance method the OS


acts like the deadlock never occurs and completely ignores it even
if the deadlock occurs. This method only applies if the deadlock
occurs very rarely. The algorithm is very simple. It says ” if the
deadlock occurs, simply reboot the system and act like the
deadlock never occurred.”

15. Explain first fit, best fit, worst fit, next fit algorithm?
 First fit : Prerequisite : Partition Allocation Methods. In the first
fit, the partition is allocated which is first sufficient from the top
of Main Memory.
Algorithm:
i. Input memory blocks with size and processes with size.
ii. Initialize all memory blocks as free.
iii. Start by picking each process and
check if it can Be assigned to
current block.
iv. If size-of-process <= size-of-block
if yes then Assign and check for
next process.
v. If not then keep checking the further blocks.

 Best fit :
Algorithm :
i. Input memory blocks and processes with sizes.
ii. Initialize all memory blocks as free.
iii. Start by picking each process and find the minimum block size that
can be assigned to current process i.e., find min(blockSize[1],
blockSize[2],…..blockSize[n]) > processSize[current], if found then
assign it to the current process.

iv. If not then leave that process and keep checking the further processes.


Next fit :
The next fit is a modified version of ‘first fit’. It begins as the first fit
to find a free partition but when called next time it starts searching
from where it left off, not from the beginning. This policy makes use
of a roving pointer. The pointer moves along the memory chain to
search for the next fit. This helps in, to avoid the usage of memory
always from the head (beginning) of the free blockchain.
Algorithm:

i. Input the number of memory blocks and their sizes and initializes all the
blocks as free.
ii. Input the number of processes and their sizes.
iii. Start by picking each process and check if it can be assigned to the
current block, if yes,allocate the required memory and check for next
process but from the block where we left not from starting.
iv. If the current block size is smaller then keep checking the further blocks.

 Worst fit :
Prerequisite : Partition allocation methods : Worst Fit allocates a
process to the partition which is largest sufficient among the freely
available partitions available in the main memory. If a large process
comes at a later stage, then memory will not have space to
accommodate it.
Algorithm:
i. Input memory blocks and processes with sizes.
ii. Initialize all memory blocks as free.

iii. Start by picking each process and find maximum block size that can be
assigned to current process i.e., find max(blockSize[1],
blockSize[2],…..blockSize[n]) > processSize[current], if found then assign it
to the current process.

iv. If not then leave that process and keep checking the further processes.

16. Describe indexed file and indexed sequential file


organization

 Indexed File Allocation : There was a requirement for an allocation


approach that would allow disc blocks to be utilized effectively while
simultaneously reducing the access time. This is when indexed allocation
comes in handy. It is a hybrid of connected and contiguous allocation that
is more efficient in terms of space and time.
In this allocation, a unique block known as the Index block in this architecture holds
references to all the blocks occupied by a file. Each file has a unique index block.
The disc address of the ‘i th’ file block is contained in the index block's ‘ith’ entry.
The index block's address is contained in the directory entry.
The following image is an example of indexed file allocation.
The following image is an example of indexed file allocation.

 Indexed sequential file : Is an advanced sequential file organization


method. In this case, records are stored in the file with the help of the
primary key. For each primary key, an index value is created and mapped
to the record. This index contains the address of the record in the file.
PART-C
Answer any three questions each question carries 8 marks

17. Discuss the Simple Operating System Structure. Describe the layered
approach

The layered structure approach breaks up the operating system into different layers
and retains much more control on the system. The bottom layer (layer 0) is the
hardware, and the topmost layer (layer N) is the user interface. These layers are so
designed that each layer uses the functions of the lower-level layers only. It
simplifies the debugging process as if lower-level layers are debugged, and an error
occurs during debugging. The error must be on that layer only as the lower-level
layers have already been debugged.
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.

Kernel: The core of the operating system is the Kernel. It is the inner layer of 05. It
controls the computer's resources, allotting them to different users and to different
tasks. It interacts directly with the hardware. It never deals with the user directly. It
initiates the shell for user interaction Kernel is the part of the operating system that
loads first, and it remains in main memory. It handles the input/output requests
from software, translating them into data-processing instructions for the central
processing unit. It handles memory and peripherals like keyboards, monitors,
printers, and speakers.
Typically, the kernel is responsible for memory management, process and task
management and disk management.

Shell: The shell is a utility which acts as the command interpreter for the Kernel and
is the interface between the user and the Kernel. It is the outer layer of OS
Shell handles user interactions by Prompting the user to give input
Interpreting the input for the operating system Handling the output from the
operating system.
A shell is an environment or a special user program which provide an interface to
user to use operating system services. It executes programs based on the input
provided by the user.

18. What is the important feature of critical section? State the Readers Writers
problem and give solution using semaphore.
A critical section will usually terminate in finite time, and a thread, task, or process
will have to wait for a fixed time to enter it (bounded waiting). To ensure exclusive
use of critical sections some synchronization mechanism is required at the entry
and exit of the program.
The Readers Writers Problem:
 There is a shared resource which should be accessed by multiple processes.
 There are two types of processes in this context. They are reader and writer.
 Any number of readers can read from the shared resource simultaneously,
but only one writer can write to the shared resource.
 When a writer is writing data to the resource, no other process can access
the resource.
 A writer cannot write to the resource if there are non-zero number of
readers accessing the resource at that time.
Solution of Readers Writers Problem
From the above problem statement, it is evident that readers have higher priority
than writer. If a writer wants to write to the resource, it must wait until there are no
readers currently accessing that resource.

Here, we use one mutex m and a semaphore w. An integer variable read count is used
to maintain the number of readers currently accessing the resource. The variable read
count is initialized to 0 A value of 1 is given initially to m and w. Instead of having the
process to acquire lock on the shared resource, we use the mutex m to make the
process to acquire and release lock whenever it is updating the read count variable.
The code for the writer process is as given below:
while(TRUE)
{
wait(w);

/* perform the write operation */

signal(w);
}

And, the code for the reader process looks like this:
while(TRUE)
{
//acquire lock
wait(m);
read_count++;
if(read_count == 1)
wait(w);

//release lock
signal(m);

/* perform the reading operation */

// acquire lock
wait(m);
read_count--;
if(read_count == 0)
signal(w);

// release lock
signal(m);
}

As seen above in the code for the writer, the writer just waits on the w semaphore until it
gets a chance to write to the resource.

 After performing the write operation, it increments w so that the next writer can
access the resource. > On the other hand, in the code for the reader, the lock is
acquired whenever the read_count is updated by a process.
 When a reader wants to access the resource, first it increments the read count
value, then accesses the resource and then decrements the read count value.
 The semaphore w is used by the first reader which enters the critical section and
the last reader which exits the critical section.
 The reason for this is, when the first readers enter the critical section, the writer is
blocked
19. Explain the basic concepts of segmentation in detail.
In Operating Systems, Segmentation is a memory management technique in which
the memory is divided into the variable size parts. Each part is known as a segment
which can be allocated to a process.

The details about each segment are stored in a table called a segment table.
Segment table is stored in one (or many) of the segments.

Segment table contains mainly two information about segment:

Base: It is the base address of the segment


Limit: It is the length of the segment.

It is better to have segmentation which divides the process into the segments.
Each segment contains the same type of functions such as the main function can
be included in one segment and the library functions can be included in the other
segment.

When a program is loaded into memory, the segmentation system tries to locate
space that is large enough to hold the first segment of the process, space
information is obtained from the free list maintained by memory manager. Then it
tries to locate space for other segments. Once adequate space is located for all the
segments, it loads them into their respective areas.
The operating system also generates a segment map table for each program.

The Segment number is mapped to the segment table. The limit of the respective
segment is compared with the offset. If the offset is less than the limit then the
address is valid otherwise it throws an error as the address is invalid.

In the case of valid addresses, the base address of the segment is added to the
offset to get the physical address of the actual word in the main memory.
20. Explain disk structure in detail.

 Data is stored in Disk in form of tracks and sectors.


 Disk surface is divided in to tracks.
 Track is further dived in to sectors.
 Sector is the addressable unit in disk.
 A read/write head positioned just above the disk surface
 Information stored by magnetic recording on the track under read/write head
 Fixed head disk
 Moving head disk
 Designed for large amount of storage
 Primary design consideration cost, size, and spееd

 Hardwarе for disk system


Disk drivе, Dеvicе motor, Read/writе hеad, Associatеd logic

 Disk controllеr
Dеtеrminеs the logical interaction with the computer
Can service morе than onе drivе (ovеrlappеd sееks)

 Cylindеr
Thе samе numbеrеd tracks on all thе disk surfacеs
Еach track contains bеtwееn 8 to 32 sеctors

 Sеctor
Smallеst unit of information that can bе rеad from/writtеn into disk
Rangе from 32 bytеs to 4096 bytеs

Some important parameters used to measure the performance of hard disk are as
follow
Sееk timе
Seek Timе is time rеquirеd by rеad/writе hеad to movе to rеquеstеd track
Includеs thе initial startup timе and thе timе rеquirеd to travеrsе thе tracks to bе
crossеd oncе thе accеss arm is up to spееd.

Latеncy or rotational dеlay


Timе rеquirеd for thе rеquеstеd sеctor to comе undеr thе rеad/writе hеad.
Rotational delay is generally the half of the time taken in one rotation.

Data Transfer Rate


Data transfer rate is define as the amount of data transfer in per unit time for
example 30 MB/Sec.

Data Transfer Time


Data Transfer time is the total time taken to transfer a specific amount of data from
the disk. Data Transfer time depends on the data transfer rate of the disk.
Average Access Time
Average access time is calculated as
Average Access Time = Seek Time + Rotational Latency + Data Transfer Time

You might also like