OS Micro 2022 Final Exam Worksheet
OS Micro 2022 Final Exam Worksheet
each
topic:
Introduction
o What is an operating system, Early Systems, Simple Batch Systems,
Multiprogramming, Batched Systems, Time-Sharing Systems, Personal-Computer
Systems, Parallel Systems, Distributed Systems, Real-Time Systems.
Hardware Structures
o Computer-System Operation, I/O Structure, Storage Structure, Storage Hierarchy,
Hardware Protection, General System Architecture.
Operating System Structures
o System Components, Operating-System Services, System Calls, System Programs,
System Structure, Virtual Machines, System Design and Implementation, System
Generation
Processes
o Process Concepts, Process Scheduling, Operation on Processes, Cooperating Processes,
Threads, Interposes Communication
CPU Scheduling
o Basic Concepts, Scheduling Criteria, Scheduling Algorithms, Multiple-Processor
Scheduling, Real-Time Scheduling, Algorithm Evaluation.
Synchronization
o Background, The Critical-Section Problem, Synchronization Hardware, Semaphores,
Classical Problems of Synchronization, Critical Regions, Monitors.
Deadlocks
System Model, Deadlock Characterization, Methods for Handling Deadlocks, Deadlock
Prevention, Deadlock Avoidance, Deadlock Detection, Recovery from Deadlock, Combined
Approach to Deadlock Handling.
Memory Management (Actual Lecture from Tanebaum - chapter 4)
Background, Logical versus Physical Address Space, Swapping, Contiguous Allocation,
Paging, Segmentation, Segmentation with Paging.
File Systems
Concepts, Access Methods, Directory Structure, Protection, Consistency Semantics, File-
System Structure, Allocation Methods, Free-Space Management, Directory Implementation,
Efficiency and Performance, Recovery.
Secondary Storage Structure
Disk Structure, Disk Scheduling, Disk Management, Swap-Space Management, Disk
Reliability, Stable-Storage Implementation.
Protection and Security
Goals of Protection, Domain of Protection, Access Matrix, The Security Problem,
Authentication, Program Threats, System Threats, Threat Monitoring, Encryption
///////////////
True / False
1
1. Management of I/O devices is a very important part of the operating system - so important and
so varied that entire I/O subsystems are devoted to its operation.
2. Device drivers are modules that can be plugged into an OS to handle a particular device or
category of similar devices.
3. Devices communicate with the computer via signals sent over wires or through the air.
4. Interrupts allow devices to notify the CPU when they have data to transfer or when an
operation is complete, allowing the CPU to perform other duties when no I/O transfers need its
immediate attention.
5. At boot time the system determines which devices are present, and loads the appropriate
handler addresses into the interrupt table.
6. During operation, devices signal errors or the completion of commands via interrupts.
7. I/O devices can be roughly categorized as storage, communications, user-interface, and other
8. All I/O requests are handled through system calls that must be performed in kernel mode.
9. User applications are allowed to perform I/O in user mode.
10. There are 3 types of users in Linux (Regular, Administrative(root) and Service users) whereas,
in Windows, there are 4 types of user accounts (Administrator, Standard, Child and Guest).
11. An address generated by the CPU is commonly referred to as a logical address.
12. Linux runs faster even with older hardware whereas Windows are slower compared to
Linux.
13. The size of pages and frames are same in logical memory and physical memory respectively.
14. Cache is non-volatile memory.
15. A condition where a set of blocked processes each holding a resource and waiting to acquire a
resource held by another process in the set is termed as Deadlock.
16. A synchronous device is one that performs data transfers with predictable response times.
17. An asynchronous device exhibits irregular or unpredictable response times.
2
divides logical address space of process into paging
fixed-size
pieces
timestamps In Unix, Linux, and Windows file Creation, modification, and access
systems which are associated with each file.
It can run multiple OS on same machine at virtual machines
same time
Examples of file meta-data (i.e., file attributes) File size, owner, type, permissions, date, inode
that are maintained number
in a typical file system (e.g., Linux or
Windows).
an abstracted view above the file system virtual file system
interface, allowing
the same file system API to be used whether
files are stored locally
or remotely.
Old memory management techniques Overlays
where the memory should contain only those
instructions and data that are required at a
given time
Scheduling activity done by operating systems I/O or Disk scheduling
to schedule I/O requests arriving for disk.
Types of Disk Scheduling Algorithms that FCFS, SSTF, SCAN, CSCAN, LOOK,
improves the effective bandwidth, the average CLOOK
response time, and strategies for disk queue
ordering.
3
ways to access a file into a computer system Sequential-Access, Direct Access, Index
sequential Method.
I/O devices categories Block device, Character device, Network
device
It lets you manage smartphones, tablets, Mobile Device Management (MDM) software
laptops, desktops, TVs, and rugged devices
and multiple operating systems such as
Android, iOS, iPadOS, tvOS, macOS,
Windows, and Chrome OS.
File Access Methods in Operating System Sequential Access, Direct Access, and Index
sequential method
files systems can be sued with Linux ext* family (ext, ext2, ext3 and ext4) and XFS.
files systems can be sued with Windows FAT (File Allocation Table) and NTFS (New
Technology File system).
Authentication methods MAC, Digital Signature,
Hash Functions
formatting done at factory that files the disk Physical formatting or low level formatting.
with a special data structure for each Sector
//////////////////////
The set of all physical addresses corresponding to the logical addresses is a ---------------- of the
process
4
B. Deadlock detection
C. Deadlock prevention
D. Deadlock removal
If a process continues to fault, replacing pages, for which it then faults and brings back in right away.
This high
paging activity is called ___________.
A. paging
B. thrashing
C. page fault
D. CPU utilization
Utilities used for system administration (halt, ifconfig, fdisk, etc.) are stored in _____________
directory.
A. /dev
B. /boot
C. /lib
5
D. /sbin
rm and [r]mkdir commands are used to _____________ directory.
A. Create
B. Move
C. Remove
D. Modify
Files that start with a -------- in UNIX/Linux directory structure are known as hidden files .
A. . (dot)
B. # ( hash )
C. / (slash)
D. ~ (tilt)
____ command display the status of a process.
E. ls
F. ps
G. gcc
H. cat
In _____________ page replace algorithm we will replace the page that has not been used for the
longest
period of time.
A. counter based
B. Least Frequently Used
C. FIFO
D. LRU
When the process tries to access locations that are not in memory, the hard traps the operating system.
This is called as_______.
A. Page fault
B. Page replacement
C. Paging
D. hit
--------------refers to the situation when free memory space exists to load a process in the memory but
the space
is not contiguous.
A. Segmentation
B. Internal fragmentation
C. Swapping
D. External Fragmentation
When the address used in a program gets converted to an actual physical RAM address, it is called ----
-------
A. Execution
B. Loading
C. Address Binding
D. Compiling
6
The run-time mapping from virtual to physical address is done by a piece of hardware in the CPU,
called the
_______
A modification of free-list approach in free space management is to store the addresses of n free
blocks in the first free block. Known as ______.
A. counting
B. linked list
C. bit vector
D. grouping
With the FIFO page replacement policy, and enough space for storing 3 page frames, the memory
page reference string ‘ABCABDDCABCD’ would produce:
(a) 5 page faults
(b) 6 page faults
(c) 7 page faults
(d) 8 page faults
In which of the following directory does the configuration files are present?
A. /etc
B. /bin
C. /sbin
D. /root
Where is the user password stored?
A. /etc/password
B. /etc/passwd.
C. /user/password..
D. /root/password.
7
Given four page frames and the memory reference string 06514505365523235226, show what will be
in each page frame after each reference using the following page replacement algorithms. Circle each
page at the point that it is brought into memory because of a page fault.
8
Disk Scheduling Algorithms:
1. FCFS: FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS, the requests are
addressed in the order they arrive in the disk queue.
2. SSTF: In SSTF (Shortest Seek Time First), requests having shortest seek time are executed
first. So, the seek time of every request is calculated in advance in a queue and then they are
scheduled according to their calculated seek time. As a result, the request near the disk arm
will get executed first.
3. SCAN: In SCAN algorithm the disk arm moves into a particular direction and services the
requests coming in its path and after reaching the end of the disk, it reverses its direction and
again services the request arriving in its path. So, this algorithm works like an elevator and
hence also known as elevator algorithm.
4. CSCAN: In SCAN algorithm, the disk arm again scans the path that has been scanned, after
reversing its direction. So, it may be possible that too many requests are waiting at the other
end or there may be zero or few requests pending at the scanned area.
5. 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.
9
6. CLOOK: As LOOK is similar to SCAN algorithm, in a similar way, CLOOK is similar to
CSCAN disk scheduling algorithm. 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.
What are the different types of computer buses commonly found in a modern PC?
Currently, hard drives are divided into 4 major types: hard drive technologoes
They are two main types of devices under all Unix systems:
10
A Character ('c') Device is one with which the Driver communicates by sending and receiving
single characters (bytes, octets).
A Block ('b') Device is one with which the Driver communicates by sending entire blocks of data.
Examples for Character Devices: serial ports, parallel ports, sounds cards.
Examples for Block Devices: hard disks, USB cameras, Disk-On-Key.
When we want to load the page on the memory, and the page is already available on memory, then it is
called page hit.
a process is copied into the main memory from the secondary memory
a) Swapping
b) Paging
c) Segmentation
d) Demand paging
11
12
13
14
15
FILE-SYSTEM INTERFACE
File Concept
Access Methods
Directory Structure
Protection
File Concept
Contiguous logical address space
Types:
o Data
numeric
character
binary
o Program
source
object (load image)
o Documents
File Structure
None - sequence of words, bytes
Simple record structure
o Lines
o Fixed length
o Variable length
Complex Structures
o Formatted document
o Relocatable load file
Can simulate last two with first method by inserting appropriate control characters.
Who decides:
16
o Operating system
o Program
File Attributes
o Name - only information kept in human readable form.
o Type - needed for systems that support different types.
o Location - pointer to file location on device.
o Size - current file size.
o Protection - controls who can do reading, writing, executing.
o Time, date, and user identification - data for protection, security, and
usage monitoring.
Information about files are kept in the directory structure, which is maintained on
the disk.
File Operations
create
write
read
reposition within file - file seek
delete
truncate
Access Methods
Sequential Access
Direct Access
Directory Structure - a collection of nodes containing
information about all files.
If A deletes D => dangling pointer.
Solutions:
o Backpointers, so we can delete all pointers. Variable size records a
problem.
o Backpointers using a daisy chain organization.
o Entry-hold-count solution.
General Graph Directory
How do we guarantee no cycles?
o Allow only links to file not subdirectories.
o Garbage collection.
o Every time a new link is added use a cycle detection algorithm to
determine whether it is OK.
Protection
File owner/creator should be able to control:
o what can be done
o by whom
Types of access
o Read
o Write
17
o Execute
o Append
o Delete
o List
Access Lists and Groups
Mode of access: read, write, execute
Three classes of users
RWX
a) owner access 7 => 1 1 1
RWX
b) group access 6 => 1 1 0
RWX
c) public access 1 => 0 0 1
Ask manager to create a group (unique name), say G , and add some users to the
group.
For a particular file (say game) or subdirectory, define an appropriate access.
chmod 761 game
FILE-SYSTEM IMPLEMENTATION
File-System Structure
Allocation Methods : Contiguous, Linked Allocation - each file is a linked list of disk. Indexed
Allocation - brings all pointers together into the index block.
Free-Space Management : 1. Bit vector (n blocks) , Linked list (free list), Grouping,Counting
Directory Implementation
Efficiency and Performance
Recovery
Access control, that is, deciding if a particular operation is to be allowed or not, is performed
by the file server when a user opens a file, walks a directory, and tries to modify its
entries (including creating and removing files).
access control lists, that determine which operations can be performed on which file.
18
is a collection of access ' rights, each of which is an ordered pair <objectname,
rights-set>.
The binding of instructions and data to memory addresses can be done at any
step along the way:
Compile time: If it is known at compile time where the process will reside
in memory, then absolute code can be generated.
Load time: If it is not known at compile time where the process will reside
in memory, then the compiler must generate re-locatable code.
Execution time: If the process can be moved during its execution from one
memory segment to another, then binding must be delayed until run time.
Deadlock prevention is a set of methods for ensuring that at least one of the
necessary condition cannot hold.
A state is safe if the system can allocate resources to each process (up to its
maximum) in some order and still avoid a deadlock.
Polling is a process by which a host waits for controller response. It is a looping process, reading
the status register over and over until the busy bit of status register becomes clear.
19
the data transfer rates.
2. Application: Different devices have different use in the system.
3. Complexity of Control: A disk is much more complex whereas printer
requires simple control interface.
4. Unit of transfer: Data may be transferred as a stream of bytes or characters
or in larger blocks.
5. Data representation: Different data encoding schemes are used for different
devices.
6. Error Conditions: The nature of errors differs widely from one device to
another.
The basic hardware elements involved in I/O buses, device controllers, and
the device themselves. The work of moving data between devices and main
memory is performed by the CPU as programmed I/O or is offloaded to a DMA
controller. The kernel module that controls a device driver.
Device Controllers
A computer system contains a multitude of I/O devices and their respective
controllers:
● network card
● graphics adapter
● disk controller
● DVD-ROM controller
● serial port
● USB
● sound card
20
Logical Formatting
After disk is partitioned, logical formatting used.
Operating system stores the initial file system data structures onto the disk.
Swap space management is low level task of the operating system. The main
goal for the design and implementation of swap space is to provide the best
throughput for the virtual memory system.
Disk drives are the major secondary storage I/O devices on most computers.
Most secondary devices are either magnetic disks or magnetic tapes. Modern disk
drives are structured as large one dimensional arrays of logical disk blocks. Disk
scheduling algorithms can improve the effective bandwidth, the average response
time, and the variance response time. Algorithms such as SSTF, SCAN, C-SCAN.
LOOK, and CLOOK are designed to make such improvements through strategies
for disk queue ordering.
A buffer is a memory area that stores data while they are transferred between
two devices or between a device and an application. Buffering is done for
three reasons.
One reason is to cope with a speed mismatch between the producer and
consumer of a data stream.
Second buffer while the first buffer is written to disk. A second use of
buffering is to adapt between devices that have different data transfer sizes.
A third use of buffering is to support copy semantics for application I/O.
A cache is region of fast memory that holds copies of data. Access to the
cached copy is more efficient than access to the original.
Caching and buffering are two distinct functions, but sometimes a region of
memory can be used for both purposes.
I/O system calls are costly in terms of CPU consumption because of the many
layers of software between a physical device and an application. To schedule a set of I/O requests
means to determine a good order in which
to execute them. The order in which applications issue system calls rarely is
the best choice. Scheduling can improve overall system performance, can
share device access fairly among processes, and can reduce the average
waiting time for I/O to complete. Operating-system developers implement
scheduling by maintaining a queue of requests for each device. When an
application issues a blocking I/O system call, the request is placed on the
queue for that device.
The I/O scheduler rearranges the order of the queue to improve the overall
system efficiency and the average response time experienced by
applications.
To schedule a set of I/O requests means to determine a good order in which
to execute them. The order in which applications issue system calls rarely is
the best choice. Scheduling can improve overall system performance, can
share device access fairly among processes, and can reduce the average
waiting time for I/O to complete. Operating-system developers implement
21
scheduling by maintaining a queue of requests for each device. When an
application issues a blocking I/O system call, the request is placed on the
queue for that device.
The I/O scheduler rearranges the order of the queue to improve the overall
system efficiency and the average response time experienced by
applications.
Sequential or random-access. A sequential device transfers data in a fixed order
that is determined by the device, whereas the user of a random-access device can
instruct the device to seek to any of the available data storage locations.
Synchronous or asynchronous. A synchronous device is one that performs data
transfers with predictable response times. An asynchronous device exhibits
irregular or unpredictable response times.
22
23
A major security problem for operating systems is the authentication problem.
Computer not holding S(k) cannot generate authenticators on messages that can
be verified using V(k).
Since authenticators are generally exposed (for example, they are sent on the
network with the messages themselves), it must not be feasible to derive S(k)
from the authenticators.
Authentication – Hash Functions
Basis of authentication.
Creates small, fixed-size block of data (message digest, hash value) from
m.
Hash Function H must be collision resistant on m
Must be infeasible to find an m’ ≠ m such that H(m) = H(m’).
If H(m) = H(m’), then m = m‘
The message has not been modified.
Common message-digest functions include MD5, which produces a 128-bit
hash, and SHA-1, which outputs a 160-bit hash.
Authentication – MAC
Symmetric encryption used in message-authentication code (MAC)
authentication algorithm.
Simple example:
MAC defines S(k)(m) = f (k, H(m)).
Where f is a function that is one-way on its first argument.
k cannot be derived from f (k, H(m)).
Because of the collision resistance in the hash function, reasonably
assured no other message could create the same MAC.
A suitable verification algorithm is V(k)(m, a) = ( f (k,m) = a).
Note that k is needed to compute both S(k) and V(k), so anyone able to
compute one can compute the other.
24
information contained within the system. Security means to avoid:
a) Unauthorized access to the computer system.
b) Unauthorized examination of output.
c) Unauthorized tapping of data.
d) Destruction of software data by mistake or on purpose.
e) Examination of sensitive data by unauthorized users and alteration of sensitive
data without detection.
The UNIX provides the features like:
a) Password protection for system access.
b) Control access to individual files.
c) Encryption of data files.
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
■ Address generated by CPU is divided into:
■ Page number(p)
❑ used as an index into page table which contains base address of each
page in physical memory.
■ Page offset(d)
❑ combined with base address to define the physical memory address that
is sent to the memory unit.
40
41
42
Page Replacement Strategies
■ The Principle of Optimality
❑ Replace the page that will not be used again the farthest time into the
future.
43
■ Random Page Replacement
❑ Replace the page that has not been used for the longest time.
■ LFU - Least Frequently Used
❑ An approximation to LRU
■ Working Set
44
45
46
47
48
49
50
51
52
53
Bit map => 0 not free 1 is free
Link every free space one block to the next
Grouping “ the start and ending maintained
Counting: idexed block used which maintain all blocks with number and i.e 1 block maintain all free
block infon
54
55
56
PTBR: page table base register
PTE:page table entry
57
Effective memory access time
58
59
60
61
Always any first time fault occurs and placed on frame and replaced with optimal rep algorithm after
each fault ….
62
63
64
65
66
z
67
68
69
70
Chipset 1-ROM ,CS2 RAM …. 128*8..128 address ,8bits -1Word length /data lines bidirectional ,
Read operation :from RAM->cpu, Write: from cpu->RAM
There is chipset, decoder and dataline operation
71
72
List and discuss the Memory manger functions ?
73
Discuss Goals of Memory management and types of fragmentation?
74
List and Discuss the memory management techniques?
Mounting makes file systems, files, directories, devices, and special files available for use at a
particular location. Mount point is the actual location from which the file system is mounted and
accessed.
There are types of mounts:
Remote mount
Local mount
75
1. Deadlock prevention: is a set of methods for ensuring that at least one of the necessary conditions
cannot hold. These methods prevent deadlocks by constraining how processes can request for
resources.
2. Deadlock Avoidance: This method of handling deadlocks requires that processes give advance
additional information concerning which resources they will request and use during their lifetimes.
With this information, it may be decided whether a process should wait or not.
The compile time and load time binding methods generate identical logical and physical addresses,
where as the execution time binding method results in different physical and logical addresses. In this
case we refer to the logical address as the virtual address. The set of all logical addresses generated
by a program form the logical address space of a process; the set of all physical addresses
corresponding to these logical addresses is a physical address space of the process. The total size of
physical address space in a system is equal to the size of its main memory.
The run-time mapping from virtual to physical addresses is done by a piece of hardware in the CPU,
called the memory management unit (MMU).
What steps are needed for page replacement? (5)
Answer:-
1. Find the location of the desired page on the disk
2. Find a free frame
a) If there is a free frame use it.
b) If there is no free frame, use a page replacement algorithm to select a victim frame.
3. Read the desired page into the newly freed frame; change the page and frame tables.
4. Restart the user process.
76
File system must keep track of free blocks on disk. Write down the two Schemes used for it with
example?
How we do memory protection in memory management?
Answer:
Using two CPU registers, specifically designed for this purpose, can provide memory protection.
These registered are:
Base register – it holds the smallest legal physical memory address for a process
Limit register – it contains the size of the process
mice, keyboards, disk drives, display adapters, USB devices, network connections, audio I/O, printers,
special devices for the handicapped, and many special-purpose peripherals.
2. List the four events that cause the execution of a piece of code in kernel:
Interrupt
Trap
System call
signal
3. How you can differentiate between external and internal fragmentation
Solution:-
77
How can you achieve memory protection in paging?
memory protection in paging is achieved by associating protection bits with each page. these bits are
associated with each page table entry and specify protection on the corresponding page.
A process is thrashing if it is spending more time paging than executing. thrashing result in severe
performance problems: low cpu utilization, high disk utilization, low utilization of other i/o devices.
78