0% found this document useful (0 votes)
42 views15 pages

IA3 Question Bank & Answers

The document discusses demand paging and page replacement algorithms. It contains questions and answers about demand paging, how it affects performance, calculating page faults using different algorithms, file systems and operations. Key topics covered include valid-invalid bits, page fault handling, FIFO, optimal and LRU page replacement.
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)
42 views15 pages

IA3 Question Bank & Answers

The document discusses demand paging and page replacement algorithms. It contains questions and answers about demand paging, how it affects performance, calculating page faults using different algorithms, file systems and operations. Key topics covered include valid-invalid bits, page fault handling, FIFO, optimal and LRU page replacement.
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/ 15

IA3 QUESTION BANK & ANSWERS

Q.No.01.Explain demand paging in detail.


A demand paging is similar to paging system with swapping when we want to execute a
process we swap the process the in to memory otherwise it will not be loaded in to memory.
 Basic concept: Instead of swapping the whole process the pager swaps only the necessary
pages in to memory. Thus it avoids reading unused pages and decreases the swap time and
amount of physical memory needed.
 The valid-invalid bit scheme can be used to distinguish between the pages that are on the
disk and that are in memory.
With each page table entry a valid–invalid bit is associated
(v ⇒ in-memory, i⇒not-in-memory)
Initially valid–invalid bit is set to i on all entries
 During address translation, if valid–invalid bit in page table entry is i ⇒ page fault.
 If the bit is valid then the page is both legal and is in memory.
 If the bit is invalid then either page is not valid or is valid but is currently on the disk.
 Marking a page as invalid will have no effect if the processes never access to that page.
Suppose if it access the page which is marked invalid, causes a page fault trap. This may
result in failure of OS to bring the desired page in to memory

Q.No.02. With the supporting diagram explain the steps involved in handling page fault.
Steps in Handling a Page Fault
1. The memory address requested is first checked, to make sure it was a valid memory request.
2. If the reference is to an invalid page, the process is terminated. Otherwise, if the page is not
present in memory, it must be paged in.
3. A free frame is located, possibly from a free-frame list.
4. A disk operation is scheduled to bring in the necessary page from disk.
5. After the page is loaded to memory, the process's page table is updated with the new frame
number, and the invalid bit is changed to indicate that this is now a valid page reference.
6. The instruction that caused the page fault must now be restarted from the beginning.

Q.No.3. Describe how the demand paging affects system performance


Demand paging can significantly affect the performance of a computer-system.
• Let p be the probability of a page-fault (0≤p ≤1), If p = 0, no page-faults.
If p = 1, every reference is a fault.
• Effective access time(EAT)=[(1 - p) *memory access]+ [p *page-fault time]
• To compute the effective access time, we must know how much time is needed to
service a page fault.
• A page-fault causes the following events to occur :
1)Trap to the OS.
2) Save the user-registers and process-state.
3) Determine that the interrupt was a page-fault. '
4) Check that the page-reference was legal and determine the location of the page on
the disk.
5) Issue a read from the disk to a free frame:
a. Wait in a queue for this device until the read request is serviced.
b. Wait for the device seek time.
c. Begin the transfer of the page to a free frame.
6) While waiting, allocate the CPU to some other user.
7) Receive an interrupt from the disk I/O subsystem (I/O completed).
8) Save the registers and process-state for the other user (if step 6 is executed).
9) Determine that the interrupt was from the disk.
10) Correct the page-table and other tables to show that the desired page is now in memory.
11) Wait for the CPU to be allocated to this process again.
12) Restore the user-registers, process-state, and new page-table, and then resume the
interrupted instruction.

In any case, we are faced with three major components of the page-fault service time:
1. Service the page-fault interrupt.
2.Read in the page.
3. Restart the process.
• The first and third tasks can be reduced, with careful coding, to several hundred
instructions.
• Consider: - average page-fault service time : 8 milliseconds , memory-access time :
200 nanoseconds, the effective access time in nanoseconds is effective access time
EAT = (1 - p) x (200) + p (8 milliseconds)
= (1 - p) x 200 + p x 8,000,000
= 200 + 7,999,800 x p
• the effective access time is directly proportional to the page-fault rate.
Q.No.4. For the following page reference string 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1
Calculate no of page faults using FIFO, Optimal page replacement and LRU

