You are on page 1of 23

Sample question paper

Q Questions/ Answer M
u ar
e. ks
a Differentiate between Batch Operating System and Time shared Operating
) System.
(any two points)
Sr. Batch Operating System Time shared Operating
No System
1 There is an operator which takes Each task is given some time to
similar jobs having same execute, so that all the tasks
requirement and group them into work smoothly
batches.
2 It is very difficult to guess or know Each task gets an equal
the time required by any job to opportunity
complete

b State any four services of Operating System.


)
Here is a list of common services offered by an almost all operating systems:

 User Interface
 Program Execution
 File system manipulation
 Input / Output Operations
 Communication
 Resource Allocation
 Error Detection
 Accounting
 Security and protection

c) Define : Process , Program


A process is defined as an entity which represents the basic unit of work to be
implemented in the system.

A program is a piece of code which may be a single line or millions of lines.


d State two features of preemptive scheduling.
)
1. Preemptive Scheduling is defined as the scheduling which is done when
the process changes from running state to ready state or from waiting
for the state to ready state.
2. We can interrupt the process in between of execution.
3. In preemptive scheduling, if a process which has high priority arrives in
the ready queue, then the process which has low priority may starve.
e) Define following terms
i) Page fault
ii) Segmentation
i) Page fault
While executing a program, if the program references a page which is not
available in the main memory because it was swapped out a little ago, the
processor treats this invalid memory reference as a page fault

ii) Segmentation

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 segment which can be allocated to a process.
f) Write syntax of ps command and explain its use with the help of suitable
example.
ps

PID TTY TIME CMD


5763 pts/3 00:00:00 zsh
8534 pts/3 00:00:00 ps
The result contains four columns of information.

o PID - the number of the process


o TTY - the name of the console that the user is logged into
o TIME- the amount of CPU in minutes and seconds that the process has been
running
o CMD - the name of the command that launched the process

g) List any four file attributes


Attributes of the File
1.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.
2.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.
3.Type
In a File System, the Files are classified in different types such as video files,
audio files, text files, executable files, etc.
4.Location
In the File System, there are several locations on which, the files can be stored.
Each file carries its location as its attribute.
5.Size
The Size of the File is one of its most important attribute. By size of the file, we
mean the number of bytes acquired by the file in the memory.
6.Protection
The Admin of the computer may want the different protections for the different
files. Therefore each file carries its own set of permissions to the different
group of Users.
7.Time and Date
Every file carries a time stamp which contains the time and date on which the
file is last modified.

Q.
2
)
a Explain dual modes of operations of an Operating system.
)
There are two modes of operation in the operating system to make sure it
works correctly. These are user mode and kernel mode.
A diagram that illustrates the transition from user mode to kernel mode and
back again is as follows:

The following are the modes:

 User Mode:

The system is in user mode when the operating system is running a user
application such as handling a text editor. The transition from user mode to
kernel mode occurs when the application requests the help of operating
system or an interrupt or a system call occurs.
The mode bit is set to 1 in the user mode. It is changed from 1 to 0 when
switching from user mode to kernel mode.

 Kernel Mode

The system starts in kernel mode when it boots and after the operating
system is loaded, it executes applications in user mode. There are some
privileged instructions that can only be executed in kernel mode. These are
interrupt instructions, input output management etc. If the privileged
instructions are executed in user mode, it is illegal and a trap is generated.
The mode bit is set to 0 in the kernel mode. It is changed from 0 to 1 when
switching from kernel mode to user mode.

b Describe essential activities done by an Operating System for protection and


) sharing
Protection
Protection provides mechanisms for controlling which users / processes have
access to which system resources.
System calls allow the access mechanisms to be adjusted as needed, and for
non-priveleged users to be granted elevated access permissions under
carefully controlled temporary circumstances.
Once only of concern on multi-user systems, protection is now important on all
systems, in the age of ubiquitous network connectivity.

