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

CT3 OS Answer Key-Final PDF

1. Thrashing occurs when a process spends more time swapping pages in and out of memory rather than executing. This leads to low CPU utilization. The working set model aims to prevent thrashing by examining a process's recent page references. 2. The working set of a process is the set of pages it has referenced within a fixed number of references called the working set window. The total demand of all processes' working sets should not exceed available memory, otherwise thrashing will occur. 3. If total demand is greater than available memory, the working set model dictates suspending one of the processes to reduce page swapping and prevent thrashing.

Uploaded by

Saksham Sahay
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)
48 views

CT3 OS Answer Key-Final PDF

1. Thrashing occurs when a process spends more time swapping pages in and out of memory rather than executing. This leads to low CPU utilization. The working set model aims to prevent thrashing by examining a process's recent page references. 2. The working set of a process is the set of pages it has referenced within a fixed number of references called the working set window. The total demand of all processes' working sets should not exceed available memory, otherwise thrashing will occur. 3. If total demand is greater than available memory, the working set model dictates suspending one of the processes to reduce page swapping and prevent thrashing.

Uploaded by

Saksham Sahay
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/ 13

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

ANSWER KEY SUBMISSION

Date of Exam & 23.6.2022


Category of Exam CLA1/CLA2/CLA3/SURPRISE
Session FN
TEST

Course Name Operating Systems Course Code


18CSC205J

Name of the Faculty Dr.S.Veena & Date of submission of 23.6.2022


submitting Dr.Shanmuganathan Answer Key
Department to which 50
CSE Total Marks
the Faculty belongs to

PART A (20 X 1= 20)


Q.
Questions Marks
No.
When a program tries to access a page that is mapped in address space but not loaded in physical
memory, then what occurs
a) page fault occurs
1. 1
b) fatal error occurs
c) segmentation fault occurs
d) no error occurs
Which algorithm chooses the page that has not been used for the longest period of time whenever
the page required to be replaced?
a) first in first out algorithm
2. 1
b) additional reference bit algorithm
c) least recently used algorithm
d) counting based page replacement algorithm
Working set model for page replacement is based on the assumption of ____________
a) modularity
3. b) locality 1
c) globalization
d) random access
Applying the LRU page replacement to the following reference string. 1 2 4 5 2 1 2 4
The main memory can accommodate 3 pages and it already has pages 1 and 2. Page 1 came in
before page 2.
How many page faults will occur?
4. 1
a) 2
b) 3
c) 4
d) 5
Which of the following page replacement algorithms suffers from Belady’s Anomaly?
a) Optimal replacement
5. b) LRU 1
c) FIFO
d) Both optimal replacement and FIFO
A process refers to 5 pages, A, B, C, D, E in the order : A, B, C, D, A, B, E, A, B, C, D, E. If the
page replacement algorithm is FIFO, the number of page transfers with an empty internal store of 3
6. frames is? 1
a) 8
b) 10

Course Code : 18CSC205J Page No. 1 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

c) 9
d) 7
The aim of creating page replacement algorithms is to ____________
a) replace pages faster
7. b) increase the page fault rate 1
c) decrease the page fault rate
d) to allocate multiple pages to processes
A FIFO replacement algorithm associates with each page the _______
a) time it was brought into memory
8. b) size of the page in memory 1
c) page after and before it
d) page recently used
What is the Optimal page – replacement algorithm?
a) Replace the page that has not been used for a long time
9. b) Replace the page that has been used for a long time 1
c) Replace the page that will not be used for a long time
d) Replace the page that will big in size.
Optimal page – replacement algorithm is difficult to implement, because ____________
a) it requires a lot of information
10. b) it requires future knowledge of the reference string 1
c) it is too complex
d) it is extremely expensive
Defective sectors on a disk are often called as ______.
a) good block
11. b) destroyed blocks 1
c) bad blocks
d) error blocks
File type can be represented by ____________
a) file name
12. b) file extension 1
c) file identifier
d) file permission
_________ is a sequence of procedures and functions.
a) object file
13. b) source file 1
c) executable file
d) text file
Which of the following is crucial time while accessing the data on the disks?
a) seek time
14. b) Rotational delay 1
c) Transmission time
d) Waiting time
The ________ policy restricts scanning to one direction only.
a) SCAN
15. b) C-SCAN 1
c) FCFS
d) SSTF
____________ are often used where very rapid access is required, where fixed length records are
used, and where records are always accessed one at a time.
a) Direct files
16. 1
b) Sequential files
c) Indexed files
d) Indexed sequential file
17. __________________ refers to the logical structuring of records. 1

Course Code : 18CSC205J Page No. 2 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