FIFO: A FIFO replacement algorithm associates each page the time when that page was brought
into memory. when a Page is to be replaced the oldest one is selected.

There are 15-page faults

Optimal Page Replacement: “Replace the page that will not be used for the longest period of
time”
Least Recently Used: The LRU (Least Recently Used) algorithm, predicts that the page that has not
been used in the longest time is the one that will not be used again in the near future.

Q.No.05. What is file? Explain the various file operations and attributes.

A file is a named collection of related information that is recorded on secondary storage. The
information in a file is defined by its creator. Many different types of information may be stored in a
file source programs, object programs, executable programs, numeric data, text, payroll records,
graphic images, sound recordings, and so on.

A file's attributes vary from one operating system to another but typically consist of these:

Name: The symbolic file name is the only information kept in human readable form.

Identifier: This unique tag, usually a number, identifies the file within the file system; it is the non-
human-readable name for the file.

Type: This information is needed for systems that support different types of files.

Location: This information is a pointer to a device and to the location of the file on that device.

Size: The current size of the file (in bytes, words, or blocks) and possibly the maximum allowed size
are included in this attribute.

Protection: Access-control information determines who can do reading, writing, executing, and so
on.

Time, date, and user identification: This information may be kept for creation, last modification,
and last use. These data can be useful for protection, security, and usage monitoring.

File Operations

A file is an abstract data type. To define a file properly, we need to consider the operations that can
be performed on files.

Creating a file:Two steps are necessary to create a file,

Space in the file system must be found for the file.

An entry for the new file must be made in the directory.


Writing a file:To write a file, we make a system call specifying both the name of the file and the
information to be written to the file. Given the name of the file, the system searches the directory to
find the file's location. The system must keep a write pointer to the location in the file where the next
write is to take place. The write pointer must be updated whenever a write occurs.

Reading a file:To read from a file, we use a system call that specifies the name of the file and where
the next block of the file should be put. Again, the directory is searched for the associated entry, and
the system needs to keep a read pointer to the location in the file where the next read is to take place.
Once the read has taken place, the read pointer is updated.

Repositioning within a file:The directory is searched for the appropriate entry, and the current-file-
position pointer is repositioned to a given value. Repositioning within a file need not involve any
actual I/0. This file operation is also known as files seek.

Deleting a file:To delete a file, search the directory for the named file. Having found the associated
directory entry, then release all file space, so that it can be reused by other files, and erase the directory
entry.

Truncating a file:The user may want to erase the contents of a file but keep its attributes. Rather
than forcing the user to delete the file and then recreate it, this function allows all attributes to remain
unchanged but lets the file be reset to length zero and its file space released.

Q.No.06. Explain various file access methods.


Sequential methods:The simplest access method is sequential methods. Information in the file is
processed in order, one record after the other.Reads and writes make up the bulk of the operations
on a file.

A read operation (next-reads) reads the next portion of the file and automatically advances a file
pointer, which tracks the I/O location

The write operation (write next) appends to the end of the file and advances to the end of the newly
written material.

A file can be reset to the beginning and on some systems, a program may be able to skip forward or
backward n records for some integer n-perhaps only for n =1.

Eg: Magnetic tape

Direct Access

 A file is made up of fixed length logical records that allow programs to read and write
records rapidly in no particular order.
 The direct-access method is based on a disk model of a file, since disks allow random
access to any file block. For direct access, the file is viewed as a numbered sequence of
blocks or records.
 Example: if we may read block 14, then read block 53, and then write block 7. There are no
restrictions on the order of reading or writing for a direct-access file.
 Direct-access files are of great use for immediate access to large amounts of information
such as Databases, where searching becomes easy and fast.

Eg: Magnetic disk. HDD


Other Methods: These methods generally involve the construction of an index for the file.The
Index, is like an index in the back of a book contains pointers to the various blocks. To find a
record in the file, we first search the index and then use the pointer to access the file directly and to
find the desired record.

