Model Paper-03 (1)
Model Paper-03 (1)
PART-A
I. Answer any Six questions each question carries 2 marks
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.
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.
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
Thread:
operating system?
Functions of OS :
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.
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.
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.
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);
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);
// 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.
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.
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.