a) file organisation
b) structural organisation
c) physical organisation
d) logical organisation
The universe consists of __________
a) all users in the system
18. b) all users that are not owners 1
c) all users that aren’t included in the group or owners
d) all users that are included in group
Virtual memory uses disk space as an extension of ____.
a) secondary storage
19. b) main memory 1
c) tertiary storage
d) cache memory
________is series or collection of bits where each bit corresponds to a disk block.
a) Bit Vector
20. b) Array 1
c) List
d) Index

PART B (3 X 10 = 30)
ANSWER ALL THE QUESTIONS
Q.
Questions Marks
No.
a) Explain in detail about thrashing and working set model
Thrashing : (5 Marks)
➢ A process is busy with swapping pages in and out. This high paging activity is called
Thrashing.
➢ A process is in thrashing if it is spending more time on paging rather than executing.
Cause of Thrashing
If a process does not have “enough” pages, the page-fault rate is very high. This leads to:
➢ low CPU utilization.
➢ operating system thinks that it needs to increase the degree of multiprogramming.
another process added to the system

21 10

Working Set Model: (5 Marks)


▪ It is based on the assumption of locality.
  working-set window  a fixed number of page references
Example: 10,000 instruction
▪ The idea is to examine the most recent  page references.
▪ WSSi (working set of Process Pi) = total number of pages referenced in the most recent
 (varies in time)

Course Code : 18CSC205J Page No. 3 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

 if  too small will not encompass entire locality.


 if  too large will encompass several localities.
 if  =   will encompass entire program.
▪ D =  WSSi  total demand frames
▪ if D > m  Thrashing
 Policy if D > m, then suspend one of the processes.
▪ if D <= m  No Thrashing
▪ The sequence of memory references shown in Figure,
▪ if  = 10 memory references,
▪ Then the working set at time
▪ t1 is {1, 2, 5, 6, 7}
▪ t2, the working set has changed to {3, 4}.

The working set model states that a process can be in RAM if and only if all of the pages
that it is currently using (often approximated by the most recently used pages) can be in
RAM.

b) Give a brief discussion about virtual memory and how OS handles the page fault
effectively?
Virtual memory (5 Marks)
Virtual memory is a technique that allows the execution of processes that are not completely
in Main memory.
Virtual memory – involves the separation of logical memory as perceived by users from
physical memory.
Need for virtual memory
➢ Programs often have code to handle unusual error conditions. Since these errors
seldom, if ever, occur in practice, this code is almost never executed.
➢ Arrays, lists, and tables are often allocated more memory than they actually need. An
array may be declared 100 by 100 elements, even though it is seldom larger than 10
10
by 10 elements.
➢ An assembler symbol table may have room for 3,000 symbols, although the average
program has less than 200 symbols. Certain options and features of a program may be
used rarely. Even in those cases where the entire program is needed, it may not all be
needed at the same time.
➢ One major advantage of this scheme is that programs can be larger than physical
memory.
➢ Further, virtual memory abstracts main memory into an extremely large, uniform
array of storage, separating logical memory as viewed by the user from physical
memory.
➢ This separation allows an extremely large virtual memory to be provided for
programmers when only a smaller physical memory is available.

Course Code : 18CSC205J Page No. 4 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Steps in Handling a Page Fault (5 Marks):

1. Check an internal table (usually kept with the process control block) whether the
reference was a valid or an invalid memory access.
2. If the reference
Invalid, we terminate the process.
Valid but we have not yet brought in that page, we now page it in.
3. Find a free frame
4. Schedule a disk operation to read the desired page into the newly allocated frame.
5. When the disk read is complete, modify the internal table kept with the process and
the page table to indicate that the page is now in memory.
6. We restart the instruction that was interrupted by the trap. The process can now access
the page as though it had always been in memory.

a) Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 2
124, 65, 67. The head is initially at cylinder number 53. The cylinders are numbered from
0 to 199. What is the total head movement (in number of cylinders) incurred while servicing
these requests for each of the following disk scheduling algorithms:
22
i.FCFS ii. SSTF iii. SCAN iv. LOOK v. C-LOOK

i.FCFS(First Come First Serve)


• FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS, the requests

Course Code : 18CSC205J Page No. 5 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

are addressed in the order they arrive in the disk queue.

• Total head movements using FCFS= [(98 – 53) + (183 – 98) + (183 – 41) + (122 – 41)
+ (122 – 14) + (124 – 14) + (124 – 65) + (67 – 65)]
• = 45 + 85 + 142 + 81 + 108 + 110 + 59 + 2
• =632
ii. SSTF(Shortest Seek Time First)
• Shortest Seek Time First (SSTF) selects the request with the minimum seek time
from the current head position