Sharing of physical resources is not commonly implemented, but may be done


as if the virtual machines were networked together.
c) State what is interprocess communication and explain its advantages..
Interprocess 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 transferring of data from one process to another.
A diagram that illustrates interprocess communication is as follows:

The models of interprocess communication are as follows:

Shared Memory Model

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.

Advantage of Shared Memory Model


Memory communication is faster on the shared memory model as compared to
the message passing model on the same machine.

Disadvantages of Shared Memory Model


Some of the disadvantages of shared memory model are as follows:

 All the processes that use the shared memory model need to make sure
that they are not writing to the same memory location.
 Shared memory model may create problems such as synchronization
and memory protection that need to be addressed.

Message Passing Model

Multiple processes can read and write data to the message queue without
being connected to each other. Messages are stored on the queue until their
recipient retrieves them. Message queues are quite useful for interprocess
communication and are used by most operating systems.

Advantage of Messaging Passing Model


The message passing model is much easier to implement than the shared
memory model.

Disadvantage of Messaging Passing Model


The message passing model has slower communication than the shared
memory model because the connection setup takes time.
A diagram that demonstrates the shared memory model and message passing
model is given as follows:

d Discribe different scheduling criteria.


)
Different scheduling criteria are:

 CPU utilization. We want to keep the CPU as busy as possible. Conceptually,


CPU utilization can range from 0 to 100 percent. In a real system, it should
range from 40 percent (for a lightly loaded system) to 90 percent (for a
heavily used system).
 Throughput. If the CPU is busy executing processes, then work is being
done. One measure of work is the number of processes that are completed
per time unit, called throughput.
 Turnaround time. From the point of view of a particular process, the
important criterion is how long it takes to execute that process. The interval
from the time of submission of a process to the time of completion is the
turnaround time. Turnaround time is the sum of the periods spent waiting to
get into memory, waiting in the ready queue, executing on the CPU, and doing
I/0.
 Waiting time. The CPU-scheduling algorithm does not affect the amount of
time during which a process executes or does I/0, it affects only the amount
of time that a process spends waiting in the ready queue. Waiting time is the
sum of the periods spent waiting in the ready queue.
 Response time. Time from the submission of a request until the first
response is produced. This measure, called response time, is the since it takes
to start responding, not the time it takes to output the response.
Q. 12
3 M
a Define PCB. List information contained in PCB and explain any two 4
) M
Each process is represented as a process control block (PCB) in the operating
system. It contains
Information associated with specific process.
In general, a PCB may contain information regarding:
1. Process Number: Each process is identified by its process number, called
process identification
number (PID).
2. Priority: Each process is assigned a certain level of priority that
corresponds to the relative importance of the event that it services.
3. Process State: This information is about the current state of the process. I.e.
whether process is in
new, ready, running, waiting or terminated state.
4. Program Counter: This contains the address of the next instruction to be
executed for this process.
5. CPU Registers: CPU registers vary in number and type, depending upon the
computer architectures. These include index registers, stack pointers and
general purpose registers etc. When an interrupt occurred, information about
the current status of the old process is saved in registers along with the
program counters. This information is necessary to allow the process to be
continued correctly after the completion of an interrupted process.
6. CPU Scheduling Information: This information includes a process priority,
pointers to scheduling queues and any other scheduling parameters.
7. Memory Management Information: This information may include such
information as the value of base and limit registers, the page table or the
segment table depending upon the memory system used by operating system.
8. Accounting: This includes actual CPU time used in executing a process in
order to charge individual user for processor time.
9. I/O Status: It includes outstanding I/O request, allocated devices
information, pending operation and so on.
10. File Management: It includes information about all open files, access
rights etc.
b Define deadlock and state the necessary conditions for deadlock..
)
A Deadlock is a situation where each of the computer process waits for a
resource which is being assigned to some another process. In this situation,
none of the process gets executed since the resource it needs, is held by some
other process which is also waiting for some other resource to be released.
Let us assume that there are three processes P1, P2 and P3. There are three
different resources R1, R2 and R3. R1 is assigned to P1, R2 is assigned to P2
and R3 is assigned to P3.
After some time, P1 demands for R1 which is being used by P2. P1 halts its
execution since it can't complete without R2. P2 also demands for R3 which is
being used by P3. P2 also stops its execution because it can't continue without
R3. P3 also demands for R1 which is being used by P1 therefore P3 also stops
its execution.