Q.No.7. Explain the various types of directory structures.


The most common schemes for defining the logical structure of a directory are described below.

1. Single-level Directory

 The simplest directory structure is the single-level directory. All files are contained in the
same directory, which is easy to support and understand
 A single-level directory has significant limitations, when the number of files increases or
when the system has more than one user.

2. Two-Level Directory

In the two-level directory structure, each user has its own user file directory (UFD). The UFDs have
similar structures, but each lists only the files of a single user.

When a user refers to a particular file, only his own UFD is searched. Different users may have files
with the same name, as long as all the file names within each UFD are unique.
To create a file for a user, the operating system searches only that user's UFD to a scertain whether
another file of that name exists. To delete a file, the operating system confines its search to the local
UFD thus; it cannot accidentally delete another user's file that has the same name.

3.Tree Structured Directories: A tree is the most common directory structure.

 The tree has a root directory, and every file in the system has a unique path name.
 A directory contains a set of files or subdirectories. A directory is simply another file, but it
is treated in a special way.
 All directories have the same internal format. One bit in each directory entry defines the
entry as a file (0) or as a subdirectory (1). Special system calls are used to create and delete
directories.

4..Acyclic Graph Directories

 The common subdirectory should be shared. A shared directory or file will exist in the file
system in two or more places at once. A tree structure prohibits the sharing of files or
directories.
 An acyclic graph is a graph with no cycles. It allows directories to share subdirectories and
files.
 The same file or subdirectory may be in two different directories. The acyclic graph is a
natural generalization of the tree-structured directory scheme.
5.General Graph Directory

 Cycles are allowed here


 Problem: With cycles, the reference-count may be non-zero even when it is no longer possible
to refer to a directory (or file). (A value of 0 in the reference count means that there are no
more references to the file or directory, and the file can be deleted).
 Solution: Garbage-collection scheme can be used to determine when the last reference has
been deleted.

Q.N0.08. write a short note on thrashing


The process continues to fault, replacing pages for which it then faults and brings back. This high
paging activity is called thrashing. The phenomenon of excessively moving pages back and forth
b/w memory and secondary has been called thrashing
As the degree of multi programming increases, more slowly until a maximum is reached. If the
degree of multi programming is increased further thrashing sets in and the CPU utilization drops
sharply.

At this point, to increases CPU utilization and stop thrashing, we must increase degree of
multiprogramming.

we can limit the effect of thrashing by using a local replacement algorithm. To prevent thrashing,
we must provide a process as many frames as it needs

Locality of Reference:

 As the process executes it moves from locality to locality.

 A locality is a set of pages that are actively used.

 A program may consist of several different localities, which may overlap.

 Locality is caused by loops in code that find to reference arrays and other
data structures by indices.

The ordered list of page number accessed by a program is called reference string

Q.No.9. Give the difference between global V/S local allocations


Q.No.10. Illustrate access matrix with an example.
The rows of the access matrix represent domains, and the columns represent objects.
Each entry in the matrix consists of a set of access rights.

The entry access (i, j) defines the set of operations that a process executing in domain Di can
invoke on object Oj.

In the above diagram, there are four domains and four objects—three files (F1, F2, F3) and one
printer. A process executing in domain D1 can read files F1 and F3. A process executing in
domain D4 has the same privileges as one executing in domain D1; but in addition, it can also
write onto files F1 and F3.

When a user creates a new object Oj, the column Oj is added to the access matrix with the
appropriate initialization entries, as dictated by the creator.

The process executing in one domain and be switched to another domain. When we switch a
process from one domain to another, we are executing an operation (switch) on an object (the
domain).

Q.No.11. Describe access matrix implementation methods


Different methods of implementing the access matrix (which is sparse)
 Global Table
 Access Lists for Objects
 Capability Lists for Domains
 Lock-Key Mechanism
1.Global Table
 This is the simplest implementation of access matrix.
 A set of ordered triples <domain, object, rights-set> is maintained in a file. Whenever
