Device and File Management in Operating Systems: BN104/BN104D

Verified

Added on  2025/04/10

|17
|1969
|404
AI Summary
Desklib provides past papers and solved assignments for students. This report covers device and file management in operating systems.
Document Page
Unit Code: BN104/BN104D
Unit Title: Operating Systems
Assessment Title: Device and file management
Submitted By –
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Table of Contents
List of Figures...............................................................................................................................................3
List of Tables................................................................................................................................................3
Introduction.................................................................................................................................................4
B-Q1 Device Handler Seek Strategies and Primary and Secondary storage.................................................5
a. On a hard disk, the queue of track requests is as follows:...............................................................5
b. Calculate the total number of tracks and the average number of tracks travelled by the head to
satisfy the requests in B-Q1-a..................................................................................................................6
B-Q2 Deadlock and File Management.........................................................................................................7
a. Describe the four conditions of deadlock in your own word...........................................................7
b. Consider a system with five dedicated devices and four processes (process A, B, C and D) that
require a maximum of two devices to complete the task. Draw a directed graph of a scenario that
demonstrates there is a deadlock in the system. You can use any number of devices (maximum five)
and processes (maximum four) in your demonstration. Explain your graph with details.......................8
c...............................................................................................................................................................9
i. As described in lecture, files can be formatted with fixed-length or variable-length fields. Explain
them in your own words with example (make sure your example is different from the one used in the
lecture.....................................................................................................................................................9
ii. Explain relative and complete file name in your own words with example.....................................9
B-Q3 UNIX..................................................................................................................................................10
Conclusion.................................................................................................................................................14
References.................................................................................................................................................15
Document Page
List of Figures
Figure 1: Arm movement diagram for FCFS.................................................................................................5
Figure 2: Arm movement diagram for SSTF.................................................................................................5
Figure 3: Arm movement diagram for LOOK...............................................................................................6
Figure 4: Sample deadlock diagram.............................................................................................................7
Figure 5: Resource allocation diagram with deadlock.................................................................................8
Figure 6: chmod 1......................................................................................................................................11
Figure 7: chmod 2......................................................................................................................................11
Figure 8: cd 1.............................................................................................................................................12
Figure 9: cd 2.............................................................................................................................................12
Figure 10: mkdir 1......................................................................................................................................12
Figure 11: mkdir 2......................................................................................................................................12
Figure 12: ls 1............................................................................................................................................13
Figure 13: ls 2............................................................................................................................................14
List of Tables
Table 1: Table for Numeric mode..............................................................................................................10
Table 2: Table for symbolic mode..............................................................................................................10
Table 3: File permissions table..................................................................................................................11
Document Page
Introduction
This report is based on the device and file management in the operating system. The purpose of this
assignment is to understand some of the important characteristics of the operating system. This
assignment involves the learning of operating system concepts like processes, deadlocks, file and device
management, etc. This report also includes the basics of operating system structure, virtual memory,
demand paging, memory allocation, etc. The successful completion of this assignment will also provide
the understanding of the integration of hardware, the functioning of peripheral devices, software
applications, file system structures, etc. it will also give the opportunity to demonstrate the competency
to use CLI operate UNIX like operating systems and common UNIX administration tasks.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
B-Q1 Device Handler Seek Strategies and Primary and
Secondary storage.
a. On a hard disk, the queue of track requests is as follows:
19 36 2 27 0 21 18 55 22
Assume that the head starts at track 19.
Draw a diagram for arm movement for each of the following seek strategies.
The arm movement of the disk header for Disk scheduling algorithms[1] is given below:-
i. FCFS
Figure 1: Arm movement diagram for FCFS
ii. SSTF
Document Page
Figure 2: Arm movement diagram for SSTF
iii. LOOK
Figure 3: Arm movement diagram for LOOK
b. Calculate the total number of tracks and the average
number of tracks traveled by the head to satisfy the
requests in B-Q1-a.
Solution:
The tracks traveled by one head movement is the difference between source track to the destination
track. Total number of tracks is the sum of tracks traveled per head movement. Therefore,
Total number of tracks = Σ (tracks traveled per head movement) and
Average number of tracks traveled = (total number of tracks traveled) / (total tracks)
i. FCFS:
Total number of tracks = (36-19)+(36-2)+(27-2)+(27-0)+(21-0)+(21-18)+(55-18)+(55-22)=197
Document Page
Average number of tracks traveled = (total number of tracks traveled) / (total tracks)
= 197/55 =3.581
ii. SSTF:
Total number of tracks = (19-18)+(21-18)+(22-21)+(27-22)+(36-27)+(55-36)+(55-2)+(2-0)=93
Average number of tracks travelled = (total number of tracks travelled) / (total tracks)
= 93/55 =1.690
iii. LOOK:
Total number of tracks = (19-18)+(18-2)+(2-0)+(21-0)+(22-21)+(27-22)+(36-27)+(55-36)=70
Average number of tracks travelled = (total number of tracks travelled) / (total tracks)
= 70/55 = 1.272
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
B-Q2 Deadlock and File Management.
a. Describe the four conditions of deadlock in your own word.
Solution:
Deadlock is a situation wherein a set of processes are blocked due to each process holding a set of
resources acquired by another process. The processes are said to be in deadlock only if all the 4
conditions hold true simultaneously. The 4 conditions of deadlock are:-
1. Mutual Exclusion
This condition occurs when one or more resources are in a non-sharable mode which means
only one process can use that resource/s at a time.
2. Hold and wait –
This condition occurs when the process is holding some resources and waiting for additional
resources to be allocated.
3. No pre-emption –
This condition says that the resources of one process cannot be pre-empted by another process.
The process cannot be released until the process releases it voluntarily.
4. Circular wait –
A set of processes are waiting for the requested resources in a circular form.[2]
In the diagram below, process P1 is holding resource R2 and waiting for R1 which is allocated to process
P2. Process P2 is holding resources R1 and R2 and waiting for resources R3 which is allocated to process
P3 who is waiting for resource R2. This whole situation creates a deadlock.
Document Page
Figure 4: Sample deadlock diagram
b. Consider a system with five dedicated devices and four
processes (process A, B, C, and D) that require a maximum
of two devices to complete the task. Draw a directed graph
of a scenario that demonstrates there is a deadlock in the
system. You can use any number of devices (maximum five)
and processes (maximum four) in your demonstration.
Explain your graph with details.
Solution:
Document Page
Figure 5: Resource allocation diagram with deadlock
The above diagram depicts a sample deadlock situation. A, B, C, & D represents processes and R1, R2,
R3, & R4 represents resources. Process A is holding resource R4 and waiting for resource R1 which is
acquired by process B who is waiting for resource R2. Similarly, process C is holding resource R2 and
waiting for R3 which is acquired by process D who is waiting for R1 acquired by process A. This whole
scenario fulfills all 4 conditions of deadlock and thus creates a deadlock.
c.
i. As described in lecture, files can be formatted with fixed-
length or variable-length fields. Explain them in your own
words with an example (make sure your example is
different from the one used in the lecture.
Solution:
When a fixed length file is created, all the fields or records in the field are of same bytes. For example, a
file that stores only enrollment ID and mobile number of a person. Both of the fields are of fixed length.
Therefore, a file will be formatted with a fixed length of 24 bits=3 Bytes.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
When a variable length file is created, the records may contain variable number of bytes up to a
specified maximum size. For example, a file that stores all the details of an employee like name, age,
enrollment ID, mobile number, and address shall be formatted as variable length file with each field
having a variable length.
ii. Explain relative and complete file name in your own words
with an example.
Solution:
A file name which starts from the root or top-level directory and recursively includes all the directory in
which file is contained is called as the absolute or complete filename.[5]
For example,
C:\Users\abc\OneDrive\Pictures\Saved Pictures\home.jpg
A file name specifying the position of the file in the file system tree relative to default directory is called
relative filename. ‘../’ are used to represent the number of directories that are level up to the current
directory.[6]
For example,
../index.php – index.php is present in a folder which is one level higher than the current
directory
../../game.exe – game.exe is present in a folder which is two levels higher than the current
directory
Document Page
B-Q3 UNIX
i. chmod:
chmod is short for change mode. This command is used to change access (read, write & execute)
permissions of a filesystem object.[4]
These permissions are defined on the user, group, and others (ugo).
‘+’ adds file mode bits to the existing bits.
‘-‘ removes mentioned file mode bits from the existing bits.
‘=’ adds the mentioned bits and remove the unmentioned bits.
Note: When chmod is applied to a directory the modes show different behavior, like –
Read mode allows listing files in a directory,
Write mode allows adding new files,
Execute mode allows accessing files in the directory.
Chmod works in 2 modes:-
1. Numeric mode (Octal representation):
This mode represents file access permissions in octal form. Here,
Table 1: Table for Numeric mode
Mode Numeric Form
Read 4
Write 2
Execute 1
2. Symbolic mode:
This mode has predefined letter corresponding to the file access permission type. Here,
Table 2: Table for symbolic mode
Mode Numeric Form
Read r
Write w
Execute x
chevron_up_icon
1 out of 17
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]