In this scenario, a cycle is being formed among the three processes. None of the
process is progressing and they are all waiting. The computer becomes
unresponsive since all the processes got blocked.

Four condition for deadlock.


1. Mutual exclusion: Only one process at a time can use non-sharable
resource.
2. Hold and wait: A process is holding at least one resource and is waiting to
acquire additional resources held by other processes.
3. No pre-emption: A resource can be released only voluntarily by the process
holding it after that
process completes its task.
4. Circular wait: There exists a set {P0, P1, …, P0} of waiting processes such
that P0 is waiting for a
resource that is held by P1, P1 is waiting for a resource that is held by P2, …,
Pn–1 is waiting for a
resource that is held by Pn, and Pn is waiting for a resource that is held by P0.

c) Explain following terms with respect to Memory management :


I. Compaction
II. Swapping.
Compaction
External Fragmentation is the type of fragmentation in which the memory
space satisfies the requirement of the process. The problem here is that the
memory is not contiguous. So, the process is not able to use that memory.
It can be reduced with the help of the compaction technique. Through this
technique, we will shuffle the memory blocks in such a way so that all the free
memory space get merged and converted into a large memory block which can
be used by the process. This is shown in diagram clearly.
So, the compaction technique reduces the wastage of memory created by the
process of fragmentation.

Swapping
Swapping is a concept in which we do swapping of a process from main
memory to secondary storage and vice-versa. The swapping of processes from
one memory to another is explained clearly in the diagram given below. It
clearly explains that how this swap in and swap out thing works. This is done
so that the memory which we get free through swapping can be used by other
processes.
Swapping affects the performance of the system, but it is helpful or beneficial
for the system when we want to run multiple processes in parallel. Due to this
reason, memory compaction technique is another name given to swapping.

The total time taken by the swapping can be calculated by adding


1. The time is taken in moving the whole process from main memory to
secondary disk.
2. The time is taken in moving back from secondary disk to main memory.
3. Time is taken by the process to regain its main memory
By adding all the above time, we can calculate the total time taken in the whole
process.

d Enlist different file allocation methods and explain any two


)
List different file allocation methods. Explain any one in detail
File allocation methods are:
 Contiguous Allocation method
 Linked Allocation method
 Indexed Allocation method
Contiguous Allocation
 The contiguous allocation method requires each file to occupy a set of
contiguous address on the disk.
 Disk addresses define a linear ordering on the disk.
 With this ordering, accessing block b+1 after block b normally requires no
head movement.
 Contiguous allocation of a file is defined by the disk address and the length of
the first block. If the file is n blocks long, and starts at location b, then it
occupies blocks b, b+1, b+2, …, b+n-1.
 The directory entry for each file indicates the address of the starting block
and the length of the area allocated for this file

linked Allocation:
 In this method, each file occupies disk blocks scattered anywhere on the disk.
 It is a linked list of allocated blocks.
 When space has to be allocated to the file, any free block can be used from the
disk and system makes an entry in directory.
 Directory entry for allocated file contains file name, a pointer to the first
allocated block and last allocated block of the file.
 The file pointer is initialized to nil value to indicate empty file.
 A write to a file, causes search of free block.
 After getting free block data is written to the file and that block is linked to
the end of the file.
 To read the file, read blocks by following the pointers from block to block
starting with block address specified in the directory entry.
 For example, a file of five blocks starting with block 9 and continue with block