an operation M is executed on an object Oj, within domain Di, the table is searched
for a triple <Di, Oj, Rk>. If this triple is found, the operation is allowed to continue;
otherwise, an exception (or error) condition is raised.
2.Access Lists for Objects
 Each column in the access matrix can be implemented as an access list for one object.
The empty entries are discarded. The resulting list for each object consists of ordered
pairs <domain, rights-set>.
 It defines all domains access right for that object. When an operation M is executed
on object Oj in Di, search the access list for object Oj, look for an entry <Di, RK > with
M ϵ Rk. If the entry is found, we allow the operation; if it is not, we check the default
set. If M is in the default set, we allow the access. Otherwise, access is denied, and an
exception condition occurs. For efficiency, we may check the default set first and then
search the access list.
3.Capability Lists for Domains

 A capability list for a domain is a list of objects together with the operations allowed
on those objects. An object is often represented by its name or address, called a
capability.
 To execute operation M on object Oj, the process executes the operation M, specifying
the capability for object Oj as a parameter. Simple possession of the capability means
that access is allowed.
Capabilities are distinguished from other data in one of two ways:
1. Each object has a tag to denote its type either as a capability or as accessible data.
2. The address space associated with a program can be split into two parts. One part is
accessible to the program and contains the program's normal data and instructions.
The other part, containing the capability list, is accessible only by the operating
system.
4. A Lock-Key Mechanism
 The lock-key scheme is a compromise between access lists and capability lists.
 Each object has a list of unique bit patterns, called locks. Each domain has a list of
unique bit patterns, called keys.
 A process executing in a domain can access an object only if that domain has a key
that matches one of the locks of the object.
Q.No.12. Differentiate between equal and proportional allocation

Q.No.13. What are the goals of protection?


 Protection is a mechanism for controlling the access of programs, processes, or users to the
resources defined by a computer system. Protection ensures that only processes that have
gained proper authorization from the operating system can operate on the files, memory
segments, CPU, and other resources of a system.

 Protection is required to prevent mischievous, intentional violation of an access restriction by


a user

Q.No.14. Explain the following disk scheduling algorithms also calculate seek time and
disk rotations for the following queue.: 98 183 37 122 14 124 65 67
i) FCFS ii) SSTF iii) SCAN iv) Look
Ans: FCFS

SSTF

SCAN
(LooK refer class notes)

Q.No.16. Describe with a neat diagram the components of Linux operating system
Ans.Components of a Linux System
Linux is composed of three main bodies of code; the most important distinction between the
kernel and all other components.
1. The kernel is responsible for maintaining the important abstractions of the operating
system.
 Kernel code executes in kernel mode with full access to all the physical resources of
the computer.
 All kernel code and data structures are kept in the same single address space.

2. The system libraries define a standard set of functions through which applications interact
with the kernel, and which implement much of the operating-system functionality that does
not need the full privileges of kernel code.

3. System utilities. The system utilities are programs that perform individual, specialized
management tasks. Some system utilities may be invoked just once to initialize and configure some
aspect of the system. others known as daemons in UNIX terminology may run permanently, handling
such tasks as responding to incoming network connections, accepting logon requests from terminals,
and updating log files.

Figure illustrates the various components that make up a full Linux system.

Three components to Linux module support:


 Module management
 Driver registration
 Conflict resolution

Module Management
 Supports loading modules into memory and letting them talk to the rest of the kernel.
 Module loading is split into two separate sections:
 Managing sections of module code in kernel memory
 Handling symbols that modules are allowed to reference
Driver Registration

 Allows modules to tell the rest of the kernel that a new driver has become available.
 The kernel maintains dynamic tables of all known drivers, and provides a set of routines to
allow drivers to be added to or removed from these tables at any time.
Registration tables include the following items:

 Device drivers
 File systems
 Network protocols
 Binary format

Conflict Resolution

A mechanism that allows different device drivers to reserve hardware resources and to
protect those resources from accidental use by another driver
The conflict resolution module aims to:

 Prevent modules from clashing over access to hardware resources


 Prevent auto probes from interfering with existing device drivers
 Resolve conflicts with multiple drivers trying to access the same hardware

You might also like