iii. SCAN
• The disk arm starts at one end of the disk, and moves toward the other end, servicing
requests until it gets to the other end of the disk, where the head movement is reversed
and servicing continues.
• SCAN algorithm Sometimes called the elevator algorithm

Course Code : 18CSC205J Page No. 6 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

iv. LOOK

• It is similar to the SCAN disk scheduling algorithm except for the difference that the
disk arm in spite of going to the end of the disk goes only to the last request to be
serviced in front of the head and then reverses its direction from there only. Thus it
prevents the extra delay which occurred due to unnecessary traversal to the end of the
disk.

v. C-LOOK
• In CLOOK, the disk arm in spite of going to the end goes only to the last request to be
serviced in front of the head and then from there goes to the other end’s last request.
Thus, it also prevents the extra delay which occurred due to unnecessary traversal to
the end of the disk.
head is initially at cylinder number 53. The cylinders are numbered from 0 to 199

Total Head Movement using C-LOOK=[(65-53)+(67-65)+(98-67)+(122-98)+(124-


122)+(183-124)+(183-14)+

Course Code : 18CSC205J Page No. 7 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

(41-14)]
= 12+2+31+24+2+59+169+27)=326

b) Explain the File system implementation and Directory implementation.

File-System Implementation
• Types - On-disk and in-memory structures 3
• On Disk Data Structures
✓ Boot Control Block - Boot Control Block contains all the information which is
needed to boot an operating system from that volume. It is called boot block in
UNIX file system. In NTFS, it is called the partition boot sector.
✓ Volume Control Block - Volume control block all the information regarding that
volume such as number of blocks, size of each block, partition table, pointers to free
blocks and free FCB blocks. In UNIX file system, it is known as super block. In
NTFS, this information is stored inside master file table.
✓ Directory Structure (per file system) -A directory structure (per file system) contains
file names and pointers to corresponding FCBs.
✓ File Control Block - File Control block contains all the details about the file such as
ownership details, permission details, file size,etc. In UFS, this detail is stored in
inode.
• In-Memory File System Structures 3
✓ The in-memory data structures are used for file system management as well as
performance improvement via caching. This information is loaded on the mount time
and discarded on ejection.

✓ Virtual File Systems


Virtual File Systems, VFS, provide a common interface to multiple different
filesystem types. In addition, it provides for a unique identifier ( vnode ) for files
across the entire space, including across all filesystems of different types. ( UNIX

Course Code : 18CSC205J Page No. 8 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

inodes are unique only across a single filesystem, and certainly do not carry across
networked file systems. )
The VFS in Linux is based upon four key object types:
o The inode object, representing an individual file
o The file object, representing an open file.
o The superblock object, representing a filesystem.
o The dentry object, representing a directory entry.

Directory Implementation
Directories need to be fast to search, insert, and delete, with a minimum of wasted disk space.

Linear List – 2 Marks


• A linear list is the simplest and easiest directory structure to set up, but it does have
some drawbacks.
• Finding a file ( or verifying one does not already exist upon creation ) requires a
linear search.
• Deletions can be done by moving all entries, flagging an entry as deleted, or by
moving the last entry into the newly vacant position.
• Sorting the list makes searches faster, at the expense of more complex insertions and
deletions.
• A linked list makes insertions and deletions into a sorted list easier, with overhead for
the links.
• More complex data structures, such as B-trees, could also be considered.

Hash Table – 2 Marks


• A hash table can also be used to speed up searches.
• Hash tables are generally implemented in addition to a linear or other structure

Course Code : 18CSC205J Page No. 9 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

a) Consider a reference string: 4, 7, 6, 1, 7, 6, 1, 2, 7, 2. the number of frames in the memory


is 3. Find out the number of page faults respective to:
1. Optimal Page Replacement Algorithm ( 5 Marks):

Number of Page Faults = 5 10

2. FIFO Page Replacement Algorithm ( 5 Marks):

23

Number of Page Faults in FIFO = 6

b)Explain the various Directory structure with advantages and disadvantages.


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
2. Two-level directory
3. Tree-structured directory
4. Acyclic graph directory
5. General graph directory structure
2
Single level Directory Structure
• 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.

Course Code : 18CSC205J Page No. 10 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

2
Two-level directory
• 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.

2
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

Course Code : 18CSC205J Page No. 11 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

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.

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.

Course Code : 18CSC205J Page No. 12 of 13 Signature of the Faculty


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY, RAMAPURAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Course Code : 18CSC205J Page No. 13 of 13 Signature of the Faculty

You might also like