16,then block 1,then block 10 an finally block 25.each allocated block contains
a pointer to the next block.
Indexed Allocation:
 In this method, each file has its own index block.
 This index block is an array of disk block addresses.
 When a file is created, an index block and other disk blocks according to the
file size are allocated to that file.
 Pointer to each allocated block is stored in the index block of that file.
 Directory entry contains file name and address of index block.
 When any block is allocated to the file, its address is updated in the index
block.
 Any free disk block can be allocated to the file. Each ith entry in the index
block points to the ith block of the file. To find and read the ith block, we use
the pointer in the ith index block entry.
Q.
4
a Compare between Windows and LINUX Operating System.(any four points)
)

Description LInux Windows


Linux can be freely
distributed,
downloaded freely,
distributed through
$119 - $199.99, $69 for
magazines, Books
Cost students, $99 to upgrade to
etc. There are priced
pro
versions for Linux
also, but they are
normally cheaper
than Windows.
Linux is developed
by Open Source
development i.e.
Development through sharing and
Developed and distributed
and collaboration of
by Microsoft.
Distribution code and features
through forums etc
and it is distributed
by various vendors.
Linux kernel is
developed by the
Manufacture
community. Linus Microsoft
r
Torvalds oversees
things.
Everyone. From
home users to
User developers and Everyone
computer
enthusiasts alike.
Linux can be
installed on a wide
variety of computer
hardware, ranging
from mobile phones, On PC's desktops, laptops,
Usage
tablet computers servers and some phones.
and video game
consoles, to
mainframes and
supercomputers.
Ext2, Ext3, Ext4, Jfs,
File system
ReiserFS, Xfs, Btrfs, FAT,FAT32, NTFS, exFAT
support
FAT,FAT32, NTFS
BASH (Bourne Windows uses a command
Text mode Again SHell) is the shell and each version of
interface Linux default shell. Windows has a single
command interpreter with
dos-like commands,
It can support
recently there is the
multiple command
addition of the optional
interpreters.
PowerShell that uses more
Unix-like commands.
PowerPC: versions 1.0 - NT
4.0; DEC Alpha: versions 1.0
- NT 4.0; MIPS R4000:
Supported versions 1.0 - NT 4.0; IA-32:
All
platforms versions 1.0 - 8; IA-64:
version XP; x86-64:
versions XP - 8; ARM:
version RT;

b Write any four system calls related to device management.


)
A process may need several resources for its execution. So system calls used for
asking permission from the kernel to use those resources are included in this
type.

1. request device, release device


2. read, write, reposition
3. get device attributes, set device attributes
4. logically attach or detach devices

c) Compare between short term and long term scheduler.(any four points)
BASIS FOR LONG-TERM SHORT-TERM
COMPARISON SCHEDULER SCHEDULER

Basic It picks up the process It picks up the process


from Job Pool/Job Queue. from Ready Queue.

Frequency Long-Term Scheduler Short-Term Scheduler


selects the process less select the process
frequently. more frequently.

Control It controls the Degree of It has less control over


Multiprogramming. the Degree of
Multiprogramming.

Alternative Alternatively, it is called Alternatively, it is


Job Scheduler. called CPU Scheduler.

Important Long-Term Scheduler is Short-Term Scheduler


there in Batch Systems is there in Batch
but it may or may not be System and is
present in Time Sharing minimally present in
System. the Time Sharing
System also
d Compare FCFS and SJF Scheduling algorithm with any four points.
)

First Come First Serve (FCFS)


Let's start with the Advantages:

 FCFS algorithm doesn't include any complex logic, it just puts the
process requests in a queue and executes it one by one.
 Hence, FCFS is pretty simple and easy to implement.
 Eventually, every process will get a chance to run, so starvation doesn't
occur.

It's time for the Disadvantages:

 There is no option for pre-emption of a process. If a process is started,


then CPU executes the process until it ends.
 Because there is no pre-emption, if a process executes for a long time,
the processes in the back of the queue will have to wait for a long time
before they get a chance to be executed.

Shortest Job First (SJF)


Starting with the Advantages: of Shortest Job First scheduling algorithm.

 According to the definition, short processes are executed first and then
followed by longer processes.
 The throughput is increased because more processes can be executed in
less amount of time.

And the Disadvantages:

 The time taken by a process must be known by the CPU beforehand,


which is not possible.
 Longer processes will have more waiting time, eventually they'll suffer
starvation.
e) Describe contiguous memory allocation done by Operating System with he
help of
suitable example.
Contiguous Allocation
 The contiguous allocation method requires each file to occupy a set of
contiguous address on the disk.
 Disk addresses define a linear ordering on the disk.
 With this ordering, accessing block b+1 after block b normally requires no
head movement.
 Contiguous allocation of a file is defined by the disk address and the length of
the first block. If the file is n blocks long, and starts at location b, then it
occupies blocks b, b+1, b+2, …, b+n-1.
 The directory entry for each file indicates the address of the starting block
and the length of the area allocated for this file
Q. Attempt any TWO of the following. 12
5 M
a Write two uses of following Operating System tools :
) i. Performance Monitor
ii. Task scheduler
iii. User Management
Performance Monitor
Performance Monitor is the second most common operating system
performance monitoring tool for Windows. Performance Monitor acts as both a
real time and log-based performance monitoring tool for operating systems, so
only the real time portion of the tool will be discussed in detail in this section,
and the logging portion will be discussed later.

Like Task Manager, Performance Monitor measures performance by making


system calls to retrieve system counters, but Performance Monitor makes these
calls via a performance library that also supports logging of the counters.
Unlike Task Manager, Performance Monitor provides an interface to monitor
any selection of a huge set of system counters on a graph in real time, rather
than just the limited set Task Manager uses. Counters include things like
percentage of processor time, thread count, page fault rate, memory size, and
elapsed time for processes. Similarly, there are counters that provide state for
threads, the processor, the system, network interfaces, memory, physical disks,
and many others. This level of detailed information available for monitoring
from Performance Monitor is very extensive and makes Performance Monitor
ideal for monitoring resource usage and performance of almost all pieces of a
Windows system.

Task scheduler

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. Schedulers are of three types −
 Long-Term Scheduler
 Short-Term Scheduler
 Medium-Term Scheduler

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. It also controls the degree of
multiprogramming. If the degree of multiprogramming is stable, then the
average rate of process creation must be equal to the average departure rate
of processes leaving the system.
On some systems, the long-term scheduler may not be available or minimal.
Time-sharing operating systems have no long term scheduler. When a process
changes the state from new to ready, then there is use of long-term scheduler.

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. This
process is called swapping, and the process is said to be swapped out or
rolled out. Swapping may be necessary to improve the process mix.

User Management

Linux is a multi-user operating system. Even systems that will be used by a


single user are configured as a multi-user system. This has various advantages:

 security-wise, your system is protected from malicious software


execution as the software is executed as an unprivileged user rather
than the system administrator
 if at any time multiple users are going to work on the system, you just
need to add the user to the system (no need to upgrade to a multi-user
environment first)
 you can easily back up all files belonging to a particular user as all user
files are located inside his home directory
 if you messed up your personal configuration for a particular software
title, you can just remove the configuration files (or move them aside)
and start the software title up again to start with a clean slate. No
configuration changes made by a user are propagated system-wide

b Write the output of the following commands.


) a. Kill 9042018
b. Ps 07121975
c. Sleep 05
a. Kill 9042018

To kill, or terminate a process first find out the process identifier number or
PID of the process to be killed, then pass the PID number to the kill command.

b. Ps 07121975

the ps command shows the running processes by the user running it within a
terminal window. To invokeps simply type the following:

c. Sleep 05
waiting for 5 seconds

c) Given a page reference reference string(arrival) with four page frames,


calculate
the page faults with FIFO and LRU page replacement algorithms respectively :
12, 3, 4, 5, 1, 2, 5, 1, 2, 3, 4, 5, 1,6,7,8,7,8,9,7,8,9,5,4,4,5,4,2.
FIFO

1 3 4 5 1 2 5 1 2 3 4 5 1 6 7 8 7 8 9 7 8 9 5 4 4 5 4 2
2
1 1 1 5 5 5 5 5 5 3 3 3 1 1 1 8 8 8 8 8 8 8 8 4 4 4 4 4
2 2 2
3 3 3 1 1 1 1 1 1 4 4 4 6 6 6 6 6 9 9 9 9 9 9 9 9 9 2
4 4 4 2 2 2 2 2 2 5 5 5 7 7 7 7 7 7 7 7 5 5 5 5 5 5
F F F F F F F F F F F F F F F F F

No. of page fault:- 17

LRU
1 3 4 5 1 2 5 1 2 3 4 5 1 6 7 8 7 8 9 7 8 8 5 4 4 5 4 2
2
1 1 1 5 5 5 5 5 5 3 3 3 1 1 1 8 8 8 9 9 8 8 8 4 4 4 4 2
2 2 2
3 3 3 1 1 1 1 1 1 4 4 4 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6

4 4 4 2 2 2 2 2 2 5 5 5 7 7 7 7 7 7 7 7 5 5 5 5 5 5
F F F F F F F F F F F F F F F F F F

No. of page fault:- 18

Q. Attempt any TWO of the following 12


6 M
A Solve given problem by Using FCFS to calculate average waiting time and
) turnaround
time.

Process Arrival Burst


time time
P1 0 7
P2 1 4
P3 2 9
P4 3 6
P5 4 8

P1 P2 P3 P4 P5
0 7 11 20 26 34

TAT = ENDING TIME - ARRIVAL TIME

PROCESS ENDING TIME ARRIVAL TIME TAT


P1 7 0 7
P2 11 1 10
P3 20 2 18
P4 26 3 23
P5 34 4 30

Avg. TAT = (7+10+18+23+30)/5 = 17.6

WT = TURN AROUND TIME - BURST TIME

PROCESS TURN BURST TIME WT


AROUND TIME
P1 7 7 0
P2 10 4 6
P3 18 9 9
P4 23 6 17
P5 30 8 22

Avg. WT = (0+6+9+17+22)/5 = 10.8


b Compare between bitmap and linked list free space management
) techniques.(any six
points)
1. Bitmap

This technique is used to implement the free space management. When the
free space is implemented as the bitmap or bit vector then each block of the
disk is represented by a bit. When the block is free its bit is set to 1 and when
the block is allocated the bit is set to 0. The main advantage of the bitmap is it
is relatively simple and efficient in finding the first free block and also the
consecutive free block in the disk. Many computers provide the bit
manipulation instruction which is used by the users.

The calculation of the block number is done by the formula:

(number of bits per words) X (number of 0-value word) + Offset of first 1


bit

For Example: Apple Macintosh operating system uses the bitmap method to
allocate the disk space.

Assume the following are free. Rest are allocated:

Advantages:

 This technique is relatively simple.


 This technique is very efficient to find the free space on the disk.

Disadvantages:

 This technique requires a special hardware support to find the first 1 in


a word it is not 0.
 This technique is not useful for the larger disks.

For example: Consider a disk where blocks 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 17, 18,
25,26, and 27 are free and the rest of the blocks are allocated. The free-space
bitmap would be: 001111001111110001100000011100000

2. Linked list

This is another technique for free space management. In this linked list of all
the free block is maintained. In this, there is a head pointer which points the
first free block of the list which is kept in a special location on the disk. This
block contains the pointer to the next block and the next block contain the
pointer of another next and this process is repeated. By using this disk it is not
easy to search the free list. This technique is not sufficient to traverse the list
because we have to read each disk block that requires I/O time. So traversing
in the free list is not a frequent action.

Advantages:

 Whenever a file is to be allocated a free block, the operating system can


simply allocate the first block in free space list and move the head
pointer to the next free block in the list.

Disadvantages:

 Searching the free space list will be very time consuming; each block
will have to be read from the disk, which is read very slowly as
compared to the main memory.
 Not Efficient for faster access.

In our earlier example, we see that keep block 2 is the first free block which
points to another block which contains the pointer of the 3 blocks and 3 blocks
contain the pointer to the 4 blocks and this contains the pointer to the 5 block
then 5 block contains the pointer to the next block and this process is repeated
at the last.
c) Construct and explain directory structure of a file system in terms of single
level, two level and tree structure
A directory is a container that is used to contain folders and file. It organizes
files and folders into a hierarchical manner.

There are several logical structures of a directory, these are given below.
1. Single-level directory –
Single level directory is simplest directory structure.In it all files are
contained in same directory which make 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 the unique
name . if two users call their dataset test, then the unique name rule
violated.

Advantages:
 Since it is a single directory, so its implementation is very easy.
 If files are smaller in size, searching will faster.
 The operations like file creation, searching, deletion, updating are
very easy in such a directory structure.
Disadvantages:
 There may chance of name collision because two files can not have
the same name.
 Searching will become time taking if directory will large.
 In this can not group the same type of files together.
2. 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 there own user files
directory (UFD). The UFDs has similar structures, but each lists only the
files of a single user. system’s master file directory (MFD) is searches
whenever a new user id=s logged in. The MFD is indexed by username or
account number, and each entry points to the UFD for that user.

Advantages:
 We can give full path like /User-name/directory-name/.
 Different users can have same directory as well as file name.
 Searching of files become more easy due to path name and user-
grouping.
Disadvantages:
 A user is not allowed to share files with other users.
 Still it not very scalable, two files of the same type cannot be grouped
together in the same user.
3. 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 there own subdirectories
and to organize on their files accordingly.

A tree structure is the most common directory structure. The tree has a
root directory, and every file in the system have a unique path.
Advantages:
 Very generalize, since full path name can be given.
 Very scalable, the probability of name collision is less.
 Searching becomes very easy, we can use both absolute path as well
as relative.
Disadvantages:
 Every file does not fit into the hierarchical model, files may be saved
into multiple directories.
 We can not share files.
 It is inefficient, because accessing a file may go under multiple
directories.
4. Acyclic graph directory –
An acyclic graph is a graph with no cycle and allows to share
subdirectories and files. The same file or subdirectories may be in two
different directories. It is a natural generalization of the tree-structured
directory.
It is used in the situation like when two programmers are working on a
joint project and they need to access files. The associated files are stored
in a subdirectory, separated them from other projects and files of other
programmers since they are working on a joint project so they want to
the subdirectories into there own directories. The common
subdirectories should be shared. So here we use Acyclic directories.
It is the point to note that shared file is not the same as copy file if any
programmer makes some changes in the subdirectory it will reflect in
both subdirectories.
Advantages:
 We can share files.
 Searching is easy due to different-different paths.
Disadvantages:
 We share the files via linking, in case of deleting it may create the
problem,
 If the link is soft link then after deleting the file we left with a
dangling pointer.
 In case of hard link, to delete a file we have to delete all the reference
associated with it.

5. General graph directory structure –


In general graph directory structure, cycles are allowed within a directory
structure where multiple directories can be derived from more than one
parent directory.
The main problem with this kind of directory structure is to calculate
total size or space that has been taken by the files and directories.

Advantages:
 It allows cycles.
 It is more flexible than other directories structure.
Disadvantages:
 It is more costly than others.
 It needs garbage collection.

You might also like