CS3451-Introduction To Operating System (IV SEM)
CS3451-Introduction To Operating System (IV SEM)
UNIT I INTRODUCTION
Computer System - Elements and organization; Operating System Overview - Objectives and
Functions - Evolution of Operating System; Operating System Structures – Operating System
Services - User Operating System Interface - System Calls – System Programs - Design and
Implementation - Structuring methods.
PART A
1. What is an Operating System? (April/May-2023)(Nov/Dec-2024)
An operating system is a program that manages the computer hardware. It also
provides a basis for application programs and act as an intermediary between a
user of a computer and the computer hardware.
It controls and coordinates the use of the hardware among the various application
programs for the various users.
2. Mention the purpose of system calls.(April/May-2024)
System calls allow user-level processes to request services of the operating system.
3. Can traps be generated intentionally by a user program? If so, for what purpose?
A trap is a software‐generated interrupt. An interrupt can be used to signal the
completion of an I/O to obviate the need for device polling.
A trap can be used to call operating system routines or to catch arithmetic errors.
4. Mention the objectives of an operating system.
Convenience – makes computer user friendly.
Efficiency - allows computer to use resources efficiently.
Ability to evolve - constructed in a way to permit effective development, testing and
introduction of new functions without interfering with service.
5. What is SYSGEN and system boot?
The SysGen process runs as a series of jobs under the control of the operating
system.
The process of bringing up the operating system is called booting.
6. Consider a memory system with a cache access time of 10ns and a memory access
time of 110ns assumes memory access time includes the time to check the cache. If
the effective access time is 10% greater than the cache access time. What is the hit
ratio H?
Cache access time Tc = 100 ns
Memory access time Tm = 500 ns
If the effective access time is 10% greater than the cache access time, what is the hit ratio
H?
Effective access time =cache hit ratio*cache access time+ cache miss ratio
*(cache access time +main memory access time)
Effective access time =10% greater the cache access time ==>110
Increased Throughput
Economy of Scale
Increased Reliability
9. What are the advantages of peer-peer system and client server system?
Peer-Peer is easy to install
All the resources and contents are shared by all the peers without server help,
where Server shares all the contents and resources.
Peer-Peer is more reliable as central dependency is eliminated. Failure of one peer
doesn’t affect the functioning of other peers. In case of Client –Server network, if
server goes down, whole network gets affected.
Job1: 0 to 5
Job2: 5 to 10
Job3: 10 to 15
API usually provides more useful functionality than the system call.
13. Write the difference between batch systems and time-sharing systems.
This batch is submitted to batch processing operating systems, and output would
appear some later time in the form of a program or as program error.
The major task of batch operating systems is to transfer control automatically from
one job to next.
Time sharing:
Objectives:
Convenience
Efficiency
Ability to evolve
Ease of use -It provides the environment for executing the programs.
Efficient use of computer - The primary goal of an OS is the efficient use of computer
systems which is otherwise called as resource utilization.
16. Why is the Operating System viewed as a resource allocator & control program?
(Nov/Dec-2023)
A computer system has many resources that may be required to solve a problem.
Processor
Main memory
Performance
Availability
Incremental growth
Scaling
In serial processing, processor does only one process at a time. (Requests, gets it,
and fetches it). Therefore this kind of processing is slow;
While in parallel processing, CPU does more than one process at a time, so it's
faster & consumes less time.
Scheduling
Setuptime
• When one job is finished, control returns to Monitor which reads next job
They may come in the form of device-specific processors, such as disk, keyboard, and
graphics controllers.
Multiprocessor systems (also known as parallel systems or multicore systems) have two
or more processors in close communication, sharing the computer bus and sometimes
the clock, memory, and peripheral devices.
Recently, multiple processors have appeared on mobile devices such as smart phones
and tablet computers.
The ability to continue providing service proportional to the level of surviving hardware
is called graceful degradation.
Fault tolerance requires mechanism to allow the failure to be detected, diagnosed and if
possible, corrected.
30. What is Dual mode operation and what are the two type’s modes?
The dual mode operation provides us with the means for protecting the operating
system from wrong users and wrong users from one another.
31. Define System call. Give any two system calls with their purpose.( Nov/Dec-2023)
1. Process control :
These system calls are used to create, manage, and control processes. Examples
include fork(), exec(), wait(), kill(), and getpid().
2. Device manipulation :
These system calls are used to manage and manipulate I/O devices such as
printers, keyboards, and disk drives.
32. What are the various types of system calls? Give any two System Call with
purpose.
Process control
File manipulation
Device manipulation
Information maintenance
Communications
Protection.
In the shared-memory model, processes use shared memory create () and shared
memory attach () system calls to create and gain access to regions of memory owned
by other processes.
The system calls are list of the function that will be call in section between user and
kernel.
But the system program is the program that can do system works like: Change system
settings.
The main difference between multicore and multiprocessor is that the multicore refers
to a single CPU with multiple execution units while the multiprocessor refers to a
system that has two or more CPUs.
37. What is dual mode operation and what is the need of it?
The dual mode of operation provides us with the means for protecting the OS from
errant users-and errant users from one another.
A more common definition is that the OS is the one program running at all times on
the computer, usually called the kernel, with all else being application programs.
Mainframe systems are the first computers developed to tackle many commercial and
scientific applications.
These systems are developed from the batch systems and then multiprogramming
system and finally time-sharing systems.
Operators batched together jobs with similar needs and ran through the computer as a
group.
The operators would sort programs into batches with similar requirements and as
system become available, it would run each batch.
PART B
Key Points
3. Storage Structure
4. I/O Structure
Processor: Controls the operation of the computer and performs its data processing
function is shown in Fig 1.1.
Main memory: Stores data and programs. This memory is volatile. Main memory is also
called as real or primary memory.
I/O modules: Move data between the computer and its external environment including
secondary memory devices (e.g. disks), communications equipment and terminals.
System bus: Provides for communication among processors, main memory, and I/O
modules.
Program Counter (PC): It holds the address of the next instruction to be executed.
Memory Address Register (MAR): It specifies the address in memory for the next read or
write.
Memory Buffer Register (MBR): It contains the data to be written into memory or which
receives the data from memory.
I/O Buffer Register (I/O BR): It is used for the exchange of data between an I/O module
and the processor.
Memory Module consists of a bit pattern that can be interpreted as either an instruction
or data.
Each location contains a bit pattern that can be interpreted as either an instruction or
data.
I/O module transfers data from external devices to processor and memory and vice versa. It
contains internal buffer for temporarily holding data until they can be sent on.
Each device controller is in charge of a specific type of device (for example, disk drives,
audio devices, or video displays).
The CPU and the device controllers can execute in parallel, competing for memory
cycles. To ensure orderly access to the shared memory, a memory controller
synchronizes access to the memory.
It initializes all aspects of the system, from CPU registers to device controllers to
memory contents.
The occurrence of an event is usually signaled by an interrupt from either the hardware
or the software.
Hardware may trigger an interrupt at any time by sending a signal to the CPU, usually
by way of the system bus. Software may trigger an interrupt by executing a special
operation called a system call (also called a monitor call).
When the CPU is interrupted, it stops what it is doing and immediately transfers
execution to a fixed location.
3. Storage Structure
Basically, we want the programs and data to reside in main memory permanently.
This arrangement is usually not possible for the following two reasons:
o Main memory is usually too small to store all needed programs and data
permanently.
o Main memory is a volatile storage device that loses its contents when power is
turned off or otherwise lost.
Volatile Storage Device – It loses its contents when the power of the device is
removed.
Non-Volatile Storage device – It does not lose its contents when the power is removed.
It holds all the data when the power is removed.
Each storage system provides the basic system of storing a datum and of holding the
datum until it is retrieved at a later time.
All the storage devices differ in speed, cost, size and volatility.
Fig.1.3 shows that all the storage devices are arranged according to speed and cost.
The higher levels are expensive, but they are fast. As we move down the hierarchy, the
cost per bit generally decreases, whereas the access time generally increases.
The storage systems above the electronic disk are Volatile, where as those below are
Non-Volatile.
During normal operation, the electronic disk stores data in a large DRAM array, which
is Volatile.
But many electronic disk devices contain a hidden magnetic hard disk and a battery for
backup power.
If external power is interrupted, the electronic disk controller copies the data from RAM
to the magnetic disk. When external power is restored, the controller copies the data
back into the RAM.
4. I/O Structure
I/O Structure consists of Programmed I/O, Interrupt driven I/O, DMS, CPU, Memory,
External devices, these are all connected with the help of Peripheral I/O Buses and
General I/O buses.
I/O Types
Programmed I/O
Fig 1.4 shows the different types of I/O. In the programmed I/O when we write the
input then the device should be ready to take the data otherwise the program should
wait for some time so that the device or buffer will be free then it can take the input.
Once the input is taken then it will be checked whether the output device or output
buffer is free then it will be printed. This process is continued every time in transferring
of the data.
I/O Interrupts
To initiate any I / O operation, the CPU first loads the registers to the device controller.
Then the device controller checks the contents of the registers to determine what
operation to perform.
DMA Structure
Direct Memory Access (DMA) is a method of handling I / O. Here the device controller
directly communicates with memory without CPU involvement.
After setting the resources of I/O devices like buffers, pointers, and counters, the
device controller transfers blocks of data directly to storage without CPU intervention.
Objectives
Functions
The hardware and software in a computer system can be viewed in a layered fashion as
shown in the figure.1.5.
• The hardware and software used in providing applications to a user can be viewed in a
layered or hierarchical fashion.
• The user of those applications, the end user, generally is not concerned with the details
of computer hardware.
Application users are not concerned with the details of computer hardware.
The operating system masks the details of the hardware from the programmer and acts
as a mediator, making it easier to access the services.
• A computer is a set of resources for the movement, storage, and processing of data and
for the control of these functions. The OS is responsible for managing these resources.
• The OS functions in the same way as ordinary computer software. That is a program or
suite of programs executed by the processor.
• The OS frequently relinquishes control and must depend on the processor to allow it to
regain control.
• The OS directs the processor in the use of the other system resources and in the timing
of its execution of other programs.
• A portion of the OS is in main memory. This includes the kernel, or nucleus which
contains.
• The remainder of main memory contains user programs and data is shown in fig 1.6.
The memory management hardware in the processor and the OS jointly control the
allocation of main memory.
Key Points
1. Serial Processing
2. Simple batch systems
3. Multiprogrammed Batch Systems
4. Time-Sharing Systems
5. Mutiprocessor System
6. Distributed Systems
7. Client Server System
8. Clustered Systems
9. Real Time Systems
10. Hand Held Systems
1. Serial Processing:
• In serial processing, processor does only one process at a time (Requests, gets it, and
fetches it).
• Therefore, this kind of processing is slow; while in parallel processing, CPU does more
than one process at a time, so it's faster & consumes less time.
• These computers were run from a console consisting of display lights, toggle switches,
some form of input device, and a printer.
• If an error halted the program, the error condition was indicated by the lights.
• If the program proceeded to a normal completion, the output appeared on the printer.
o Scheduling
o Setup time
• Early computers were expensive, and therefore it was important to maximize processor
utilization.
• The wasted time due to scheduling and setup time was unacceptable.To improve
utilization, the concept of a batch OS was accepted.
• Monitor point of view: The monitor controls the sequence of events. For this to be so,
much of the monitor must always be in main memory and available for execution. That
portion is referred to as the resident monitor.
• The user submits the job cards or tape to a computer operator, who batches the jobs
together sequentially and places the entire batch on an input device, for use by the
monitor.
• When one job needs to wait for I/O, the processor can switch to the other job, which is
likely not waiting for I/O.
• Expand memory to hold three, four, or more programs and switch among all of them.
The approach is known as multiprogramming, or multitasking is shown in fig 1.7.
4. Time-Sharing Systems:
• The CPU executes multiple jobs by switching among them but switches occur so
frequently that the user can interact with each program while it is running.
5. Multiprocessor Systems
Multiprocessor system also known as parallel system or tightly coupled system have
more than one processor in close communication sharing the computer bus, the clock
and sometimes memory and peripheral devices.
Economy of scale. Multiprocessor systems can cost less than equivalent multiple
single-processor systems, because they can share peripherals, mass storage, and
power supplies.
Asymmetric multiprocessing:
A master processor controls the system; the other processors either look to the
slave for instruction or have predefined tasks.
The boss processor schedules and allocates work to the worker processors.
Symmetric multiprocessing:
• In which each processor performs all tasks within the operating system.
• SMP means that all processors are peers; no master-slave relationship exists
between processors.
The processor communicates with one another through various communication links
such as high-speed buses or telephone lines.
Advantages
o Resource sharing
o Computation speeds up
o Reliability
7. Client-Server Systems
Server Systems can be broadly categorized as compute servers and file servers.
8. Clustered Systems
Clustered systems differ from parallel systems, however, in that they are composed of
two or more individual systems coupled together.
Asymmetric Clustering
o In this, one machine is in hot standby mode while the other is running the
applications.
o The hot standby host (machine) does nothing but monitor the active server.
o If that server fails, the hot standby host becomes the active server.
Symmetric Clustering
o In this, two or more hosts are running applications, and they are monitoring
each other.
o This mode is obviously more efficient, as it uses all of the available hardware.
Processing must be done within the defined constraints or the system will fail.
The Real-Time Operating system which guarantees the maximum time for critical
operations and complete them on time are referred to as Hard Real-Time Operating
Systems.
While the real-time operating systems that can only guarantee a maximum of the
time, i.e. the critical task will get priority over other tasks. These systems are
referred to as Soft Real-Time Operating Systems.
They are usually of limited size due to which most handheld devices have a small
amount of memory, include slow processors, and feature small display screens.
Many handheld devices have between 512 KB and 8 MB of memory. As a result, the
operating system and applications must manage memory efficiently. This includes
returning all allocated memory back to the memory manager once the memory is no
longer being used.
Currently, many handheld devices do not use virtual memory techniques, thus forcing
program developers to work within the confines of limited physical memory.
Processors for most handheld devices often run at a fraction of the speed of a processor
in a PC. Faster processors require more power. To include a faster processor in a
handheld device would require a larger battery that would have to be replaced more
frequently.
The last issue confronting program designers for handheld devices is the small display
screens typically available.
One approach for displaying the content in web pages is web clipping, where only a
small subset of a web page is delivered and displayed on the handheld device.
Some handheld devices may use wireless technology such as BlueTooth, allowing
remote access to e-mail and web browsing.
Cellular telephones with connectivity to the Internet fall into this category.
Their use continues to expand as network connections become more available and
other options such as cameras and MP3 players, expand their utility.
4. Explain in detail about operating system structure. (or) Explain Various structures of
Operating System.(Nov/Dec-2023)
System Structure
Since the operating system is such a complex structure, it should be created with
utmost care so it can be used and modified easily.
Each of these parts should be well defined with clear inputs, outputs and functions.
1. Simple structure
2. Layered approach
3. Microkernel approach
1. Simple Structure
o MS-DOS structure
o Unix structure
• In MS-DOS the interfaces and levels of functionality are not well separated.
For instance, application programs are able to access the basic I/O routines to write is
shown in Fig 1.8.
Example 2: UNIX:
o Kernel program
o System programs
The kernel is further separated into a series of interfaces and device drivers,
which were added and expanded over the years as UNIX evolved.
The kernel provides the file system, CPU scheduling, memory management, and
other operating system functions through system calls is shown in Fig 1.9.
2. Layered approach
In which the operating system is broken into a number of layers(levels). The bottom
layer (layer 0) is the hardware; the highest (layer N) is the user interface.
A typical operating-system layer — say, layer M — consists of data structures and a set
of routines that can be invoked by higher-level layers.
Given proper hardware support, OS may be broken into smaller, more appropriate
pieces.
One method is the layered approach, in which the operating system is broken up into a
number of layers (or levels), each built on top of lower layers.
The bottom layer (layer 0) is the hardware: the highest (layer N) is the user interface is
shown in Fig 1.10.
Advantage:
Disadvantage:
The major difficulty with the layered approach involves appropriately defining the
various layers. Because a layer can use only lower-level layers, careful planning is
necessary.
A problem with layered implementations is that they tend to be less efficient than other
types.
o Layer 0 -Hardware
3. Microkernel approach
Remove the non-essential components from the kernel into the user space.
Communication takes place between user modules using message passing is shown in
Fig 1.11.
Benefits
o More secure
Fig.1.11 Microkernel
Services of OS:
User interface
• Almost all operating systems have a user interface (UI). This interface can take several
forms.
• One is a command-line interface (CLI), which uses text commands and a method for
entering them (say, a keyboard for typing in commands in a specific format with
specific options).
• Here, the interface is a window system with a pointing device to direct I/O, choose from
menus, and make selections and a keyboard to enter text. Some systems provide two or
all three of these variations. The OS services is shown in fig 1.12.
Program execution:
The system must be able to load a program into memory and to run that program.
The program must be able to end its execution, either normally or abnormally
(indicating error).
I/O Operations:
• A running program may require I/O, which may involve a file or an I/O device.
• For efficiency and protection, users usually cannot control I/O devices directly.
Therefore, the operating system must provide a means to do I/O.
File-system manipulation
The file system is of particular interest. Obviously, programs need to read and write
files and directories.
They also need to create and delete them by name, search for a given file, and list file
information.
Many operating systems provide a variety of file systems, sometimes to allow personal
choice and sometimes to provide specific features or performance characteristics.
Communications
• There are many circumstances in which one process needs to exchange information
with another process.
• Such communication may occur between processes that are executing on the same
computer or between processes that are executing on different computer systems tied
together by a computer network.
Error detection
• Errors may occur in the CPU and memory hardware (such as a memory error or a
power failure), in I/O devices (such as a parity error on disk, a connection failure on a
network, or lack of paper in the printer), and in the user program (such as an
arithmetic overflow, an attempt to access an illegal memory location, or a too-great use
of CPU time).
• For each type of error, the operating system should take the appropriate action to
ensure correct and consistent computing.
• Sometimes, it has no choice but to halt the system. At other times, it might terminate
an error-causing process or return an error code to a process for the process to detect
and possibly correct.
Resource allocation
• When there are multiple users or multiple jobs running at the same time, resources
must be allocated to each of them.
• The operating system manages many different types of resources. Some (such as CPU
cycles, main memory, and file storage) may have special allocation code, whereas
others (such as I/O devices) may have much more general request and release code.
• For instance, in determining how best to use the CPU, operating systems have CPU-
scheduling routines that take into account the speed of the CPU, the jobs that must be
executed, the number of registers available, and other factors.
• There may also be routines to allocate printers, USB storage drives, and other
peripheral devices.
Accounting
• We want to keep track of which users use how much and what kinds of computer
resources.
• This record keeping may be used for accounting (so that users can be billed) or simply
for accumulating usage statistics.
• Usage statistics may be a valuable tool for researchers who wish to reconfigure the
system to improve computing services.
• When several separate processes execute concurrently, it should not be possible for
one process to interfere with the others or with the operating system itself.
• Protection involves ensuring that all access to system resources is controlled. Security
of the system from outsiders is also important.
• Such security starts with requiring each user to authenticate himself or herself to the
system, usually by means of a password, to gain access to system resources.
One provides a command line interface, or command interpreter, that allows users to
directly enter commands to be performed by the operating system.
The other allows users to interface with the operating system via a graphical user
interface or GUI
Command Interpreters
2. Others, such as Windows and UNIX, treat the command interpreter as a special
program that is running when a job is initiated or when a user first logs on (on
interactive systems).
3. On systems with multiple command interpreters to choose from, the interpreters are
known as shells.
4. The main function of the command interpreter is to get and execute the next user-
specified command. Many of the commands given at this level manipulate files: create,
delete, list, print, copy, execute, and so on.
The MS-DOS and UNIX shells operate in this way. These commands can be implemented
in two general ways.
1. In one approach, the command interpreter itself contains the code to execute the
command.
For example, a command to delete a file may cause the command interpreter to
jump to a section of its code that sets up the parameters and makes the
appropriate system call.
In this case, the command interpreter does not understand the command in any
way; it merely uses the command to identify a file to be loaded into memory and
executed.
A second strategy for interfacing with the operating system is through a user friendly
graphical user interface, or GUI.
Here, rather than entering commands directly via a command-line interface, users employ
a mouse-based window and- menu system characterized by a desktop metaphor.
The user moves the mouse to position its pointer on images, or icons, on the screen (the
desktop) that represent programs, files, directories, and system functions.
Depending on the mouse pointer’s location, clicking a button on the mouse can invoke a
program, select a file or directory—known as a folder—or pull down a menu that contains
commands.
7.What is System Call? Explain the various types of system calls with an example for
each. Or Explain the purpose and importance of system calls in details with examples.
(April/May-2023 & Nov/Dec-2023)(April/May-2024)(Nov/Dec-2024)
Definition
These calls are generally available as assembly language instructions is shown in fig
1.13.
Fig.1.13 The handling of a user application invoking the open system call
Three general methods are used to pass parameters to the operating system. The
simplest approach is to pass the parameters in registers.
In some cases, however, there may be more parameters than registers. In these cases,
the parameters are generally stored in a block, or table, in memory, and the address of
the block is passed as a parameter in a register is shown in fig 1.14.
Process control
File manipulation
Device manipulation
Information maintenance
Communications
Protection.
Process Control:
A running program needs to be able to halt its execution either normally (end()) or
abnormally (abort()).
Activities
end, abort
load, execute
File Management:
• Once the file is created, we need to open () it and to use it. We may also read ( ), write( ),
or reposition() (rewind or skip to the end of the file, for example).
• Finally, we need to close ( ) the file, indicating that we are no longer using it.
• File attributes include the file name, file type, protection codes, accounting information,
and so on.
• At least two system calls, get file attributes ( ) and set file attributes ( ), are required for
this function. Some operating systems provide many more calls, such as calls for file
move ( ) and copy ( ).
Activities
open, close
Device Management:
• A process may need several resources to execute—main memory, disk drives, access to
files, and so on. If the resources are available, they can be granted, and control can be
returned to the user process. Otherwise, the process will have to wait until sufficient
resources are available.
• The various resources controlled by the operating system can be thought of as devices.
Some of these devices are physical devices (for example, disk drives), while others can
be thought of as abstract or virtual devices (for example, files)
• A system with multiple users may require us to first request() a device, to ensure
exclusive use of it. After we are finished with the device, we release() it. These functions
are similar to the open() and close() system calls for files.
• A process may need several resources to execute — main memory, disk drives, access
to files, and so on. If the resources are available, they can be granted, and control can
be returned to the user process.
Activities
Information Maintenance:
• Many system calls exist simply for the purpose of transferring information between the
user program and the operating system.
• For example, most systems have a system call to return the current time() and date().
Other system calls may return information about the system, such as the number of
current users, the version number of the operating system, the amount of free memory
or disk space, and so on.
• In addition, the operating system keeps information about all its processes, and system
calls are used to access this information.
Activities
Communication:
In the shared-memory model, processes use shared memory create() and shared
memory attach() system calls to create and gain access to regions of memory owned
by other processes. Recall that, normally, the operating system tries to prevent one
process from accessing another process’s memory.
Activities
Protection:
System calls providing protection include set permission() and get permission(),
which manipulate the permission settings of resources such as files and disks.
The allow user() and deny user() system calls specify whether particular users can
— or cannot — be allowed access to certain resources.
System Program:
• File management. These programs create, delete, copy, rename, print, dump, list, and
generally manipulate files and directories.
• Status information. Some programs simply ask the system for the date, time, amount
of available memory or disk space, number of users, or similar status information.
Others are more complex, providing detailed performance, logging, and debugging
information, registry-which is used to store and retrieve configuration information.
• File modification. Several text editors may be available to create and modify the
content of files stored on disk or other storage devices.
• Background services. All general-purpose systems have methods for launching certain
system-program processes at boot time. Some of these processes terminate after
completing their tasks, while others continue to run until the system is halted.
Design Goals
At the highest level, the design of the system will be affected by the choice of hardware
and the type of system: batch, time sharing, single user, multiuser, distributed, real
time, or general purpose.
Beyond this highest design level, the requirements may be much harder to specify.
The requirements can, however, be divided into two basic groups: user goals and
system goals.
User Goals: Operating system should be convenient to use, easy to learn, reliable, safe,
and fast
System Goals: operating system should be easy to design, implement, and maintain,
as well as flexible, reliable, error-free, and efficient.
If the mechanism is properly separated from policy, it can be used either to support
a policy decision that I/O-intensive programs should have priority over CPU-
intensive ones or to support the opposite policy.
Policy decisions are important for all resource allocation. Whenever it is necessary
to decide whether or not to allocate a resource, a policy decision must be made.
Whenever the question is how rather than what, it is a mechanism that must be
determined.
Implementation
Much variation
o Now C, C++
o But slower
The major performance improvements in operating systems are more likely to be the
result of better data structures and algorithms than of excellent assembly language
code
o Although operating systems are large, only a small amount of the code is
critical to high performance, the interrupt handler, I/O manager, memory
manager, and CPU scheduler are probably the most critical routines.
10. What is the main difficulty that a programmer must overcome in writing an
operating system for a real-time Environment? (April/May-2024)
The main difficulty a programmer must overcome in writing an operating system for a real-
time environment is ensuring deterministic behavior. In real-time systems, tasks must be
executed within strict timing constraints, meaning that the system must provide predictable
and reliable responses to events, often within microseconds or milliseconds. The challenges
involved include:
1. Meeting timing constraints: The operating system must guarantee that critical tasks
or processes meet their deadlines, which requires precise scheduling, resource
management, and prioritization.
2. Interrupt handling: The system needs to handle interrupts promptly and predictably,
ensuring that time-sensitive tasks are executed without unnecessary delays.
3. Resource contention: Managing limited resources (like CPU time, memory, and I/O
devices) in a way that guarantees the real-time tasks are prioritized and are not starved
by lower-priority tasks.
4. Concurrency and synchronization: Multiple tasks might be running simultaneously,
and their interactions need to be carefully synchronized to avoid issues like race
conditions or deadlocks that could interfere with time-sensitive operations.
5. Avoiding non-deterministic behaviors: Real-time systems should avoid behaviors like
jitter (unpredictable fluctuations in task execution time), which could arise from non-
deterministic scheduling or inefficient resource management.
The operating system must be optimized for these requirements, often at the cost of features
or flexibility that a general-purpose operating system might support, to ensure reliable and
consistent performance under real-time constraints.
(i) Buffering :
It refers to the process of temporarily storing data in a memory area, called a buffer,
while it is being transferred between two locations or processed. The data can be
coming from or going to an input/output (I/O) device, such as a disk, network, or
keyboard, and the buffer acts as a temporary holding area that helps manage
differences in data processing speeds between components.
(ii) Spooling :
In a time-sharing system, the CPU is allocated to various processes for short periods,
typically milliseconds, in a round-robin or priority-based scheduling manner. This
approach maximizes the system's efficiency by keeping all users and processes actively
engaged with the system, providing the appearance of simultaneous execution.
Example,
Cloud Computing
Distributed Databases
Distributed File Systems
Google File System (GFS)
Hadoop Distributed File System (HDFS)
Peer-to-Peer Networks:
It is a type of computing system that is designed to process data and respond to inputs
within a specific time constraint, often referred to as a deadline. In real-time systems,
the correctness of the system's operation not only depends on the logical correctness of
the results but also on the timing of the responses. These systems are used in
environments where timing is critical, such as in embedded systems, industrial control,
robotics, telecommunications, and many others.
APRIL/MAY-2023
PART A
PART B
*****
NOV/DEC-2023
PART A
PART B
4. Explain the purpose and importance of system calls in details with examples.(Q.NO:7)
*****
APRIL/MAY-2024
PART A
PART B
1. What is the main difficulty that a programmer must overcome in writing an operating system for a
real-time Environment?(Q.No:10)
2. Describe three general methods for passing parameters to the operating system.(Q.No:7)
3. Consider a computing cluster consisting of two nodes running a database. Describe two ways in
which the cluster software can manage access to the data on the disk. Discuss the benefits and
disadvantages of each.(Q.No:3)
4. List five services provided by an operating system, and explain how each creates convenience for
users. In which cases would it be impossible for user-level programs to provide these sevices?
Explain your answer.(Q.No:5)
*****
ANNA UNIVERSITY QUESTIONS
NOV/DEC-2024
PART A
*****
UNIT II
PROCESS MANAGEMENT
Processes - Process Concept - Process Scheduling - Operations on Processes - Inter-
process Communication; CPU Scheduling - Scheduling criteria - Scheduling
algorithms: Threads - Multithread Models – Threading issues; Process
Synchronization - The Critical-Section problem - Synchronization hardware –
Semaphores – Mutex - Classical problems of synchronization - Monitors; Deadlock -
Methods for handling deadlocks, Deadlock prevention, Deadlock avoidance, Deadlock
detection, Recovery from deadlock.
2 MARKS
1. Define a process.
A process is a program in execution. It is the unit of work in a modern operating
system. A process is an active entity with a program counter specifying the next
instructions to execute and a set of associated resources. It also includes the
process stack, containing temporary data and a data section containing global
variables.
2. What is process control block?
Each process is represented in the operating system by a process control block
also called a task control block. It contains many pieces of information associated
with a specific process. It simply acts as a repository for any information that may
vary from process to process. It contains the following information:
Process state
Program counter
CPU registers
CPU- scheduling information
Memory-management information
Accounting information
I/O status information
3. What are the states of a Process?(April/May-2024)
5. What are the use of job queues, ready queues and device queues?
As a process enters a system they are put in to a job queue. This queue
consists of all jobs in the system.
The processes that are residing in main memory and are ready and waiting
to execute are kept on a list called ready queue.
The list of processes waiting for a particular I/O device kept in the device
queue.
When a process is in its critical section, any other process that tries to enter its
critical section must loop continuously in the entry code. This is called as busy
waiting and this type of semaphore is also called a spinlock, because the
process while waiting for the lock.
28.What is a Dispatcher?
The dispatcher is the module that gives control of the CPU to the process
selected by the short-term scheduler. This function involves:
Switching context
Switching to user mode
Jumping to the proper location in the user program to restart that program.
Response time
31.Define throughput.
Throughput in CPU scheduling is the number of processes that are completed
per unit time. For long process, this rate may be one process per hour, for short
transactions, throughput might be 10 process per second.
35.Define deadlock.
A process requests resources; if the resources are not available at that time, the
process enters a wait state.
Waiting processes may never again change state, because the resources they
have requested are held by other waiting processes. This situation is called a
deadlock.
allocated to each process, and the future requests and releases of each process,
to decide whether they could be satisfied or must wait to avoid a possible future
deadlock.
44.What is a deadlock?
A process requests resources; if the resources are not available at that time, the
process enters a wait state.
Waiting processes may never again change state, because the resources they
have requested are held by other waiting processes.
This situation is called a deadlock.
45.What is Semaphore?
A semaphore 'S' is a synchronization tool which is an integer value that, apart
from initialization, is accessed only through two standard atomic operations;
wait() - operation was originally termed P (from the Dutch proberen, “to test”);
signal() - was originally called V (from verhogen, “to increment”).
Semaphores can be used to deal with the n-process critical section problem. It
can be also used to solve various Synchronization problems.
yet a third thread loads images from the hard drive, and a fourth does periodic
automatic backups of the file being edited.
Challenges:
Shared Access to Data
2. Process takes more time to terminate. Thread takes less time to terminate.
3. It takes more time for creation. It takes less time for creation.
57.Define Mutex.(Nov/Dec-2021)
Mutex is a binary variable whose purpose is to provide locking mechanism. It is
used to provide mutual exclusion to a section of code, means only one process
can work on a particular code section at a time.
Context Processes require more time Threads require less time for
switching time for context switching as they context switching as they are
are heavier. lighter than processes.
Data and Code Processes have independent A thread shares the data
sharing data and code segments. segment, code segment, files
Treatment by All the different processes are All user level peer threads are
OS treated separately by the treated as a single task by the
operating system. operating system.
Time for Processes require more time Threads require less time for
creation for creation. creation.
Time for Processes require more time Threads require less time for
termination for termination. termination.
PART B
1. What is Process? Explain about the states of process with neat sketch and
discuss the process state transition with a neat diagram. (April/May-2023)
Definition:
Process is a program execution. A process is the unit of work in a modern time-
sharing system.
Process Concept:
A program is a passive entity, such as the contents of a file stored on disk,
whereas a process is an active entity, with a program counter specifying the
next instruction to execute and a set of associated resources. The structure of a
process in memory is shown in Figure 2.1.
A process is more than the program code, which is sometimes known as the text
section.
It also includes program counter and the contents of the processor’s registers,
The process stack, which contains temporary data (such as function parameters,
return addresses, and local variables),
And a data section, which contains global variables.
And heap, which is memory that is dynamically allocated during process run
time.
A program becomes a process when an executable file is loaded into memory.
Fig.2.3 shows the elements of the Process Control Block. The elements are,
State: The state may be new, ready, running, waiting, halted, and so on.
Program counter: The counter indicates the address of the next instruction to be
executed for this process.
CPU registers: The registers vary in number and type, depending on the
computer architecture.
CPU-scheduling information: This information includes a process priority,
pointers to scheduling queues, and any other scheduling parameters.
Memory-management information: This information may include such
information as the value of the base and limit registers, the page tables, or the
segment tables, depending on the memory system used by the operating
system.
I/O Status information: The information includes the list of I/O devices
allocated to this process, a list of open files, and so on.
The short-term scheduler, or CPU scheduler, selects from among the processes that
are ready to execute and allocates the CPU to one of them.
The long-term scheduler executes much less frequently; minutes may separate the
creation of one new process and the next. The long-term scheduler controls the degree
of multiprogramming (the number of processes in memory).
Some operating systems, such as time-sharing systems, may introduce an additional,
intermediate level of scheduling. This medium-term scheduler is shown in following
figure 2.6.
Context Switch:
• When an interrupt occurs, the system needs to save the current context of the process
running on the CPU so that it can restore that context when its processing is done,
essentially suspending the process and then resuming it.
• Switching the CPU to another process requires performing a state save of the current
process and a state restore of a different process. This task is known as a context
switch.
The processes in most systems can execute concurrently, and they may be created
and deleted dynamically.
Thus, these systems must provide a mechanism for process creation and termination.
Process Creation:
During the course of execution, a process may create several new processes. The
creating process is called a parent process, and the new processes are called the
children of that process.
Each of these new processes may in turn create other processes, forming a tree
of processes.
The init process (which always has a pid of 1) serves as the root parent process
for all user processes.
Once the system has booted, the init process can also create various user
processes, such as a web or print server.
When a process creates a new process, two possibilities for execution exist:
1. The parent continues to execute concurrently with its children.
2. The parent waits until some or all of its children have terminated.
There are also two address-space possibilities for the new process:
The child process is a duplicate of the parent process (it has the same program
and data as the parent).
The child process has a new program loaded into it.
To illustrate these differences, let’s first consider the UNIX operating system.
A new process is created by the fork() system call. The new process consists of a
copy of the address space of the original process. This mechanism allows the
parent process to communicate easily with its child process.
Both processes (the parent and the child) continue execution at the instruction
after the fork(), with one difference: the return code for the fork() is zero for the
new (child) process, whereas the (nonzero) process identifier of the child is
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 20
MAILAM ENGINEERING COLLEGE CS3451 – Introduction to Operating System Univ-II
returned to the parent. Fig.2.7 shows Process creation using the fork() system
call.
After a fork() system call, one of the two processes typically uses the exec()
system call to replace the process’s memory space with a new program.
The exec() system call loads a binary file and starts its execution.
Process Termination:
A process terminates when it finishes executing its final statement and asks the
operating system to delete it by using the exit() system call. At that point, the
process may return a status value (typically an integer) to its parent process (via
the wait() system call).
All the resources of the process—including physical and virtual memory, open
files, and I/O buffers—are deallocated by the operating system.
A parent may terminate the execution of one of its children for a variety of
reasons, such as these:
1. Shared Memory
2. Message Passing
Figure 2.8 shows the types of Communications models. Ie)(a) Message passing. (b)
Shared memory.
a. In the shared-memory model, a region of memory that is shared by cooperating
processes is established.
Processes can then exchange information by reading and writing data to the shared
region.
Figure 2.8 Communications models. (a) Message passing. (b) Shared memory.
Both of the models just mentioned are common in operating systems, and many
systems implement both.
Message passing is useful for exchanging smaller amounts of data, because no
conflicts need be avoided.
Message passing is also easier to implement in a distributed system than shared
memory.
Shared memory can be faster than message passing, since message-passing systems
are typically implemented using system calls.
Shared-Memory Systems:
The unbounded buffer places no practical limit on the size of the buffer. The
consumer may have to wait for new items, but the producer can always produce new
items.
The bounded buffer assumes a fixed buffer size. In this case, the consumer must wait
if the buffer is empty, and the producer must wait if the buffer is full.
The following variables reside in a region of memory shared by the producer and
consumer processes:
while (true)
{
while (in == out)
; /* do nothing */
next consumed = buffer[out];
out = (out + 1) % BUFFER SIZE;
/* consume the item in next consumed */
}
Message-Passing Systems:
Message passing provides a mechanism to allow processes to communicate and to
synchronize their actions without sharing the same address space.
It is particularly useful in a distributed environment, where the communicating
processes may reside on different computers connected by a network.
For example, an Internet chat program could be designed so that chat participants
communicate with one another by exchanging messages.
Here are several methods for logically implementing a link and the send()/receive()
operations:
Direct communication:
Direct communication, each process that wants to communicate must explicitly name
the recipient or sender of the communication. In this scheme, the send() and
receive() primitives are defined as:
Indirect communication:
Indirect communication, the messages are sent to and received from mailboxes, or
ports.
• A mailbox can be viewed abstractly as an object into which messages can be placed by
processes and from which messages can be removed.
• Each mailbox has a unique identification.
• For example, POSIX message queues use an integer value to identify a mailbox.
• A process can communicate with another process via a number of different mailboxes,
but two processes can communicate only if they have a shared mailbox.
Thread Overview:
A thread is a basic unit of CPU utilization. It comprises a thread ID, a program
counter, a register set, and a stack.
It shares with other threads belonging to the same process its code section, data
section, and other operating-system resources, such as open files and signals. Figure
2.9 shows Single threaded and multithreaded process model.
• A traditional (or heavyweight) process has a single thread of control.
• If a process has multiple threads of control, it can perform more than one task at a
time.
For example.
A word processor may have a thread for displaying graphics, another thread for
responding to keystrokes from the user, and a third thread for performing spelling
and grammar checking in the background.
Such applications can perform several CPU-intensive tasks in parallel across the
multiple computing cores. The Multithreaded server Architecture is shown in Fig 2.10.
Benefits:
Responsiveness:
Multithreading an interactive application may allow a program to continue
running even if part of it is blocked or is performing a lengthy operation,
thereby increasing responsiveness to the user.
Resource sharing:
Processes can only share resources through techniques such as shared memory
and message passing.
Economy:
Allocating memory and resources for process creation is costly. Because threads
share the resources of the process to which they belong, it is more economical
to create and context-switch threads.
Scalability:
The benefits of multithreading can be even greater in a multiprocessor
architecture, where threads may be running in parallel on different processing
cores.
Similarity between Threads and Processes:
Only one thread or process is active at a time
Within process both execute sequentially
Both can create children
Differences between Threads and Processes:
Threads are not independent, processes are.
Threads are designed to assist each other, processes may or may not do it
Types of Threads:
User Level thread (ULT):
It Is implemented in the user level library, they are not created using the system calls.
Thread switching does not need to call OS and to cause interrupt to Kernel. Kernel
doesn’t know about the user level thread and manages them as if they were single-
threaded processes.
Advantages of ULT :
Disadvantages of ULT :
No or less co-ordination among the threads and Kernel.
If one thread causes a page fault, the entire process blocks.
1. Kernel Level Thread (KLT) :
Kernel knows and manages the threads. Instead of thread table in each process, the
kernel itself has thread table (a master one) that keeps track of all the threads in the
system. In addition kernel also maintains the traditional process table to keep track of
the processes. OS kernel provides system call to create and manage threads.
Advantages of KLT:
Since kernel has full knowledge about the threads in the system, scheduler may
decide to give more time to processes having large number of threads.
Good for applications that frequently block.
Disadvantages of KLT :
Slow and inefficient.
It requires thread control block so it is an overhead.
Multicore Programming:
On a system with a single computing core, concurrency merely means that the
execution of the threads will be interleaved over time .Figure 2.11 shows the
concurrent execution on a single core system , because the processing core is capable
of executing only one thread at a time.
On a system with multiple cores, however, concurrency means that the threads can
run in parallel, because the system can assign a separate thread to each core .
Programming Challenges
The trend towards multicore systems continues to place pressure on system designers
and application programmers to make better use of the multiple computing cores.
Designers of operating systems must write scheduling algorithms that use multiple
processing cores to allow the parallel execution shown in Figure 2.13
1. Identifying tasks: This involves examining applications to find areas that can be
divided into separate, concurrent tasks.
2. Balance: While identifying tasks that can run in parallel, programmers must also
ensure that the tasks perform equal work of equal value.
3. Data splitting: Just as applications are divided into separate tasks, the data
accessed and manipulated by the tasks must be divided to run on separate cores.
4. Data dependency: The data accessed by the tasks must be examined for
dependencies between two or more tasks. When one task depends on data from
another, programmers must ensure that the execution of the tasks is synchronized to
accommodate the data dependency.
Types of Parallelism:
In general, there are two types of parallelism:
Data parallelism and Task parallelism.
Data parallelism - focuses on distributing subsets of the same data across multiple
computing cores and performing the same operation on each core.
Task parallelism - involves distributing not data but tasks (threads) across
multiple computing cores.
Each thread is performing a unique operation. Different threads may be operating on
the same data, or they may be operating on different data.
User threads are supported above the kernel and are managed without kernel
support, whereas kernel threads are supported and managed directly by the
operating system.
Virtually all contemporary operating systems—including Windows, Linux, Mac
OS X, and Solaris— support kernel threads.
Three common ways of establishing such a relationship:
1. many-to-one model,
2. one-to-one model,
3. many-to many model.
Many-to-One Model
The many-to-one model maps many user-level threads to one kernel thread is
shown in fig 2.14.
Thread management is done by the thread library in user space, so it is
efficient.
One variation on the many-to-many model still multiplexes many user level threads to
a smaller or equal number of kernel threads but also allows a user-level thread to be
8. What is a race condition? Explain how a critical section avoids this condition.
Race condition:
When several process access and manipulate same data concurrently, then the
outcome of the execution depends on particular order in which the access takes
place is called race condition.
To avoid race condition, only one process at a time can manipulate the shared
variable.
Synchronization:
Process Synchronization means sharing system resources by processes in such
a way that, Concurrent access to shared data is handled thereby minimizing the
chance of inconsistent data. Maintaining data consistency demands
mechanisms to ensure synchronized execution of cooperating processes.
Process Synchronization was introduced to handle problems that arose while
multiple process executions. Some of the problems are discussed below.
Critical-Section Problem:
Consider a system consisting of n processes {P0, P1, ..., Pn−1}.
Each process has a segment of code, called a critical section, in which the
process may be changing common variables, updating a table, writing a file, and
so on.
The important feature of the system is that, when one process is executing in its
critical section, no other process is allowed to execute in its critical section.
That is, no two processes are executing in their critical sections at the same
time.
The critical-section problem is to design a protocol that the processes can use to
cooperate. Each process must request permission to enter its critical section.
The section of code implementing this request is the entry section.
The critical section may be followed by an exit section.
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 31
MAILAM ENGINEERING COLLEGE CS3451 – Introduction to Operating System Univ-II
Mutex Locks:
Operating-systems designers build software tools to solve the critical-section
problem. The simplest of these tools is the mutex lock. (mutual exclusion.)
We use the mutex lock to protect critical regions and thus prevent race
conditions.
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 32
MAILAM ENGINEERING COLLEGE CS3451 – Introduction to Operating System Univ-II
That is, a process must acquire the lock before entering a critical section; it
releases the lock when it exits the critical section.
The acquire()function acquires the lock, and the release() function releases the
lock.
The definition of acquire() is as follows:
acquire()
{
while (!available)
; /* busy wait */
available = false;;
}
do
{
acquire lock
critical section
release lock
remainder section
} while (true);
A mutex lock has a boolean variable available whose value indicates if the lock
is available or not.
If the lock is available, a call to acquire() succeeds, and the lock is then
considered unavailable.
A process that attempts to acquire an unavailable lock is blocked until the lock
is released.
The definition of release() is as follows:
release()
{
available = true;
}
Calls to either acquire() or release() must be performed automically.
The main disadvantage of the implementation given here is that it requires busy
waiting.
While a process is in its critical section, any other process that tries to enter its
critical section must loop continuously in the call to acquire().
In fact, this type of mutex lock is also called a spinlock because the process
“spins” while waiting for the lock to become available.
This continual looping is clearly a problem in a real multiprogramming system,
where a single CPU is shared among many processes.
10.Explain in detail about semaphores and show how wait() and signal()
operations could be implemented in multiprocessor environments, using the
Test and Set() instructions. (or) How process synchronization is achieved using
semaphore? Give an example.(April/May-2023 & Nov/Dec-2023)
1. wait() - operation was originally termed P (from the Dutch proberen, “to test”);
2. signal() - was originally called V (from verhogen, “to increment”).
wait(S)
{
while (S <= 0)
; // busy wait
S--; }
The definition of signal() is as follows:
signal(S)
{
S++;
}
All modifications to the integer value of the semaphore in the wait() and signal()
operations must be executed indivisibly.
That is, when one process modifies the semaphore value, no other process can
simultaneously modify that same semaphore value.
Semaphore Usage:
Operating systems often distinguish between counting and binary semaphores.
The value of a counting semaphore can range over an unrestricted domain.
The value of a binary semaphore can range only between 0 and 1.
Thus, binary semaphores behave similarly to mutex locks.
Counting semaphores can be used to control access to a given resource
consisting of a finite number of instances.
The semaphore is initialized to the number of resources available.
Each process that wishes to use a resource performs a wait() operation on the
semaphore (thereby decrementing the count).
When a process releases a resource, it performs a signal() operation
(incrementing the count).
When the count for the semaphore goes to 0, all resources are being used.
After that, processes that wish to use a resource will block until the count
becomes greater than 0.
To implement semaphores under this definition, we define a semaphore as
follows:
typedef struct
{
int value;
struct process *list;
} semaphore;
Each semaphore has an integer value and a list of processes list. When a
process must wait on a semaphore, it is added to the list of processes. A signal()
operation removes one process from the list of waiting processes and awakens
that process.
The wait() semaphore operation can be defined as
wait(semaphore *S)
{
S->value--;
if (S->value < 0) {
add this process to S->list;
block();
}
}
The signal() semaphore operation can be defined as
signal(semaphore *S)
{
S->value++;
if (S->value <= 0) {
remove a process P from S->list;
wakeup(P);
}
}
The block() operation suspends the process that invokes it.
The wakeup(P) operation resumes the execution of a blocked process P.
If a semaphore value is negative, its magnitude is the number of processes
waiting on that semaphore.
This fact results from switching the order of the decrement and the test in the
implementation of the wait() operation.
The list of waiting processes can be easily implemented by a link field in each
process control block (PCB). Each semaphore contains an integer value and a
pointer to a list of PCBs.
12.Explain in detail about any two CPU scheduling algorithms with suitable
examples.
With this scheme, the process that requests the CPU first is allocated the CPU
first.
When a process enters the ready queue, its PCB is linked onto the tail of the
queue.
When the CPU is free, it is allocated to the process at the head of the queue.
The running process is then removed from the queue.
Consider the following set of processes that arrive at time 0, with the length of the
CPU burst given in milliseconds:
Process Burst Time
P1 24
P2 3
P3 3
Gantt chart:
If the processes arrive in the order P1, P2, P3, and are served in FCFS order,
The waiting time is 0 milliseconds for process P1, 24 milliseconds for process
P2, and 27 milliseconds for process P3. Thus, the average waiting time is (0 +
24 + 27)/3 = 17 milliseconds.
Shortest-Job-First Scheduling:
This algorithm associates with each process the length of the process’s next
CPU burst.
When the CPU is available, it is assigned to the process that has the smallest
next CPU burst.
If the next CPU bursts of two processes are the same, FCFS scheduling is used
to break the tie.
It is shortest-next- CPU-burst algorithm, because scheduling depends on the
length of the next
Consider the following set of processes, with the length of the CPU burst given in
milliseconds:
The waiting time is 3 milliseconds for process P1, 16 milliseconds for process P2, 9
milliseconds for process P3, and 0 milliseconds for process P4.
Thus, the average waiting time is (3 + 16 + 9 + 0)/4 = 7 milliseconds.
Consider the following four processes, with the length of the CPU burst given in
milliseconds:
Gantt chart:
Priority Scheduling:
A priority is associated with each process, and the CPU is allocated to the process
with the highest priority.
Equal-priority processes are scheduled in FCFS order.
An SJF algorithm is simply a priority algorithm where the priority (p) is the inverse of
the (predicted) next CPU burst.
Consider the following set of processes, assumed to have arrived at time 0 in the
order P1, P2, · · ·, P5, with the length of the CPU burst given in milliseconds:
Gantt chart:
Let’s calculate the average waiting time for this schedule. P1 waits for 6 milliseconds
(10 - 4), P2 waits for 4 milliseconds, and P3 waits for 7 milliseconds.
Process states:
Process P1 is holding an instance of resource type R2, and is waiting for an instance
of resource type R1.
Resource Allocation Graph with a deadlock
Process P2 is holding an instance of R1 and R2 and is waiting for an instance of
resource type R3.Process P3 is holding an instance of R3 is shown in fig.2.21
P1->R1->P2->R3->P3->R2->P1
P2->R3->P3->R2->P2
Deadlock Prevention:
This ensures that the system never enters the deadlock state.
Deadlock prevention is a set of methods for ensuring that at least one of the
necessary conditions cannot hold.
By ensuring that at least one of these conditions cannot hold, we can prevent
the occurrence of a deadlock.
3. Denying No preemption
If a Process is holding some resources and requests another resource that
cannot be immediately allocated to it. (i.e. the process must wait), then all
resources currently being held are preempted.
These resources are implicitly released.
The process will be restarted only when it can regain its old resources.
Safe State
A state is safe if the system can allocate resources to each process in some order and
still avoid a deadlock. Fig.2.22 shows the state of the system. A deadlock is an unsafe
state. Not all unsafe states are dead locks; an unsafe state may lead to a dead lock.
If no cycle exists, then the allocation of the resource will leave the system in a
safe state.
If a cycle is found, then the allocation will put the system in an unsafe state.
Safety algorithm
1. Initialize work := available and Finish [i]:=false for i=1,2,3 .. n
2. Find an i such that both
Finish[i]=false
Needi<= Work
i)if no such i exists, goto step 4
3. work :=work+ allocationi;
Finish[i]:=true
goto step 2
4. If finish[i]=true for all i, then the system is in a safe state
Resource Request Algorithm
Let Requesti be the request from process Pi for resources.
1. If Requesti<= Needi goto step2, otherwise raise an error condition, since the
process has exceeded its maximum claim.
2. If Requesti <= Available, goto step3, otherwise Pi must wait, since the resources
are not available.
3. Available := Availabe-Requesti;
Allocationi := Allocationi + Requesti
Needi := Needi - Requesti;
16.Explain the two solutions of recovery from deadlock. (or)How can a system
recover from deadlock? [Nov/Dec 2021]
Deadlock Recovery
1. Process Termination:
2. Resource Preemption:
Preemptive some resources from process and give these resources to other processes
until the deadlock cycle is broken.
If all resources have only a single instance, then we can define a deadlock detection
algorithm that use a variant of resource-allocation graph called a wait for graph is
shown in fig 2.23
If Request [i,j]=k, then process Pi is requesting K more instances of resource type Rj.
Threading Issues
Usage of the two versions of fork depends upon the application. If exec is called
immediately after forking, then duplicating all threads is unnecessary, as the
program specified in the parameters to exec will replace the process.
Cancellation
Thread cancellation is the task of terminating a thread before it has completed.
A thread that is to be cancelled is often referred to as the target thread. Cancellation
of a target thread may occur in two different scenarios:
Asynchronous cancellation: One thread immediately terminates the target
thread.
Every signal has a default signal handler that is run by the kernel when handling the
signal.
Deliver the signal to the thread to which the signal applies.
Deliver the signal to every thread in the process.
Deliver the signal to certain threads in the process.
Assign a specific thread to receive all signals for the process.
Thread Pools
Once the thread completes its service, it returns to the pool awaiting more
work. If the pool contains no available thread, the server waits until one becomes
free.
Benefits of thread pools are:
It is usually faster to service a request with an existing thread than waiting to
create a thread.
A thread pool limits the number of threads that exist at any one point. This is
particularly important on systems that cannot support a large number of
concurrent threads.
Threads belonging to a process share the data of the process. Indeed, this
sharing of data provides one of the benefits of multithreaded programming. However,
each thread might need its own copy of certain data in some circumstances.
These problems are used for testing nearly every newly proposed synchronization
scheme. The following problems of synchronization are considered as classical
problems:
2. Dining-Philosphers Problem,
Import java.util.concurrent.Semaphore;
class Q
{
// an item
int item;
// Producer class
class Producer implements Runnable
{
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 50
MAILAM ENGINEERING COLLEGE CS3451 – Introduction to Operating System Univ-II
Q q;
Producer(Q q) {
this.q = q;
new Thread(this, "Producer").start();
}
// Consumer class
class Consumer implements Runnable
{
Q q;
Consumer(Q q){
this.q = q;
new Thread(this, "Consumer").start(); }
// Driver class
class PC
{
public static void main(String args[])
{
// creating buffer queue
Q q = new Q();
}
}
Output:
There is a shared resource which should be accessed by multiple processes. There are
two types of processes in this context. They are reader and writer. Any number
of readers can read from the shared resource simultaneously, but only one writer can
write to the shared resource. When a writer is writing data to the resource, no other
process can access the resource. A writer cannot write to the resource if there are non
zero number of readers accessing the resource at that time.
The Solution
From the above problem statement, it is evident that readers have higher priority than
writer. If a writer wants to write to the resource, it must wait until there are no
readers currently accessing that resource.
while(TRUE)
{
wait(w);
/* perform the write operation */
signal(w);
}
while(TRUE)
{
//acquire lock
wait(m);
read_count++;
if(read_count == 1)
wait(w);
//release lock
signal(m);
/* perform the reading operation */
// acquire lock
wait(m);
read_count--;
if(read_count == 0)
signal(w);
// release lock
signal(m);
}
As seen above in the code for the writer, the writer just waits on the w semaphore
until it gets a chance to write to the resource.
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 53
MAILAM ENGINEERING COLLEGE CS3451 – Introduction to Operating System Univ-II
After performing the write operation, it increments w so that the next writer can
access the resource.
On the other hand, in the code for the reader, the lock is acquired whenever
the read_count is updated by a process.
The semaphore w is used by the first reader which enters the critical section
and the last reader which exits the critical section.
The reason for this is, when the first readers enters the critical section, the
writer is blocked from the resource. Only new readers can access the resource
now.
Similarly, when the last reader exits the critical section, it signals the writer
using the w semaphore because there are zero readers now and a writer can
have the chance to access the resource.
Examples of preemptive
scheduling are Round Robin Examples of non-preemptive
and Shortest Remaining Time scheduling are First Come First
Examples First. Serve and Shortest Job First
Ordinary Pipes :
Situation: These are working on a simple script that takes the output from one
program and directly pipes it into another program in a shell (e.g., in Linux or Unix).
For instance, you might want to take the output of ls and pipe it into grep to filter files
by name:
ls | grep "pattern"
Situation: You are developing a system where multiple independent programs need to
communicate with each other asynchronously. For example, you have a producer
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 55
MAILAM ENGINEERING COLLEGE CS3451 – Introduction to Operating System Univ-II
program that generates data and a consumer program that processes the data, and
you need the two to communicate across a network or over time. You can use a
named pipe (FIFO), which provides a named communication endpoint that can be
opened by both processes.
cat /tmp/my_pipe
The communication between processes can happen over time, allowing the
producer and consumer to run independently.
Named pipes allow multiple processes (both reading and writing) to access the
pipe through a shared name, making it easier to manage complex workflows.
The pipe persists beyond the scope of the process that created it, allowing for
more flexible and asynchronous communication between different processes or
systems.
Deadlock in the Dining Philosophers Problem occurs when all philosophers (or
processes) are in a state where they are each waiting for a resource that is held by
another philosopher. Here's how this can happen:
1. The Setup:
o There are five philosophers sitting around a circular table, each needing
two forks (one for the left and one for the right) to eat.
o Each philosopher picks up the fork on their left, and then the fork on
their right, to eat.
2. The Circular Wait Condition:
o Suppose each philosopher picks up the left fork at the same time.
o Now, every philosopher is holding one fork (their left one) and waiting for
the right fork to be available.
o The right fork for each philosopher is held by their neighbor.
o This creates a circular wait where each philosopher is waiting for a fork
that is being held by another philosopher.
Deadlock Conditions:
1. Mutual Exclusion: Each fork can only be held by one philosopher at a time.
2. Hold and Wait: Philosophers are holding a fork and waiting for the other fork.
3. No Preemption: A fork cannot be forcibly taken away from a philosopher once
they've picked it up.
4. Circular Wait: A cycle of philosophers exists where each philosopher is waiting
for a fork that is being held by the next philosopher in the cycle.
When all philosophers simultaneously pick up their left fork, they are all stuck in a
circular wait for the right fork, creating a deadlock situation where none of them can
proceed to eat. In this situation, no philosopher can ever finish eating because they
will never be able to acquire both forks they need.
23. Explain the difference between long-term, short-term, and medium- term
schedulers. (Nov/Dec-2024)
It is also called a
1. Alternate It is also called a It is also called a
process swapping
Name CPU scheduler. job scheduler.
scheduler.
It provides lesser
It reduces the control It controls the
2. Degree in control over the
over the degree degree of
programming degree of
of multiprogramming. multiprogramming.
multiprogramming.
4. Usage in
time- sharing It is minimal in the It is almost absent
It is a part of the time-
system time-sharing or minimal in a
sharing system.
sharing system. sharing system.
system
PART-C-CASE STUDY
SOLUTION:
a. The content of the matrix Need = Max-Allocation and is
A B C
P0 7 4 3
P1 1 2 2
P2 6 0 0
P3 0 1 1
P4 4 3 1
a. Check for
Available=Available+Allocation
Available=3 3 2+ 2 0 0
Available = 5 3 2
So request P1 is granted.
The system is currently in a safe state. The sequence <P1,P3,P4,P2,P0> satisfies the
safety state.
Request (1,0,2) , to decide whether this request can be immediately granted, we first
check that Request<=Avaliable (1,02)<=(3,3,2), which is true. So the new state will be
Allocation Need
Available
A B C A B C A B C
P0 0 1 0 7 4 3 2 3
0
P1 3 0 2 0 2 0
P2 3 0 2 6 0 0
P3 2 1 1 0 1 1
P4 0 0 2 4 3 1
The system is currently in a safe state. The sequence <P1,P3,P4,P0,P2> satisfies the
safety state.
2.Consider the following five processes, with the length of CPU burst time given
in milliseconds.
Sol:
First-Come, First-Served Scheduling
Gantt chart
P1 P2 P3 P4 P5
0 10 16 23 27 32
Waiting Time
Process Waiting Time
P1 0-0 = 0
P2 10-0 = 10
P3 16-1 = 15
P4 23-1 = 22
P5 27-2 = 25
= 72/5
= 14.4 ms
Turnaround Time
Process Turnaround
Time
P1 10+0 = 10
P2 6+10 = 16
P3 7+15 = 22
P4 4+22 = 26
P5 5+25 = 30
= 16.2 ms
Waiting Time
Process Waiting Time
P1 22-0 = 22
P2 0-0 = 0
P3 15-1 = 14
P4 6-1 = 5
P5 10-2 = 8
Gantt chart
P2 P4 P2 P5 P3 P1
0 1 5 10 15 22 32
Waiting Time
Process Waiting Time
P1 22-0-0 = 22
P2 5-0-1 = 4
P3 15-1-0 = 14
P4 1-1-0 = 0
P5 10-2-0 = 8
Turnaround Time
Process Turnaround
Time
P1 10+22 = 32
P2 6+4 = 10
P3 7+14 = 21
P4 4+0 = 4
P5 5+8 = 13
Non Preemptive SJF and Non Preemptive priority scheduling algorithm gives
minimum average waiting time as compared to other CPU scheduling algorithms.
3)Consider the following five processes that arrive at time 0, with the length of the
CPU burst time given in milliseconds.
Process CPU BURST TIME
P1 10
P2 29
P3 3
P4 7
P5 12
Consider the FCFS, non preemptive Shortest job First (SJF). Round Rabin(RR)
(quantum=10 milliseconds) scheduling algorithms. Illustrate the scheduling using
Gantt chart. Which algorithm will give the minimum average waiting time?
(APRIL/MAY-2023)
4. Consider the following set of processes, with the length of the CPU burst time
given in milliseconds.(Nov/Dec-2023)
Process Burst
Time
P1 10
P2 1
P3 2
P4 1
P5 5
a)Draw Gantt’s Chart illustrating the execution of these processes using FCFS, SJF
and Round Robin (with quantum = 1) scheduling techniques.
b) Find the Turnaround time and waiting time of each process using the above
techniques.
To solve this problem, let's start by drawing the Gantt Chart for each scheduling
technique: FCFS, SJF, and Round Robin (with a quantum of 1). Then, we'll calculate
the turnaround time and waiting time for each process using each scheduling
technique.
Given Processes:
a) Gantt Chart:
For FCFS:
Turnaround Time:
P1: 10
P2: 11
P3: 13
P4: 14
P5: 19
Waiting Time:
P1: 0
P2: 10
P3: 11
P4: 13
P5: 14
For SJF:
Turnaround Time:
P1: 19
P2: 2
P3: 15
P4: 3
P5: 14
Waiting Time:
P1: 9
P2: 0
P3: 13
P4: 1
P5: 9
For Round Robin (Quantum = 1):
Turnaround Time:
P1: 14
P2: 2
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 71
MAILAM ENGINEERING COLLEGE CS3451 – Introduction to Operating System Univ-II
P3: 15
P4: 3
P5: 19
Waiting Time:
P1: 4
P2: 0
P3: 12
P4: 1
P5: 9
These calculations should provide you with the required Gantt charts and the
turnaround time and waiting time for each process under each scheduling technique.
5. The processes are assumed to have arrived in the order P1,P2,P3,P4,P5 all at
time 0. Calculate the average turnaround time and maximum waiting time for
per- emptive scheduling algorithm.(Nov/Dec-2023)
6. Consider three processes, all arriving at time zero, with total execution time
of 10, 20 and 30 units respectively. Each process spends the first 20% of
execution time doing I/O, the next 70% of time doing computation and the last
10% of time doing I/O again. The operating system uses a shortest remaining
compute time first scheduling algorithm and schedules a new process either
when the running process gets blocked on I/O or when the running process
finishes its compute burst. Assume that all I/O operations can be overlapped as
much as possible. (Nov/Dec-2023)
To calculate the average waiting time and average turnaround time, let's follow the
Shortest Remaining Time First (SRTF) scheduling algorithm for the given processes.
Now let's simulate the execution using the SRTF scheduling algorithm and calculate
waiting time and turnaround time.
| P1 | P2 | P1 | P3 | P2 | P3 | P3 | | P1 | P2 | P1 | P3 | P2 | P3 | P3 |
(iii) Calculate CPU idle time: The CPU is idle during the time when no process is in the
ready queue. In this case, the CPU is idle during the time P1, P2, and P3 complete
their I/O operations. The total CPU idle time is 2 + 2 + 4 = 8 units.
Now, let's allocate these segments to available free slots. I'll represent the allocated
segments using arrows:
| A2 (21B) | A3 (365B) |
|--------------------| |--------------------|-------------------|-------------|
A0 50 400
A1 450 100
A2 670 21
A3 1200 365
500 A1 50 500
700 A2 50 720
Internal Fragmentation: This occurs within allocated memory blocks. Since segments
might not perfectly fit into available slots, there may be some wasted space within the
allocated memory. In this case, for example, A0 has 50 bytes of internal
fragmentation, A1 has 0 bytes, A2 has 0 bytes, and A3 has 0 bytes. Total internal
fragmentation is 50+0+0+0=5050+0+0+0=50 bytes.
External Fragmentation: This occurs between allocated memory blocks. In this case,
there is external fragmentation due to the non-contiguous allocation of segments. The
free slots are scattered, and combining them could provide larger contiguous space.
Total external fragmentation is 350+200+90+150=790350+200+90+150=790 bytes.
Total Fragmentation: This is the sum of internal and external fragmentation. In this
case, 50+790=84050+790=840 bytes.
Physical Address 1050: This falls within the allocated region of A3. The segment is A3,
and the offset is 1050−1200=−1501050−1200=−150, which is out of bounds.
Physical Address 560: This falls within the allocated region of A1. The segment is A1,
and the offset is 560−450=110560−450=110 within the allocated space.
Physical Address 78: This falls outside any allocated region.
Physical Address 2000: This falls outside any allocated region.
To calculate the Need matrix, we subtract the Allocation matrix from the Max matrix
for each process:
For T0:
Need(T0)=Max(T0)−Allocation(T0)=(0,0,1,2)−(0,0,1,2)=(0,0,0,0)\text{Need}(T0) =
\text{Max}(T0) - \text{Allocation}(T0) = (0, 0, 1, 2) - (0, 0, 1, 2) = (0, 0, 0,
0)Need(T0)=Max(T0)−Allocation(T0)=(0,0,1,2)−(0,0,1,2)=(0,0,0,0)
For T1:
Need(T1)=Max(T1)−Allocation(T1)=(1,7,5,0)−(1,0,0,0)=(0,7,5,0)\text{Need}(T1) =
\text{Max}(T1) - \text{Allocation}(T1) = (1, 7, 5, 0) - (1, 0, 0, 0) = (0, 7, 5,
0)Need(T1)=Max(T1)−Allocation(T1)=(1,7,5,0)−(1,0,0,0)=(0,7,5,0)
For T2:
Need(T2)=Max(T2)−Allocation(T2)=(2,3,5,6)−(1,3,5,4)=(1,0,0,2)\text{Need}(T2) =
\text{Max}(T2) - \text{Allocation}(T2) = (2, 3, 5, 6) - (1, 3, 5, 4) = (1, 0, 0,
2)Need(T2)=Max(T2)−Allocation(T2)=(2,3,5,6)−(1,3,5,4)=(1,0,0,2)
For T3:
Need(T3)=Max(T3)−Allocation(T3)=(0,6,5,2)−(0,6,3,2)=(0,0,2,0)\text{Need}(T3) =
\text{Max}(T3) - \text{Allocation}(T3) = (0, 6, 5, 2) - (0, 6, 3, 2) = (0, 0, 2,
0)Need(T3)=Max(T3)−Allocation(T3)=(0,6,5,2)−(0,6,3,2)=(0,0,2,0)
For T4:
Need(T4)=Max(T4)−Allocation(T4)=(0,6,5,6)−(0,0,1,4)=(0,6,4,2)\text{Need}(T4) =
\text{Max}(T4) - \text{Allocation}(T4) = (0, 6, 5, 6) - (0, 0, 1, 4) = (0, 6, 4,
2)Need(T4)=Max(T4)−Allocation(T4)=(0,6,5,6)−(0,0,1,4)=(0,6,4,2)
Process Need (A B C D)
T0 0000
T1 0750
T2 1002
T3 0020
T4 0642
To check if the system is in a safe state, we can use the Banker's Algorithm and
check whether there exists a sequence of processes that can finish (i.e., a safe
sequence). The key steps are:
T0's Need = (0, 0, 0, 0) → Can be satisfied by Available (1, 5, 2, 0). So, T0 can
finish. After T0 finishes, Available resources will be updated:
New Available=Available+Allocation(T0)=(1,5,2,0)+(0,0,1,2)=(1,5,3,2)\text{New
Available} = \text{Available} + \text{Allocation}(T0) = (1, 5, 2, 0) + (0, 0, 1, 2) = (1,
5, 3, 2)New Available=Available+Allocation(T0)=(1,5,2,0)+(0,0,1,2)=(1,5,3,2)
T1's Need = (0, 7, 5, 0) → Can be satisfied by Available (1, 5, 3, 2). So, T1 can
finish. After T1 finishes, Available resources will be updated:
New Available=(1,5,3,2)+(1,0,0,0)=(2,5,3,2)\text{New Available} = (1, 5, 3, 2) + (1,
0, 0, 0) = (2, 5, 3, 2)New Available=(1,5,3,2)+(1,0,0,0)=(2,5,3,2)
T2's Need = (1, 0, 0, 2) → Can be satisfied by Available (2, 5, 3, 2). So, T2 can
finish. After T2 finishes, Available resources will be updated:
New Available=(2,5,3,2)+(1,3,5,4)=(3,8,8,6)\text{New Available} = (2, 5, 3, 2) + (1,
3, 5, 4) = (3, 8, 8, 6)New Available=(2,5,3,2)+(1,3,5,4)=(3,8,8,6)
T3's Need = (0, 0, 2, 0) → Can be satisfied by Available (3, 8, 8, 6). So, T3 can
finish. After T3 finishes, Available resources will be updated:
New Available=(3,8,8,6)+(0,6,3,2)=(3,14,11,8)\text{New Available} = (3, 8, 8, 6) +
(0, 6, 3, 2) = (3, 14, 11, 8)New Available=(3,8,8,6)+(0,6,3,2)=(3,14,11,8)
T4's Need = (0, 6, 4, 2) → Can be satisfied by Available (3, 14, 11, 8). So, T4 can
finish. After T4 finishes, Available resources will be updated:
New Available=(3,14,11,8)+(0,0,1,4)=(3,14,12,12)\text{New Available} = (3, 14,
11, 8) + (0, 0, 1, 4) = (3, 14, 12,
12)New Available=(3,14,11,8)+(0,0,1,4)=(3,14,12,12)
Since we were able to find a sequence of processes that can finish (T0, T1, T2, T3, T4),
the system is in a safe state.
(3) If a request from thread T1 arrives for (0, 4, 2, 0), can the request be granted
immediately?
Request(T1)=(0,4,2,0)andNeed(T1)=(0,7,5,0)\text{Request}(T1) = (0, 4, 2, 0)
\quad \text{and} \quad \text{Need}(T1) = (0, 7, 5,
0)Request(T1)=(0,4,2,0)andNeed(T1)=(0,7,5,0)
Since the request (0, 4, 2, 0) is less than or equal to the Need (0, 7, 5, 0), this
condition is satisfied.
Request(T1)=(0,4,2,0)andAvailable=(1,5,2,0)\text{Request}(T1) = (0, 4, 2, 0)
\quad \text{and} \quad \text{Available} = (1, 5, 2,
0)Request(T1)=(0,4,2,0)andAvailable=(1,5,2,0)
Since the request (0, 4, 2, 0) is less than or equal to the Available resources (1,
5, 2, 0), this condition is also satisfied.
Since both conditions are satisfied, the request can be granted immediately.
4. Consider the 5 processes, A, B, C, D and E, as shown in the table. The highest number
has low Priority. Find The completion order of the 5 processes under the
policies.(Nov/Dec-2024)
(i) Draw four Gantt charts illustrating the execution of these processes using FCFS,
pre-emptive SJF, non-pre-emptive Priority and RR (Quantum= 2) scheduling.
(ii) Calculate the average waiting and turnaround times for the above
scheduling algorithms.
Gantt Chart:
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 82
MAILAM ENGINEERING COLLEGE CS3451 – Introduction to Operating System Univ-II
|A |A |A |A |A |A |B |B |B |B |C |C |D |D |D |D |E |E |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Execution Order:
|A |A |A |A |A |A |C |C |B |B |B |B |D |D |D |D |E |E |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Sorted Order:
1. E (Priority 1)
2. D (Priority 2)
3. A, C (Priority 3 → Arrival order decides)
4. B (Priority 4)
Execution Order:
|A |A |A |A |A |A |C |C |D |D |D |D |E |E |B |B |B |B |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Execution Order:
|A |A |B |B |A |A |C |C |A |A |B |B |D |D |E |E |D |D |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
5. Represent and explain the drawback of the typical 'Semaphore" solution to Dining
Philosophers' problem with pseudo code, and also provide a solution to remedy the
drawback.(Nov/Dec-2024)
In the Dining Philosophers Problem, a group of philosophers sits around a circular table with
one fork (chopstick) between each pair. To eat, a philosopher must acquire both the left and
right forks. The problem arises in ensuring no deadlocks or starvation occur while multiple
philosophers try to eat concurrently.
A typical semaphore-based solution involves using a binary semaphore (mutex) for each fork,
ensuring that philosophers pick up forks in a synchronized manner. However, this approach
can lead to deadlock if each philosopher picks up their left fork and waits indefinitely for the
right fork.
Drawback: Deadlock
If all philosophers pick up their left fork at the same time, no one will be able to acquire
their right fork.
This leads to circular waiting, where each philosopher is waiting for a resource held by
another, causing deadlock.
To prevent deadlock, we introduce a central arbitrator (waiter) who controls access to the
forks. A philosopher must request permission before picking up both forks.
Uses:
This waiter approach is one of the simplest and most effective solutions to prevent deadlocks in
the Dining Philosophers problem.
PART C
16)a) Consider the following five processes that arrive at time 0, with the length of the
CPU burst time given in milliseconds.
Process CPU BURST TIME
P1 10
P2 29
P3 3
P4 7
P5 12
Consider the FCFS, non preemptive Shortest job First (SJF). Round Rabin(RR)
(quantum=10 milliseconds) scheduling algorithms. Illustrate the scheduling using
Gantt chart. Which algorithm will give the minimum average waiting time?(Q.No:
PART- C- 3)
ANNA UNIVERSITY QUESTIONS
NOV/DEC- 2023
PART A
1.Draw the Life cycle of a Process.(Q.NO:59)
2.Compare Process creation and thread creation in terms of economy.(Q.NO:60)
PART B
1. Consider the following set of processes, with the length of the CPU burst time given
in milliseconds.(Q.NO:4)
Process Burst
Time
P1 10
P2 1
P3 2
P4 1
P5 5
a)Draw Gantt’s Chart illustrating the execution of these processes using FCFS, SJF
and Round Robin (with quantum = 1) scheduling techniques.
b) Find the Turnaround time and waiting time of each process using the above
techniques.
2. What are semaphores? How do they implement mutual exclusion?(Q.NO:10)
3. Explain the techniques used to prevent deadlocks.(Q.NO:14)
PART – C
1. Consider three processes, all arriving at time zero, with total execution time of 10,
20 and 30 units respectively. Each process spends the first 20% of execution time
doing I/O, the next 70% of time doing computation and the last 10% of time doing I/O
again. The operating system uses a shortest remaining compute time first scheduling
algorithm and schedules a new process either when the running process gets blocked
on I/O or when the running process finishes its compute burst. Assume that all I/O
operations can be overlapped as much as possible. (Q.NO:6)
2. Consider the following scenario. There are 4 segments in a program of sizes, A0=400B,
A1=100B, A2=21B and A3=365B. Assume that the main memory address ranges
from 0 to 1999, among which the following are the available free slots : 50-350, 450-
500, 670-1060 and 1200-1850. Answer the followings.(Q.NO:7)
Provide diagrammatic representation of logical memory to physical
memory
Provide segment map table and draw a suitable memory management
unit.
Find out internal, external and total fragmentation.
List the segments of following physical address: 1050, 560, 78, 2000
*****
PART A
1. Define the process states.(Q.No:3)
2. What are the threading issues?(Q.No:61)
PART B
1. Describe how processes are created and terminated in an operating system.(Q.No:3)
2. Give an example of a situation in which ordinary pipes are more suitable than named pipes and an
example of a situation in which named pipes are more suitable than ordinary pipes.(Q.No:21)
3. Describe how deadlock is possible with the dining-philosopher's problem.(Q.No:22)
4. Consider the following snapshot of a system.(CASE STUDY:Q.No:8)
PART A
1. What do you mean by cooperating process?(Q.No:62)
2. Define IPC.(Q.No:11)
PART B
1. Explain the difference between long-term, short-term, and medium- term schedulers.(Q.No:23)
2. Discuss about threads.(Q.No:5)
3. Explain deadlock prevention and avoidance.
Given 3 processes, A, B and C, three resources, x, y, and z and following events,
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 88
MAILAM ENGINEERING COLLEGE CS3451 – Introduction to Operating System Univ-II
(i) A requests x
(ii) A requests y
(iii) B requests y
(iv) B requests z
(v) C requests z
(vi) C requests x
(vii) C requests y
Assume that requested resources should always be allocated to the request process if available.
Draw the resource allocation graph for the sequences. Also, mention whether it is a deadlock.
If it is, how to recover from the deadlock.
PART C
1. Consider the 5 processes, A, B, C, D and E, as shown in the table. The highest number has low
Priority. Find The completion order of the 5 processes under the policies.(Q.No.4)
(iii) Draw four Gantt charts illustrating the execution of these processes using FCFS, pre-
emptive SJF, non-pre-emptive Priority and RR (Quantum= 2) scheduling.
(iv) Calculate the average waiting and turnaround times for the above
scheduling algorithms.
2. Represent and explain the drawback of the typical 'Semaphore" solution to Dining Philosophers'
problem with pseudo code, and also provide a solution to remedy the drawback.(Q.No.5)
*****
2 MARKS
process. Thus, it avoids reading into memory pages that will not be used anyway,
decreasing the swap time and the amount of physical memory needed.
Advantages of demand paging.
Only loads pages that are demanded by the executing process.
As there is more space in main memory, more processes can be loaded reducing
context switching time which utilizes large amounts of resources.
Less loading latency occurs at program startup, as less information is accessed from
secondary storage and less information is brought into main memory.
18. What is the various page replacement algorithms used for page replacement?
FIFO page replacement
Optimal page replacement
LRU page replacement
LRU approximation page replacement
Counting based page replacement
Page buffering algorithm
19. What are the major problems to implement demand paging? (Nov/Dec 2015)
The two major problems to implement demand paging is developing
Frame allocation algorithm and Page replacement algorithm
20. Define Thrashing. How to limit the effect of thrashing? (Apr/May 2015)
(April/May-2019)
The page is brought in and taken out of the memory and is not allowed to execute. This
technique is known as thrashing. We can limit the effects of thrashing by using a local
replacement algorithm.
iii. Write the victim page to the disk; change the page and frame tables
accordingly.
c. Read the desired page into the (newly) free frame; change the page and frame tables.
d. Restart the user process.
28. Name two differences between logical and physical addresses. (May/June
2016) (Nov/Dec-2019)
S.N Logical Address Physical Address
1 Logical address does not refer to an Physical address that refers to an
actual existing address; rather, it refers actual physical address in memory
to an abstract address in an abstract
address space.
2 A logical address is generated by the CPU Physical addresses are generated
and is translated in to a physical address by the MMU.
by the memory management unit (MMU)
(when address binding occurs at
execution time)
.30. What is thrashing? How to resolve it? (April/May-2021, 2023 & Nov/Dec-
2023)
With a computer, thrashing or disk thrashing describes when a hard drive is being
overworked by moving information between the system memory and virtual
memory excessively. Thrashing occurs when the system does not have enough memory,
the system swap file is not properly configured, too much is running at the same time,
or has low system resources. When thrashing occurs, you will notice the computer hard
drive always working, and a decrease in system performance. Thrashing is serious
because of the amount of work the hard drive has to do, and if left unfixed can cause an
early hard drive failure.
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 6
MAILAM ENGINEERING COLLEGE CS3451- Introduction to Operating System – UNIT III
31.Under what circumstances do page faults occur? State the actions taken
by the operating system when a page fault occurs. (Nov/Dec-2019)
(Nov/Dec-2024)
A page fault occurs when an access to a page that has not been brought into main
memory takes place. The operating system verifies the memory access, aborting the
program if it is invalid. If it is valid, a free frame is located and I/O is requested to read
the needed page into the free frame. Upon completion of I/O, the process table and page
table are updated and the instruction is restarted.
32. When trashing is used? (Nov/Dec-2021)
Thrashing is a condition or a situation when the system is spending a major portion of
its time in servicing the page faults, but the actual processing done is very negligible.
The basic concept involved is that if a process is allocated too few frames, then there will
be too many and too frequent page faults.
33. What is the purpose of paging the page tables? (Apr/May-2024)
A page table is a data structure used by a virtual memory system in a computer to store
mappings between virtual addresses and physical addresses.
34. Define the benefits of virtual memory.(Apr/May-2024)
It can handle twice as many addresses as main memory.
It enables more applications to be used at once.
It frees applications from managing shared memory and saves users from having
to add memory modules when RAM space runs out.
The mapping of data and computer instructions to actual memory locations is known as
address binding. In computer memory, logical and physical addresses are employed.
Additionally, the OS handles this aspect of computer memory management on behalf of
programs that need memory access.
PART-B
1)Explain about Swapping in detail. (Nov/Dec-19)
Standard Swapping:
Backing store:
Dispatcher:
Whenever the CPU scheduler decides to execute a process, it calls the dispatcher. The
dispatcher checks to see whether the next process in the queue is in memory. If it is not,
and if there is no free memory region, the dispatcher swaps out a process currently in
memory and swaps in the desired process.
The main memory must accommodate both the operating system and the various user
processes. Contiguous memory allocation is used to allocate different parts of the main
memory in the most efficient way possible.
Interrupt vector:
The interrupt vector is often in low memory; programmers usually place the
operating system in low memory as well.
Several user processes to reside in memory at the same time.
In this contiguous memory allocation, each process is contained in a single
contiguous section of memory.
Memory Protection:
Relocation Register:
The relocation register contains the value of the smallest physical address. (Example,
relocation = 100040)
Limit Register:
The limit register contains the range of logical addresses. (Example, limit = 74600).
With relocation and limit registers, each logical address must be less than the limit
register is shown in fig 3.2.
The MMU maps the logical address dynamically by adding the value in the relocation
register. This mapped address is sent to memory is shown in fig 3.3.
Memory Allocation:
Variable-partition scheme:
The operating system keeps a table indicating which parts of memory are available
and which are occupied.
When a process is allocated space, it is loaded into memory.
When a process terminates, it releases its memory, which the operating system
may then fill with another process from the input queue.
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 10
MAILAM ENGINEERING COLLEGE CS3451- Introduction to Operating System – UNIT III
Dynamic storage allocation problem, concerns how to satisfy a request of size n from a
list of free holes. Solutions for Dynamic storage allocation problem:
First fit: Allocate the first hole that is big enough.
Best fit: Allocate the smallest hole that is big enough.
Worst fit: Allocate the largest hole.
Fragmentation
External fragmentation:
Both the first-fit and best-fit strategies for memory allocation suffer from external
fragmentation.
External fragmentation exists when there is enough total memory space to satisfy
a request but the available spaces are not contiguous: storage is fragmented into a
large number of small holes.
Internal fragmentation: The memory allocated to a process may be slightly larger than
the requested memory. The difference between these two numbers is internal
fragmentation—unused memory that is internal to a partition.
Compaction:
One solution to the problem of external fragmentation is compaction.
The goal is to shuffle the Memory contents so as to place all free memory together
in one large block.
Compaction is not always possible, if relocation is static and is done at assembly
or load time, compaction cannot be done.
3.What is paging? Explain the concept of Paging and Translation Look- aside
Buffer with example(or)Explain the need and concept of paging technique in
memory management.(or) Explain paging scheme of memory management.
[April/May 2021, 2023] [Nov/Dec -2021 & Nov/Dec-2023][Nov/Dec-2024]
Paging:
Segmentation permits the physical address space of a process to be
noncontiguous. Paging is another memory-management scheme that offers this
advantage.
The paging model of memory is shown in Figure 3.5. The page size (like the frame size)
is defined by the hardware. For example page 0 is stored in frame 1 it is showed in
page table and physical memory.
The size of a page is typically a power of 2, varying between 512 bytes and 16 MB per
page, depending on the computer architecture.
The Figure 3.6. Shows that the page size is 4 bytes and the physical memory contains
32 bytes (8 pages).
Logical address 0 is page 0, offset 0. Indexing into the page table, find that page 0 is
in frame 5.
Thus, logical address 0 maps to physical address 20 (= (5 x 4) + 0).
Logical address 3 (page 0, offset 3) maps to physical address 23 (= (5 x 4) + 3).
Some CPUs and kernels even support multiple page sizes. Solaris uses 8 KB and 4 MB
page sizes, depending on the data stored by the pages. Researchers are now developing
variable on-the-fly page-size.
Fig. 3.6 Paging example for a 32 –byte memory with 4-byte page
For example, which frames are allocated, which frames are available, how many
total frames there are, and so on. This information is generally kept in a data structure
called a frame table and free frame list is shown in fig 3.7.
TLB miss:
If the page number is not in the TLB (known as a TLB miss), a memory reference to the
page table must be made.
The below diagram 3.8 shows,
The page number and frame number is presented in the TLB.
If the TLB is already full of entries, the operating system must select one for
replacement.
Replacement policies range from least recently used (LRU) to random.
Wired down:
Some TLBs allow entries to be wired down, meaning that they cannot be removed
from the TLB. Typically, TLB entries for kernel code are often wired down.
The TLBs store address-space identifiers (ASIDs) in each entry of the TLB.
An ASID uniquely identifies each process and is used to provide address space
protection for that process.
Every time a new page table is selected (for instance, each context switch), the
TLB must be flushed (or erased) to ensure that the next executing process does not
use the wrong translation information.
Hit ratio: The percentage of times that a particular page number is found in the TLB is
called the hit ratio.
Protection:
Memory protection in a paged environment is accomplished by protection bits 11
that are associated with each frame. Normally, these bits are kept in the page table.
Valid bit: When this bit is set to "valid," this value indicates that the associated page is
in the process' logical
address space, and is thus a legal (or valid) page.
Invalid bit: If the bit is set to "invalid," this value indicates that the page is not in the
process' logical-address space. Illegal addresses are trapped by using the valid-invalid
bit.
Page-table length register (PTLR): Some systems provide hardware, in the form of a
page-table length register (PTLR), to indicate the size of the page table.
This value is checked against every logical address to verify that the address is in the
valid range for the process.
Only one copy of the editor needs to be kept in physical memory. Each user's page
table maps onto the same physical copy of the editor, but data pages are mapped onto
different frames.
3) Write about the techniques for structuring the page table. (NOV/DEC 2023 &
Nov/Dec-2024)
Lets consider a process P1 of size 2 MB and the main memory which is divided
into three partitions. Out of the three partitions, two partitions are holes of size 1
MB each.
Although, there is 2 MB space available in the main memory in the form of those
holes but that remains useless until it become contiguous. This is a serious
problem to address.
We need to have some kind of mechanism which can store one process at different
locations of the memory.
The Idea behind paging is to divide the process in pages so that, we can store
them in the memory at different holes. We will discuss paging with the examples
in the next sections.
The most common techniques used for the structuring the page table.
Hierarchical Paging:
Most modern computer systems support a large logical-address space (232 to 264). In
such an environment, the page table itself becomes excessively large.
Example:
Consider a system with a 32-bit logical-address space. If the page size in such a
system is 4 KB (212), then a page table may consist of up to 1 million entries (232/212)
Assuming that each entry consists of 4 bytes, each process may need up to 4 MB
of physical-address space for the page table alone.
Clearly, we would not want to allocate the page table contiguously in main
memory.
One simple solution to this problem is to divide the page table into smaller
pieces. There are several ways to accomplish this division.
One way is to use a two-level paging algorithm, in which the page table itself is
also paged is shown in below fig 3.10.
Remember our example to our 32-bit machine with a page size of 4 KB.
A logical address is divided into a page number consisting of 20 bits, and a page offset
consisting of 12 bits.
Because we page the page table, the page number is further divided into a 10-bit page
number and a 10-bit page offset.
Fig 3.11 Address translation for a two level 32 bit paging Architecture
Where pl is an index into the outer page table and p2 is the displacement within the
page of the outer page table. The address-translation method for this architecture is
shown in Figure 3.11.
Forward-mapped page table:
Address translation works from the outer page table inwards; this scheme is also
known as a forward-mapped page table. The Pentium-II uses this architecture.
VAX Architecture:
Consider the memory management of one of the classic systems, the VAX
minicomputer from Digital Equipment Corporation (DEC).
The VAX architecture also supports a variation of two-level paging.
The VAX is a 32-bit machine with page size of 512 bytes is shown in fig 3.12.
The logical-address space of a process is divided into four equal sections, each of
which consists of 230 bytes.
The above diagram shows that, where s designates the section number, p is an index
into the page table, and d is the displacement within the page.
Section:
Each section represents a different part of the logical-address space of a process. The
first 2 high-order bits of the logical address designate the appropriate section.
Page: The next 21 bits represent the logical page number of that section.
Offset:The final 9 bits represent an offset in the desired page.
The below diagram 3.13 shows that, the size of a one-level page table for a VAX
process using one section still is 221 bits * 4 bytes per entry = 8 MB.
Inner page table:The inner page tables could conveniently be one page long, or contain
210 4-byte entries.
Outer page table:The outer page table will consist of 242 entries, or 244 bytes.
The addresses would look like:
The obvious method to avoid such a large table is to divide the outer page table
into smaller pieces.
This approach is also used on some 32-bit processors for added flexibility and
efficiency.
The below diagram 3.14 shows that, the outer page table can also be divided into
various ways, it also giving a three-level paging scheme
Suppose that the outer page table is made up of standard-size pages (210entries,
or 212 bytes); a 64-bit address space is still daunting: The outer page table is still
234 bytes large.
4)Draw the diagram of segmentation memory management scheme and explain its
principle. [April/May2010] [Nov/Dec 2017]
stack frame entry in the stack, the fifth instruction of the Sqrt() is shown in fig
3.17.
Segment name
Offset.
Normally, the user program is compiled, and the compiler automatically constructs
segments reflecting the input program. A Pascal compiler might create separate
segments for the following:
1. The code
2. Global variables
3. The heap, from which memory is allocated
4. The stacks used by each thread
5. The standard C library
Segmentation Hardware:
Segment table:
Each entry of the segment table has a segment base and a segment limit.
The segment base contains the starting physical address where the segment
resides in memory, whereas the segment limit specifies the length of the segment.
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 24
MAILAM ENGINEERING COLLEGE CS3451- Introduction to Operating System – UNIT III
Virtual memory is a technique that allows the execution of processes that may not
be completely in memory.
Advantages:
Disadvantages:
Virtual memory involves the separation of user logical memory from physical memory.
This separation allows an extremely large virtual memory to be provided for
programmers when only a smaller physical memory is available.
Fig 3.19. Diagram showing virtual memory that is larger than physical memory
The virtual address space of a process refers to the logical (or virtual) view of
how a process is stored in memory.
Typically, this view is that a process begins at a certain logical address—say,
address 0—and exists in contiguous memory physical memory may be
organized in page frames and that the physical page frames assigned to a
process may not be contiguous.
It is up to the memory management unit (MMU) to map logical pages to
physical page frames in memory.
Allow heap to grow upward in memory as it is used for dynamic memory
allocation.
Similarly, allow for the stack to grow downward in memory through successive
function calls.
The large blank space (or hole) between the heap and the stack is part of the
virtual address space but will require actual physical pages only if the heap or
stack grows is shown in fig 3.20.
Sparse:
Virtual address spaces that include holes are known as sparse address spaces.
Using a sparse address space is beneficial because the holes can be filled as
the stack or heap segments grow or if we wish to dynamically link libraries (or
possibly other shared objects) during program execution.
When we want to execute a process, we swap it into memory. Rather than swapping
the entire process into memory, however, we use a lazy swapper.
Lazy swapper:
A lazy swapper never swaps a page into memory unless that page will be needed.
Since we are now viewing a process as a sequence of pages, rather than as one
large contiguous address space, use of swap is technically incorrect.
Valid-If the bit is set to "valid," this value indicates that the associated page is
both legal and in memory.
Invalid-If the bit is set to "invalid," this value indicates that the page either is
not valid (that is, not in the logical address space of the process), or is valid but
is currently on the disk.
While the process executes and accesses pages that are memory resident, execution
proceeds normally.
Page-fault trap:
Access to a page marked invalid causes a page-fault trap.
The paging hardware, in translating the address through the page table, If the invalid bit
is set, causing a trap to the operating system is shown in fig 3.23
This trap is the result of the operating system's failure to bring the desired page into
memory rather than an invalid address error as a result of an attempt to use an illegal
memory address.
We check an internal table (usually kept with the process control block) for this
process, to determine whether the reference was a valid or invalid memory access.
If the reference was invalid, we terminate the process. If it was valid, but we have
not yet brought in that page, we now page it in.
We find a free frame (by taking one from the free-frame list, for example).
Pure demand paging:
After this page is brought into memory, the process continues to execute, faulting as
necessary until every page that it needs is in memory. At that point, it can execute with
no more faults. This scheme is pure demand paging: Never bring a page into memory
until it is required.
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 30
MAILAM ENGINEERING COLLEGE CS3451- Introduction to Operating System – UNIT III
Locality of reference:
Page table: This table has the ability to mark an entry invalid through a valid-invalid
bit or special value of protection bits.
Secondary memory: This memory holds those pages that are not presenting main
memory. The secondary memory is usually a high-speed disk. It is known as the swap
device, and the section of disk used for this purpose is known as swap space.
Demand paging can have a significant effect on the performance of a computer system.
To compute the effective access time for a demand paged memory.
Page replacement:
If no frame is free, we find one that is not currently being used and free it. We can free a
frame by writing its contents to swap space, and changing the page table (and all other
tables) to indicate that the page is no longer in memory. Use the freed frame to hold the
page for which the process faulted is shown in fig 3.24.
Basic Scheme:
3. Read the desired page into the (newly) free frame; change the page and frame tables.
4. Restart the user process.
If no frames are free, two-page transfers (one out and one in) are required. This
situation effectively doubles the page-fault service time and increases the effective
access time accordingly.
Each page or frame may have a modify bit associated with it in the hardware. The
modify bit for a page is set by the hardware whenever any word or byte in the page is
written into, indicating that the page has been modified.
If the modify bit is set, we know that the page has been modified since it was read
in from the disk.
If the modify bit is not set, however, the page has not been modified since it was
read into memory. Therefore, if the copy of the page on the disk has not been overwritten
(by some other page, for example), then we can avoid writing the memory page to the
disk: it is already there.
This technique also applies to read-only pages. Such pages cannot be modified;
thus, they may be discarded when desired is shown in fig 3.25.
.
Fig 3.25 Page replacement
Frame-allocation algorithm
Page-replacement algorithm.
Reference string:
12) With neat diagram explain the different page replacement algorithms.(or)
Explain first in first out page replacement algorithm and optimal page
replacement algorithm with an example and diagrams [April/May-
2021,23][Nov/Dec-2021]
Although FIFO is simple and easy, it is not always optimal, or even efficient.
An interesting effect that can occur with FIFO is Belady's anomaly, in which increasing
the number of frames available can actually increase the number of page faults that
occur is shown in fig 3.28.
Consider, for example, the following chart based on the page sequence (1, 2, 3, 4, 1, 2,
5, 1, 2, 3, 4, 5 ) and a varying number of available frames. Obviously, the maximum
number of faults is 12 (every request generates a fault), and the minimum number is 5
(each page loaded only once), but in between there are some interesting results:
Fig 3.28 Page fault curve for FIFO replacement on a reference string
The discovery of Belady's anomaly led to the search for an optimal page-replacement
algorithm, which is simply that which yields the lowest of all possible page-faults, and
which does not suffer from Belady's anomaly.
Such an algorithm does exist, and is called OPT or MIN. This algorithm is simply
"Replace the page that will not be used for the longest time in the future."
For example, Figure 3.29 shows that by applying OPT to the same reference string used
for the FIFO example, the minimum number of possible page faults is 9. Since 6 of the
page-faults are unavoidable ( the first reference to each new page ), FIFO can be shown
to require 3 times as many ( extra ) page faults as the optimal algorithm.
The prediction behind LRU, the Least Recently Used, algorithm is 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
Figure 3.30 illustrates LRU for our sample string, yielding 12 page faults, ( as compared
to 15 for FIFO and 9 for OPT. )
13) Write notes about the Thrashing and its effects.(Nov/Dec 2015)
Thrashing:
Thrashing is the coincidence of high page traffic and low CPU efficiency.
The high paging activity is called thrashing.
If the process does not have number of frames it needs to support pages in active
use, it will quickly page fault.A process is thrashing if it is spending more time
paging than executing.
Cause of Thrashing:
Thrashing results in severe performance problems.
Consider the following scenario, which is based on the actual behavior of early paging
systems.
The operating system monitors CPU utilization. If CPU utilization is too low, we
increase the degree of multiprogramming by introducing a new process to the system
is shown in fig 3.31.
A global page-replacement algorithm is used; it replaces pages with no regard to the
process to which they belong.
The CPU scheduler sees the decreasing CPU utilization, and increases the degree of
multiprogramming as a result.
If the degree of multiprogramming is increased further, thrashing sets in and CPU
utilization drops sharply
If A is too small, it will not encompass the entire locality; if A is too large, it may
overlap several localities.
In the extreme, if A is infinite, the working set is the set of pages touched during the
process execution. The most important property of the working set is its size.
If we compute the working-set size, WSSi, for each process in the system, we can
then consider
Where D is the total demand for frames. Each process is actively using the pages in
its working set. Thus, process i needs WSSi frames.
If the total demand is greater than the total number of available frames (D > m),
thrashing will occur, because some processes will not have enough frames.
Page-Fault Frequency :
A strategy that uses the page-fault frequency (PFF) takes a more direct approach.
Both paging and segmentation have advantages and disadvantages. In fact, of the two
most popular microprocessors now being used, the Motorola is designed based on a flat-
address space, whereas the Intel 80x86 and Pentium family are based on segmentation.
Both are merging memory models toward a mixture of paging and segmentation. We
can combine these two methods to improve on each.
This combination is best illustrated by the architecture of the Intel 386. The IBM
OS/2 32-bit version is operating system running on top of the Intel 386 (and later)
architecture.
The Intel 386 uses segmentation with paging for memory management.
The maximum number of segments per process is 16 KB, and each segment can be
as large as 4 gigabytes. The page size is 4 KB.
The logical-address space of a process is divided into two partitions:
o The first partition consists of up to 8 KB segments that are private to that
process.
o The second partition consists of up to 8 KB segments that are shared
among all the processesis shown in fig 3.34.
Local descriptor table (LDT):
o Information about the first partition is kept in the local descriptor table
(LDT).
Global descriptor table (GDT):
o Information about the second partition is kept in the global descriptor
table (GDT).
Each entry in the LDT and GDT consists of 8 bytes, with detailed information about a
particular segment including the base location and length of that segment.
Linear address:
The base and limit information about the segment in question are used to generate a
linear address.
First, the limit is used to check for address validity. If the address is not valid, a
memory fault is generated, resulting in a trap to the operating system.
If it is valid, then the value of the offset is added to the value of the base, resulting in
a 32-bit linear address. This address is then translated into a physical address.
The linear address is divided into a page number consisting of 20 bits, and a page
offset consisting of 12 bits is shown in fig 3.35.
The page table, the page number is further divided into a 10-bit page directory pointer
and a 10-bit page table pointer.
1.Copy on Write:
This works by allowing the parent and child processes to initially share the same pages.
These shared pages are marked as Copy on Write pages.
Traditionally, fork() worked by creating a copy of the parent’s address space for the
child, duplicating the pages belonging to the parent.
However, considering that many child processes invoke the exec() system call
immediately after creation, the copying of the parent’s address space may be
unnecessary. Instead, we can use a technique known as copy-on-write, which
works by allowing the parent and child processes initially to share the same
pages. These shared pages are marked as copy-on-write pages, meaning that if
either process writes to a shared page, a copy of the shared page is created.
Copy-on-write is illustrated in Figures 3.37 and 3.38, which show the contents of the
physical memory before and after process 1 modifies page C.
For example, assume that the child process attempts to modify a page containing
portions of the stack, with the pages set to be copy-on-write.
The operating system will obtain a frame from the free frame list and create a copy of
this page, mapping it to the address space of the child process.
The child process will then modify its copied page and not the page belonging to
the parent process. Obviously, when the copy-on-write technique is used, only the
pages that are modified by either process are copied; all unmodified pages can be
shared by the parent and child processes.
Several versions of UNIX (including Linux, macOS, and BSD UNIX) provide a
variation of the fork() system call—vfork() (for virtual memory fork)— that operates
differently from fork() with copy-on-write. With vfork(), theparent process is
suspended, and the child process uses the address space of the parent.
Because vfork() does not use copy-on-write, if the child process changes any pages
of the parent’s address space, the altered pages will be visible to the parent once it
resumes.
Therefore, vfork() must be used with caution to ensure that the child process does
not modify the address space of the parent.
vfork() is intended to be used when the child process calls exec() immediately after
creation. Because no copying of pages takes place, vfork()
Consider a simple case of a system with 128 frames. The operating system may take 35,
leaving 93 frames for the user process. Under pure demand paging, all 93 frames would
initially be put on the free-frame list. When a user process started execution, it would
generate a sequence of page faults.
The first 93-page faults would all get free frames from the free-frame list. When
the free-frame list was exhausted, a page-replacement algorithm would be used to
select one of the 93 in-memory pages to be replaced with the 94th, and so on.
When the process terminated, the 93 frames would once again be placed on the
free-frame list.
There are many variations on this simple strategy. We can require that the
operating system allocate all its buffer and table space from the free-frame list.
When this space is not in use by the operating system, it can be used to support
user paging.
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 42
MAILAM ENGINEERING COLLEGE CS3451- Introduction to Operating System – UNIT III
We can try to keep three free frames reserved on the free-frame list at all times. Thus,
when a page fault occurs, there is a free frame available to page into. While the page
swap is taking place, a replacement can be selected, which is then written to the storage
device as the user process continues to execute. Other variants are also possible, but
the basic strategy is clear: the user process is allocated any free frame.
Our strategies for the allocation of frames are constrained in various ways. We cannot,
for example, allocate more than the total number of available frames (unless there is
page sharing.
We must also allocate at least a minimum number of frames. Here, we look more
closely at the latter requirement.
What are the physical addresses for the following logical addresses?
a. 0, 430 b. 1, 10 c. 2, 500 d. 3, 400 e. 4, 112
What are the physical addresses for the logical addresses 3400 and 0110?
90
Segment 2
190
219
Segment 0
819
1327
Segment 3
1907
1952
Segment 4
2048
2300
Segment 1
2314
21) Given memory partitions of 100KB, 500KB, 200KB, 300KB and 600KB (in
order), how would each of the first fit, best fit and worst fit algorithms place
processes of 212KB, 417KB, 112Kband 426KB(in order)? Which algorithm makes
the most efficient use of memory? (Nov/Dec 2015)
100KB
500KB
200KB
300KB
600KB
Solution:
FIRST FIT:
212KB is put in 500KB partition
417KB is put in 600KB partition
112KB is put in 288KB partition (new partition 288KB=500KB-212KB)
426KB must wait
BEST FIT:
212KB is put in 300KB partition
417KB is put in 500KB partition
112KB is put in 200KB partition
426KB is put in 600KB partition
WORST FIT:
212KB is put in 600KB partition
417KB is put in 500KB partition
112KB is put in 388KB partition
426KB must wait (In this example, Best fit turns out to be the best.)
22) On a system with paging, a process cannot access memory that it does not
own. Why? How could the operating system allow access to additional memory?
Why should it or should it not?
A process cannot access memory it does not own in a system with paging because of
memory protection. The operating system uses paging to divide memory into small,
fixed-size blocks (pages). Each process is assigned its own set of pages, and the memory
management unit (MMU) ensures that processes can only access the pages allocated to
them. This protects the memory space of each process, preventing one process from
reading or modifying the memory of another, which helps maintain stability and
security.
The operating system could allow a process to access additional memory through
techniques such as:
Yes, it may be appropriate in some cases. For example, shared memory between
processes is crucial for certain types of communication or when allocating memory
for kernel and user-space interactions.
No, unrestricted access to memory should generally not be allowed. Allowing one
process to access memory it does not own can introduce significant security risks
(e.g., allowing a malicious process to read or write to another process’s memory),
potentially causing system crashes, data corruption, or breaches in privacy.
Thus, the OS must carefully control memory access to ensure processes only interact
with their own allocated memory (and shared areas when necessary) to maintain system
stability, security, and integrity.
23) Under what circumstances do page faults occur? Describe the actions taken by
the operating system when a page fault occurs. (Apr/May-2024 & Nov/Dec-2024)
A page fault occurs when a process tries to access a page in virtual memory that is not
currently loaded into physical memory (RAM). This can happen under the following
circumstances:
1. Page Not in RAM: The page the process is trying to access is not in the main
memory but stored in secondary storage (e.g., the hard drive or SSD).
2. Page Swap: The page might have been swapped out to disk due to memory
pressure (i.e., other pages were loaded into RAM).
3. Invalid Memory Access: If a process tries to access a page it is not allowed to
access (e.g., accessing an address outside its allocated range), this can also trigger
a page fault, but it could indicate an error like a bug or a malicious attempt to
access restricted memory.
When a page fault happens, the operating system takes the following actions:
Multiple Partitioning
This technique allows more than one processes to be loaded into main memory.
In this type of allocation, main memory is divided into two types partitions.
1. fixed-sized partitions.
2. Variable-sized partitions.
Fixed - sized Partitioning : (Oldest Technique)
It is also called Static Partitioning.
In this technique, main memory is pre-divided into fixed size
partitions.(Figure 3.42)
In this partitioning, the number of partitions in Main memory is fixed but the
size of each partition may or may not be the same.
The operating system always resides in the first partition while the other
partitions can be used to store user processes.
Only one process can be placed in a partition.
The partitions cannot overlap. (no join)
A process must be contiguously present in a partition for the execution.
VARIABLE PARTITIONS
It is also called Dynamic Partitioning.
In this technique, main memory is not divided into fixed size
partitions.(Figure 3.43)
In this technique, the partition size is not declared initially. It is declared at the
time of process loading.
The first partition is reserved for the operating system. The remaining space is
divided into processes.
The size of each partition will be equal to the size of the process.
The partition size varies according to the need of the process so that the internal
fragmentation can be avoided.
The size of each frame must be uniform. The page size must match the frame
size since the frames in Paging are mapped to the pages.
CASE STUDY
1.Consider the following page-reference string:[Apr/May- 15]
[Nov/Dec2015]{April/May-2019)(Nov/Dec-19)(Nov/Dec-2023)
1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3,6.
How many page faults would occur for the following replacement algorithms,
assuming one, two, three, four, five, six, or seven frames? Remember that all
frames are initially empty, so your first unique pages will all cost one fault each.
LRU replacement
FIFO replacement
Optimal replacement
(or)
Sol:
a) One frames:
As there is no page referenced more than once all the algorithms viz LRU, FIFO and
Optimal will result in 20 page faults.
b) Two frames:
LRU:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 3 3 2 2 5 5 2 2 2 7 7 3 3 1 3 3
2 2 4 4 1 1 6 6 1 3 3 6 6 2 2 2 6
Total page fault: 18
FIFO:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 3 3 2 2 5 5 2 2 3 3 6 6 2 2 3 3
2 2 4 4 1 1 6 6 1 1 7 7 3 3 1 1 6
Total page fault: 18
Optimal:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 3 4 1 5 6 1 3 3 3 3 1 1 6
2 2 2 2 2 2 2 2 7 6 2 2 3 3
Total page fault: 15
c) Three frames:
LRU:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 4 4 5 5 5 1 1 7 7 2 2 2
2 2 2 2 2 6 6 6 3 3 3 3 3 3
3 3 1 1 1 2 2 2 2 6 6 1 6
Total page fault: 15
FIFO:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 4 4 4 6 6 6 3 3 3 2 2 2 6
2 2 2 1 1 1 2 2 2 7 7 7 1 1 1
3 3 3 5 5 5 1 1 1 6 6 6 3 3
Total page fault: 16
Optimal:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 3 3 3 3 6
2 2 2 2 2 2 7 2 2 2
3 4 5 6 6 6 6 1 1
Total page fault: 11
d) Four frames:
LRU:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 1 1 6 6
2 2 2 2 2 2 2 2 2
3 3 5 5 3 3 3 3
4 4 6 6 7 7 1
Total page fault: 10
FIFO:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 5 5 5 5 3 3 3 3 1 1
2 2 2 2 6 6 6 6 7 7 7 7 3
3 3 3 3 2 2 2 2 6 6 6 6
4 4 4 4 1 1 1 1 2 2 2
Total page fault: 14
Optimal:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 7 1
2 2 2 2 2 2 2
3 3 3 3 3 3
4 5 6 6 6
Total page fault: 8
e) Five frames:
LRU:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 1 1
2 2 2 2 2 2 2
3 3 3 6 6 6
4 4 4 3 3
5 5 5 7
Total page fault: 8
FIFO:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 6 6 6 6 6
2 2 2 2 2 1 1 1 1
3 3 3 3 3 2 2 2
4 4 4 4 4 3 3
5 5 5 5 5 7
Total page fault: 10
Optimal:
1 2 3 42 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 3 3
4 4 4 7
5 6 6
Total page fault: 7
f) Six frames:
LRU:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 6 3
4 4 4 7
5 5 5
6 6
Total page fault: 7
FIFO:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 6 7 7 7 7
2 2 2 2 2 2 1 1 1
3 3 3 3 3 3 2 2
4 4 4 4 4 4 3
5 5 5 5 5 5
6 6 6 6 6
Total page fault: 10
Optimal:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 3 3
4 4 4 7
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 54
MAILAM ENGINEERING COLLEGE CS3451- Introduction to Operating System – UNIT III
5 5 5
6 6
Total page fault: 7
g) Seven frames:
LRU:
1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 6 3
4 4 4 7
5 5 5
6 6
7
Total page fault: 7 FIFO and Optimal will also be same as above.
A TLB miss occurs when the address being referenced is not found in the TLB
(Translation Lookaside Buffer), and a page fault occurs when the requested page is not
in physical memory. However, a TLB miss with no page fault can happen when the
virtual page exists in memory but is not present in the TLB.
Assume the virtual memory page exists in physical memory (it is mapped to a
valid physical page), but the entry for this page is not in the TLB. This could occur
because the TLB is a limited cache and may have evicted older entries, so it has to
go through the page table to translate the address to a physical address.
The page table lookup is successful (no page fault), but the TLB does not have the
entry, so a TLB miss occurs.
Once the TLB miss is handled, the program can continue execution with the page
already loaded in physical memory.
A TLB miss with page fault occurs when a virtual address is not found in the TLB, and
in addition, the page is not in physical memory (i.e., the page is not mapped to a valid
physical address, and a page fault is triggered).
A TLB hit with no page fault occurs when the TLB contains the entry for the virtual
address being accessed, and the corresponding page is already in physical memory (no
page fault occurs).
The program accesses a virtual address, and the address translation is found in
the TLB.
The page table entry points to a valid physical page already present in memory
(i.e., the page is already in physical memory).
No page fault occurs, as the page is already resident in memory, and the
translation can be completed using the TLB hit.
A TLB hit with page fault seems like a contradiction at first because a TLB hit implies
the virtual address is already mapped, while a page fault indicates the page isn't in
memory. However, this can occur in a scenario where the TLB entry is valid, but the
page table entry points to a valid address in memory that is not currently resident (for
example, the page could have been swapped out).
The program accesses a virtual address, and the translation is found in the TLB (a
TLB hit).
However, when the page table is checked to ensure the page is in memory, the
page is not found in physical memory (for example, it may have been swapped out
to disk).
This causes a page fault, even though the TLB hit occurred because the page is
not currently in memory.
The page is then swapped into memory from secondary storage, and once the page
is in memory, the program can resume execution.
3. Apply the (i) FIFO, (ii) LRU, and (iii) optimal (OPT) replacement algorithms for
the page-reference strings: 4, 2, 1, 7, 9, 8, 3, 5, 2, 6, 8, 1, 0, 7, 2, 4, 1, 3, 5, 8
Indicate the number of page faults for each algorithm assuming demand paging
with three frames.(Apr/May-2024)
We replace the least recently used page when a page fault occurs.
We replace the page that will not be used for the longest time in the future.
70120304230321201701234
Number of frames: 4
1. Least-Recently-Used (LRU):
LRU replaces the page that hasn't been used for the longest period of time.
1. 7 → [7] → Fault
2. 0 → [7, 0] → Fault
3. 1 → [7, 0, 1] → Fault
4. 2 → [7, 0, 1, 2] → Fault
5. 0 → [7, 1, 2] → Hit (0 is already in the frame)
6. 3 → [1, 2, 0, 3] → Fault (7 replaced)
7. 0 → [1, 2, 3] → Hit (0 is in the frame)
8. 4 → [2, 3, 0, 4] → Fault (1 replaced)
9. 2 → [3, 0, 4] → Hit (2 is in the frame)
10. 3 → [0, 4, 2] → Hit (3 is in the frame)
11. 0 → [4, 2, 3] → Hit (0 is in the frame)
12. 3 → [4, 2, 0] → Hit (3 is in the frame)
13. 2 → [4, 0, 3] → Hit (2 is in the frame)
14. 1 → [0, 3, 4, 1] → Fault (2 replaced)
15. 2 → [3, 4, 1, 2] → Fault (0 replaced)
16. 0 → [4, 1, 2, 0] → Fault (3 replaced)
17. 1 → [4, 2, 0] → Hit (1 is in the frame)
18. 7 → [2, 0, 1, 7] → Fault (4 replaced)
19. 0 → [2, 1, 7] → Hit (0 is in the frame)
20. 1 → [2, 7] → Hit (1 is in the frame)
21. 2 → [7, 1] → Hit (2 is in the frame)
22. 3 → [1, 7, 2] → Fault (4 replaced)
23. 4 → [7, 1, 2, 3] → Fault (7 replaced)
LRU Hits: 13
2. First-In-First-Out (FIFO):
FIFO replaces the oldest page (the first one that was loaded) when a new page needs to
be placed in a full frame.
1. 7 → [7] → Fault
2. 0 → [7, 0] → Fault
3. 1 → [7, 0, 1] → Fault
4. 2 → [7, 0, 1, 2] → Fault
5. 0 → [7, 1, 2] → Hit
6. 3 → [1, 2, 0, 3] → Fault (7 replaced)
7. 0 → [1, 2, 3] → Hit
8. 4 → [2, 3, 0, 4] → Fault (1 replaced)
9. 2 → [3, 0, 4] → Hit
10. 3 → [0, 4, 2] → Hit
11. 0 → [4, 2, 3] → Hit
12. 3 → [4, 2, 0] → Hit
13. 2 → [4, 0, 3] → Hit
14. 1 → [0, 3, 4, 1] → Fault (2 replaced)
15. 2 → [3, 4, 1, 2] → Fault (0 replaced)
PREPARED BY : Mr. D. Srinivasan, AP/CSE, Mr. R. Arunkumar,AP/CSE & Mrs. A.Thilagavathi,AP/CSE 60
MAILAM ENGINEERING COLLEGE CS3451- Introduction to Operating System – UNIT III
FIFO Hits: 11
3. Optimal Replacement:
Optimal replacement replaces the page that will not be needed for the longest period of
time in the future.
1. 7 → [7] → Fault
2. 0 → [7, 0] → Fault
3. 1 → [7, 0, 1] → Fault
4. 2 → [7, 0, 1, 2] → Fault
5. 0 → [7, 1, 2] → Hit
6. 3 → [1, 2, 0, 3] → Fault (7 replaced)
7. 0 → [1, 2, 3] → Hit
8. 4 → [2, 3, 0, 4] → Fault (1 replaced)
9. 2 → [3, 0, 4] → Hit
10. 3 → [0, 4, 2] → Hit
11. 0 → [4, 2, 3] → Hit
12. 3 → [4, 2, 0] → Hit
13. 2 → [4, 0, 3] → Hit
14. 1 → [0, 3, 4, 1] → Fault (2 replaced)
15. 2 → [3, 4, 1, 2] → Fault (0 replaced)
16. 0 → [4, 1, 2, 0] → Fault (3 replaced)
17. 1 → [4, 2, 0] → Hit
18. 7 → [2, 0, 1, 7] → Fault (4 replaced)
19. 0 → [2, 1, 7] → Hit
20. 1 → [2, 7] → Hit
21. 2 → [7, 1] → Hit
22. 3 → [1, 7, 2] → Fault (4 replaced)
23. 4 → [7, 1, 2, 3] → Fault (2 replaced)
Optimal Hits: 13
Best Algorithm: LRU and Optimal are tied with a hit ratio of approximately
0.565. However, Optimal is generally considered the best algorithm theoretically
because it has the lowest number of page faults. But in practice, LRU is often
used because it's easier to implement and doesn't require knowledge of future
page accesses, unlike Optimal, which is impractical in real systems.
Why: LRU and Optimal both perform well for this specific reference string, but
LRU is preferred for real-world applications because it's more feasible to
implement, even though the hit ratio for Optimal may be slightly better in theory.
PART B
1. 13)a) What is paging? Elaborate paging with an example and a diagram. (Q.No:3 )
3. b) Explain first in first out page replacement algorithm and optimal page replacement algorithm with an
example and diagrams. (Q.No:12 )
PART B
1. Explain the need and concept of paging technique in memory management. (Q.NO:3)
2. Consider the page reference string : 1 2 3 4 1 3 0 1 2 4 1 and 3 page frames. Find the page faults, hit
ratio and miss ratio using FIFO, optimal page replacement and LRU schemes.(Q.NO:1[case study])
PART B
1. Explain the difference between internal and external fragmentation.(part-A-Q.No.23)
2. On a system with paging, a process cannot access memory that it does not own. Why? How could the
Operating system allows access to additional memory? Why should it or should it not?(Q.No.22)
3. Illustrate how pages are loaded into memory using demand paging.(Q.No.8)
4. Under what circumstances do page faults occur? Describe the actions taken by the operating system when
a page fault occurs.(Q.No.23)
PART - C
1. Assume that a program has just referenced an address in virtual memory. Describe a scenario in
which each of the following can occur.(Q.No.2)[Case Study]
(If no such scenario can occur, explain why)
(i) TLB miss with no page fault
(ii) TLB miss with page fault
(iii) TLB hit with no page fault
(iv) TLB hit with page fault
2. Apply the (i) FIFO, (ii) LRU, and (iii) optimal (OPT) replacement algorithms for the page-reference
strings:(Q.No.3)[Case Study]
4, 2, 1, 7, 9, 8, 3, 5, 2, 6, 8, 1, 0, 7, 2, 4, 1, 3, 5, 8
Indicate the number of page faults for each algorithm assuming demand paging with three frames.
PART B
UNIT IV
I/O SYSTEMS
.
Mass Storage system – Disk Structure - Disk Scheduling and Management; File-System Interface - File concept - Access
methods - Directory Structure - Directory organization - File system mounting - File Sharing and Protection; File System
Implementation - File System Structure - Directory implementation - Allocation Methods - Free Space Management; I/O
Systems – I/O Hardware, Application I/O interface, Kernel I/O subsystem
PART A
1. Define bus.
A bus is a set of wires and a rigidly defined protocol that specifies a set of messages that can be
sent on the wires. When device A has a cable that plugs into device B, and device B has a cable that plugs
into device C, and device C plugs into a port on the computer, this arrangement is called a daisy chain. A
daisy chain usually operates as a bus.
2. Define controller.
A controller is a collection of electronics that can operate a port, a bus, or a device. A serial port
controller is a simple device controller. It is a single chip in the computer that controls the signals on the wires
of a serial port.
3. How can the processor give commands and data to a controller to accomplish an I/O transfer?
The short answer is that the controller has one or more registers for data and control signals. The processor
communicates with the controller by reading and writing bit patterns in these registers.
5. What is polling?
A communications technique that determines when a terminal is ready to send data. The computer
continually interrogates its connected terminals in a round robin sequence. If a terminal has data to send, it
sends back an acknowledgment and the transmission begins. Contrast with an interrupt-driven system, in
which the terminal generates a signal when it has data to send.
15. What is rotational latency and Seek time? [Nov/Dec 2010] [Apr/May 2013]
Once the head is at right track, it must wait until the desired block rotates under the read- write head.
This delay is latency time or rotational latency. The time taken by the head to move to the appropriate
cylinder or track is called seek time.
17. What is the various disk-scheduling algorithms? Which disk scheduling algorithm would be best
to optimize the performance of a RAM disk?
The various disk-scheduling algorithms are
First Come First Served Scheduling
Shortest Seek Time First Scheduling
SCAN Scheduling
C-SCAN Scheduling
LOOK scheduling
27. Writable CD-ROM media are available in both 650 MB and 700 MB versions. What is the
principal disadvantage, other than cost, of the 700 Mb versions? [Nov/Dec 2011]
Data capacity is higher.
Low sectors
Space used for error correction data is high
28. Write the three basic functions which are provided by the hardware clocks and timers. [Apr/May
2011]
Give the current time
Give the elapsed time
Set a timer to trigger operation X at time T
29. What characteristics determine the disk access speed? [Apr/May 2012]
Disk Bandwidth: Bandwidth= total no of data transferred / total amount of time from the first request being
made to the last transfer being completed.
Access Time: The access time or response time of a rotating drive is a measure of the time it takes before the
drive can actually transfer data.
The access time has two major components:
Seek time
Rotational latency
30. Draw a diagram for interrupt driven I/O cycle. [Nov/Dec 13]
36. List the various file attributes. [Apr/May 2014, 15 & 2021]
A file has certain other attributes, which vary from one operating system to another, but typically consist of
these: Name, identifier, type, location, size, protection, time, date and user identification
37.What are the various file operations? [Nov/Dec 2010] [Apr/May 2015]
The six basic file operations are
Creating a file
Writing a file
Reading a file
Repositioning within a file
Deleting a file
Truncating a file
42. What are the most common schemes for defining the logical structure of a directory?
The most common schemes for defining the logical structure of a directory
Single-Level Directory
Two-level Directory
Tree-Structured Directories
Acyclic-Graph Directories
General Graph Directory
47. What are the functions of virtual file system (VFS)? (or) Identify the two important functions
of VFS layer in the concept of file system implementation. (Nov/Dec 2015)
a. It separates file-system-generic operations from their implementation defining a clean VFS interface.
It allows transparent access to different types of file systems mounted locally.
b. VFS is based on a file representation structure, called a vnode. It contains a numerical value for a
network-wide unique file .The kernel maintains one vnode structure for each active file or directory.
55. How can the index blocks be implemented in the indexed allocation scheme?
The index block can be implemented as follows
Linked scheme
Multilevel scheme
Combined scheme
56. What does the FCB (file control block) consists of? [Apr/May 2011 &14]
A FCB contains the files information, ownership, and permission and file location contents.
57. What does the partition control block consist of? [Apr/May 2014]
It contains the partition details, such as the number of blocks in the partition, blocks
size, free block count and pointers of free block, and free FCB count and FCB pointers.
66. Define FAT. (or) Do FAT file system is advantageous? Why? [Nov/Dec 2013, 15 &2021]
The File Allocation Table, FAT, used by DOS is a variation of linked allocation, where all the links are
stored in a separate table at the beginning of the disk. The benefit of this approach is that the FAT table can be
cached in memory, greatly improving random access speeds.
67. Mention the two approaches to identify and reuse free memory area in a heap. [Apr/May 2013]
First fit: Allocate the first hole that is big enough. Searching can start either at the beginning of the
set of holes or where the previous first-fit search ended. We can stop searching as soon as we find a free hole
that is large enough.
Best fit: Allocate the smallest hole that is big enough. We must search the entire list, unless the list is
kept ordered by size. This strategy produces the smallest leftover hole.
Worst fit: Allocate the largest hole. Again, we must search the entire list, unless it is sorted by size.
This strategy produces the largest leftover hole, which may be more useful than the smaller leftover hole from
a best-fit approach.
Directory: Directory is a collection of files stored as a group, say it is a group of files with single name. A
directory can be classified into two types.
Root Directory: root is the parent of total directories, say main drive or main filesystem (/) is the root
directory.
Sub directory: these are the directories that comes under the root directory in hierarchy, in general a
directory within a director can be called as sub directory.
File: Files are collection of data items stored in a disk or it is a device which can store the information like
data, music (mp3, ogg), photographs, movie, sound, book etc. It is like every thing you store in a system
should be a file. Files are always associated with devices like hard disk, floppy disk etc. File is the last object
in your file system tree.
Free Space Management in operating systems involves keeping track of unused space on storage
devices to efficiently allocate and deallocate space for files. The key methods are:
1. Bitmap: A binary representation where each bit corresponds to a block; 0 indicates free space, and 1
indicates used space. It provides efficient tracking of free blocks.
2. Linked List: Free blocks are linked together, where each free block points to the next free block.
This method is flexible but less efficient than a bitmap in terms of access speed.
1. File Creation and Deletion: It manages the creation, naming, and deletion of files on storage devices.
2. File Access and Manipulation: It provides mechanisms for reading, writing, and updating files, as
well as organizing them for easy access.
79. Name the three methods of allocating disk space for file systems?( NOV / DEC-2024)
The three methods of allocating disk space for file systems are:
1. Contiguous Allocation
2. Linked Allocation
3. Indexed Allocation
80. List the operations that can be performed on the directory? ( NOV / DEC-2024)
PART B
1. Explain about FCFS, SSTF, CSCAN and CLOCK disk scheduling algorithms with an example for
each. (or) Discuss disk scheduling Algorithms in detail. (Nov/Dec-2019)
Consider a disk queue with requests for i/o to blocks on cylinders in this following order.
98,183,37,122,14,124,65,67
The disk head pointer is initially at cylinder 53. Outline first come first serve disk scheduling algorithm,
SCAN disk scheduling algorithms and Shortest seek time first disk scheduling algorithm with a
diagram.(April/May-2023)
The disk transfer speeds are limited primarily by seek times and rotational latency. Bandwidth is measured by
the amount of data transferred divided by the total amount of time from the first request being made to the last
transfer being completed, (for a series of disk requests. )
FCFS Scheduling:
First-Come First-Serve is simple and intrinsically fair, but not very efficient shown in Fig 4.1.
Consider in the following sequence the wild swing from cylinder 122 to 14 and then back to 124:
SSTF Scheduling
Shortest Seek Time First scheduling is more efficient, but may lead to starvation if a constant
stream of requests arrives for the same general area of the disk shown in Fig 4.2.
SSTF reduces the total head movement to 236 cylinders, down from 640 required for the same set of
requests under FCFS. The distance could be reduced still further to 208 by starting with 37 and then 14
SCAN Scheduling
The SCAN algorithm, the elevator algorithm moves back and forth from one end of the disk to the
other, similarly to an elevator processing requests in a tall building shown in Fig 4.3.
Under the SCAN algorithm, if a request arrives just ahead of the moving head, then it will be processed
right away, but if it arrives just after the head has passed, then it will have to wait for the head to pass
going the other way on the return trip.
C-SCAN Scheduling:
The Circular-SCAN algorithm improves upon SCAN by treating all requests in a circular queue
fashion - Once the head reaches the end of the disk, it returns to the other end without processing any
LOOK Scheduling:
LOOK scheduling improves upon SCAN by looking ahead at the queue of pending requests, and
not moving the heads any farther towards the end of the disk than is necessary is shown in Fig 4.5.
Disk Formatting:
Before a disk can be used, it has to be low-level formatted, which means laying down all of the headers and
trailers demarking the beginning and ends of each sector.
Included in the header and trailer are the linear sector numbers, and error-correcting codes, ECC,
which allow damaged sectors to not only be detected, but in many cases for the damaged data to
be recovered (depending on the extent of the damage). Sector sizes are traditionally 512 bytes, but
may be larger, particularly in larger drives.
ECC calculation is performed with every disk read or write, and if damage is detected but the
data is recoverable, then a soft error has occurred. Soft errors are generally handled by the on-board
disk controller, and never seen by the OS.
After partitioning, then the filesystems must be logically formatted, which involves laying
down the master directory information.
Boot Block:
Computer ROM contains a bootstrap program ( OS independent ) with just enough code to find the
first sector on the first hard drive on the first controller, load that sector into memory, and transfer
control over to it.
The first sector on the hard drive is known as the Master Boot Record, MBR, and contains a very small
amount of code in addition to the partition table.
The partition table documents how the disk is partitioned into logical disks, and indicates specifically
which partition is the active or boot partition.
The boot program then looks to the active partition to find an operating system, possibly loading up a
slightly larger / more advanced boot program along the way shown in Fig 4.6.
In a dual-boot (or larger multi-boot) system, the user may be given a choice of which operating system
to boot, with a default action to be taken in the event of no response within some time frame.
Bad Blocks:
No disk can be manufactured to 100% perfection, and all physical objects wear out over time. For these
reasons all disks are shipped with a few bad blocks, and additional blocks can be expected to go bad
slowly over time. If a large number of blocks go bad then the entire disk will need to be replaced, but a
few here and there can be handled through other means.
In the old days, bad blocks had to be checked for manually. Formatting of the disk or running certain
disk-analysis tools would identify bad blocks, and attempt to read the data off of them one last time
through repeated tries.
Then the bad blocks would be mapped out and taken out of future service. Sometimes the data could be
recovered, and sometimes it was lost forever.
3. Explain about File Concepts. (or) Discuss the functions of file and file implementation. (Apr/May
2012] [Nov/Dec 2012 & 15]
File:
A file is a named collection of related information that is recorded on secondary storage.Data files
may be numeric, alphabetic, alphanumeric, or binary. Files may be free form, such as text files, or may be
formatted rigidly.
A text file is a sequence of characters organized into lines (and possibly pages).
A source file is a sequence of subroutines and functions, each of which is further organized as
declarations followed by executable statements.
An object file is a sequence of bytes organized into blocks understandable by the system's linker.
An executable file is a series of code sections that the loader can bring into memory and execute.
A file has certain other attributes, which 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 those systems that support different types.
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. The information about all files
is kept in the directory structure that also resides on secondary storage.
File Operations:
. The operating system can provide system calls to create, write, read, reposition, delete, and truncate files.
Creating a file: Two steps are necessary to create a file. First, space in the file system must be found for the
file. Second, an entry for the new file must be made in the directory.
Writing a file: To write a file, 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 location of the
file.
Reading a file: To read from a file, use a system call that specifies the name of the file and where (in
memory) the next block of the file should be put. Again, the directory is searched for the associated directory
entry, and the system needs to keep a read pointer to the location in the file where the next read is to take
place.
Repositioning within a file: The directory is searched for the appropriate entry, and the current-file-position
is set to a given value. Repositioning within a file does not need to involve any actual I/O. This file operation
is also known as a file seeks.
Deleting a file:
Truncating a file:
These six basic operations certainly comprise the minimal set of required file operations.
The operating system keeps a small table containing information about all open files (the open-file table).
File pointer: On systems that do not include a file offset as part of the read and write system calls, the
system must track the last read-write location as a current-file-position pointer. This pointer is unique to
File Types:
Windows (and some other systems) use special file extensions to indicate the type of each file
shown in Table 4.1:
File Structure:
Some files contain an internal structure, which may or may not be known to the OS.
For the OS to support particular file formats increases the size and complexity of the OS.
UNIX treats all files as sequences of bytes, with no further consideration of the internal structure.
(With the exception of executable binary programs, which it must know how to load and find the
first executable statement, etc. )
Macintosh files have two forks - a resource fork, and a data fork. The resource fork contains
information relating to the UI, such as icons and button images, and can be modified
independently of the data fork, which contains the code or data as appropriate.
Internally, locating an offset within a file can be complicated for the operating system. It is unlikely
that the physical record size will exactly match the length of the desired logical record.
Logical records may even vary in length. Packing a number of logical records into physical blocks is a
common solution to this problem.
The logical record size, physical block size, and packing technique determine how many logical records
are in each physical block.
The packing can be done either by the user's application program or by the operating system.
4.What is a directory? Outline a tree structured directory structure and an acycle graph directory
structure with appropriate example.(April/May-2023)
A general-purpose computer system has multiple storage devices, and those devices can be sliced up
into volumes that hold file systems.
Computer systems may have zero or more file systems, and the file systems maybe of varying types.
For example, a typical Solaris system may have dozens of file systems of a dozen different types, as
shown in the file system list in Figure 4.9.
tmpfs—a “temporary” file system that is created in volatile main memory and has its contents erased if
the system reboots or crashes
objfs—a “virtual” file system (essentially an interface to the kernel that looks like a file system) that
gives debuggers access to kernel symbols
ctfs—a virtual file system that maintains “contract” information to manage which processes start when
the system boots and must continue to run during operation
lofs—a “loop back” file system that allows one file system to be accessed in place of another one
PREPARED BY: Mr.D.Srinivasan,AP/CSE , Mrs.A.Thilagavathi,AP/CSE & Mr.R.Arunkumar, AP/CSE 23
MAILAM ENGINEERING COLLEGE CS3451-Introduction to Operating System UNIT-IV
procfs—a virtual file system that presents information on all processes as a file system
ufs, zfs—general-purpose file systems
Directory:
A directory is a file system cataloging structure which contains references to other computer files, and possibly
other directories. on many computers, directories are known as folders, or drawers, analogous to a workbench
or the traditional office filing cabinet.
Directory Overview
Search for a file
Create a file
Delete a file
List a directory
Rename a file
Traverse the file system
(i)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, however, when the number of files increases or when
the system has more than one user.
Since all files are in the same directory, they must have unique names. If two users call their data file test,
then the unique-name rule is violated.
Even a single user on a single-level directory may find it difficult to remember the names of all the files, as
the number of files increases shown in Fig 4.10.
A single-level directory often leads to confusion of file names between different users. The
An obvious extension to the two-tiered directory structure, and the one with which we are all most
familiar.
Each user / process has the concept of a current directory from which all (relative) searches take
place.
Files may be accessed using either absolute pathnames (relative to the root of the tree) or relative
pathnames (relative to the current directory.)
An absolute path name begins at the root and follows a path down to the specified file, giving the directory
names on the path.
A relative path name defines a path from the current directory shown in Fig 4.11b.
A tree structure prohibits the sharing of files or directories. An acyclic graph allows directories to have
shared subdirectories and files.
UNIX provides two types of links for implementing the acyclic-graph structure.
A hard link (usually just called a link) involves multiple directory entries that both refer to the same file. Hard
links are only valid for ordinary files in the same filesystem.
A symbolic link, that involves a special file, containing information about where to find the linked file.
Symbolic links may be used to link directories and/or files in other filesystems, as well as ordinary files in the
current filesystem shown in Fig 4.12.
Hard links require a reference count, or link count for each file, keeping track of how many directory
entries are currently referring to this file. Whenever one of the references is removed the link count is
reduced, and when it reaches zero, the disk space can be reclaimed.
One serious problem with using an acyclic-graph structure is ensuring that there are no cycles.
If we start with a two-level directory and allow users to create subdirectories, a tree-structured
directory results shown in Fig 4.13.
It should be fairly easy to see that simply adding new files and subdirectories to an existing tree
structured directory preserves the tree-structured nature.
File sharing is very desirable for users who want to collaborate and to reduce the effort required to
achieve a computing goal.
Multiple Users:
To implement sharing and protection, the system must maintain more file and directory attributes than
are needed on a single-user system.
Although many approaches have been taken to meet this requirement, most systems have evolved to
use the concepts of file (or directory) owner (or user) and group.
The owner is the user who can change attributes and grant access and who has the most control over the
file. The group attribute defines a subset of users who can share access to the file.
The first implemented method involves manually transferring files between machines via programs like
ftp.
The second major method uses a distributed file system (DFS) in which remote directories is visible
from a local machine.
In some ways, the third method, the World Wide Web, is a reversion to the first. A browser is needed
to gain access to the remote files, and separate operations (essentially a wrapper for ftp) are used to
transfer files.
Anonymous access allows a user to transfer files without having an account on the remote system.
Remote file systems allow a computer to mount one or more file systems from one or more
remote machines.
In this case, the machine containing the files is the server, and the machine seeking access to the
files is the client.
The client–server relationship is common with networked machines.
Client identification is more difficult.
A client can be specified by a network name or other identifier, such as an IP address, but these
can be spoofed, or imitated.
(c ).Failure Modes:
Local file systems can fail for a variety of reasons, including failure of the disk containing the file
system, corruption of the directory structure or other disk-management information (collectively
called metadata), disk-controller failure, cable failure, and host-adapter failure.
Recovery from failure, some kind of state information may be maintained on both the client and
the server.
In the situation where the server crashes but must recognize that it has remotely mounted exported
file systems and opened files, NFS takes a simple approach, implementing a stateless DFS.
Consistency Semantics:
Consistency semantics represent an important criterion for evaluating any file system that supports file
sharing. These semantics specify how multiple users of a system are to access a shared file simultaneously.
(a).UNIX Semantics
Writes to an open file by a user are visible immediately to other users who have this file open.
One mode of sharing allows users to share the pointer of current location into the file. Thus, the
advancing of the pointer by one user affects all sharing users. Here, a file has a single image that
interleaves all accesses, regardless of their origin.
(b).Session Semantics
The Andrew file system (OpenAFS) uses the following consistency semantics:
Writes to an open file by a user are not visible immediately to other users that have the same file
open.
Once a file is closed, the changes made to it are visible only in sessions starting later. Already open
instances of the file do not reflect these changes.
(c ).Immutable-Shared-Files Semantics
A unique approach is that of immutable shared files.
Once a file is declared as shared by its creator, it cannot be modified.
6. Write notes about the protection strategies provided for files. (or) Explain about File access
methods. [Nov/Dec 13] [May/June 17] [April/May-2021]
Files must be kept safe for reliability (against accidental damage), and protection (against
deliberate malicious access.) The former is usually managed with backup copies. This section discusses
the latter.
Types of Access:
Access Control:
One approach is to have complicated Access Control Lists, ACL, which specify exactly what access is allowed
or denied for specific users or groups.
To condense the length of the access-control list, many systems recognize three classifications of users in
connection with each file:
The information in the file can be accessed in several ways. They are
Sequential access
Direct Access
Other access methods
Sequential access:
The simplest access method is sequential access. Information in the file is processed in
order, one record after the other. This mode of access is by far the most common; for example, editors and
compilers usually access files in this fashion.
Another method is direct access (or relative access). Here, 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.
Other access methods can be built on top of a direct-access method. These methods
generally involve the construction of an index for the file. The index, 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.
Another approach to the protection problem is to associate a password with each file. Just as access to
the computer system is often controlled by a password, access to each file can be controlled in the same
way.
If the passwords are chosen randomly and changed often, this scheme may be effective in limiting
access to a file.
The use of passwords has a few disadvantages, however. First, the number of passwords that a user
needs to remember may become large, making the scheme impractical.
Disks provide most of the secondary storage on which file systems are maintained. Two characteristics make
them convenient for this purpose:
File systems:
File systems provide efficient and convenient access to the disk by allowing data to be stored,
located, and retrieved easily.
I/O Control consists of device drivers, special software programs ( often written in assembly )
which communicate with the devices by reading and writing special codes directly to and from
memory addresses corresponding to the controller card's registers shown in Fig 4.14.
The basic file system level works directly with the device drivers in terms of retrieving and
storing raw blocks of data, without any consideration for what is in each block.
The file organization module knows about files and their logical blocks, and how they map to
physical blocks on the disk.
The file-organization module knows about files and their logical blocks, as well as physical blocks. By
knowing the type of file allocation used and the location of the file, the file-organization module can
translate logical block addresses to physical block addresses for the basic file system to transfer. Each file’s
logical blocks are numbered from 0 (or 1) through N.
The logical file system manages metadata information. Metadata includes all of the file-system structure
except the actual data (or contents of the files). A file control block (FCB) (an inode in UNIX file systems)
contains information about the file, including ownership, permissions, and location of the file contents.
Each operating system has one or more dis kbased file systems. UNIX uses the UNIX file system (UFS),
which is based on the Berkeley Fast File System (FFS). Windows supports disk file-system formats of
FAT, FAT32, and NTFS (or Windows NT File System), as well as CD-ROM and DVD File-system
formats.
Linux supports over forty different file systems, the standard Linux file system is known as the extended
file system, with the most common versions being ext3 and ext4. There are also distributed file systems in
which a file system on a server is mounted by one or more client computers across a network.
A file's attributes vary from one operating system to another but typically consist of these:
Name: Name is the symbolic file name and is the only information kept in human-readable form.
8. Explain File System Implementation. (or) In a variable partition scheme, the operating system has to
keep track of allocated and free space. Suggest a means of achieving this. Describe the effects of new
allocations and process terminations in your suggested scheme. (Nov/Dec-2021)
Several on-disk and in-memory structures are used to implement a file system. These vary depending on
the operating system and the file system, but some general principles apply.
A boot control block can contain information needed by the system to boot an operating from that partition.
If the disk does not contain an operating system, this block can be empty. It is typically the first block of a
partition. In UFS, this is called the boot block; in NTFS, it is the partition boot sector.
A partition control block contains partition details, such as the number of blocks in the partition, size of the
blocks, free-block count and free-block pointers, and free FCB count and FCB pointers. In UFS this is
called a superblock; in NTFS, it is the Master File Table.
A directory structure is used to organize the files. An FCB contains many of the file's details, including file
permissions, ownership, size, and location of the data blocks. In UFS this is called the inode. In NTFS, this
information is actually stored within the Master File Table, which uses a relational database structure, with
a row per file.
The in-memory information is used for both file-system management and performance improvement via
caching. The structures can include:
There are some of the interactions of file system components when files are created and/or used:
When a new file is created, a new FCB is allocated and filled out with important information
regarding the new file. The appropriate directory is modified with the new file name and FCB
information.
When a file is accessed during a program, the open ( ) system call reads in the FCB information
from disk, and stores it in the system-wide open file table is shown in Fig 4.16.
An entry is added to the per-process open file table referencing the system-wide table, and an
index into the per-process table is returned by the open ( ) system call. UNIX refers to this index
as a file descriptor, and Windows refers to it as a file handle.
Physical disks are commonly divided into smaller units called partitions.
Partitions can either be used as raw devices: Raw partitions are generally used for swap space, and may
also be used for certain programs such as databases that choose to manage their own disk storage system.
The root partition contains the OS kernel and at least the key portions of the OS needed to complete the boot
process. At boot time the root partition is mounted, and control is transferred from the boot program to the
kernel found there.
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 shown in Fig 4.17.
(UNIX inodes are unique only across a single filesystem, and certainly do not carry across networked file
systems.)
An abbreviated API for some of the operations for the file object includes:
a. int open (. . .)—Open a file.
b. int close(...)—Close an already-open file.
c. ssize t read (. . .)—Read from a file.
d. ssize t write (. . .)—Write to a file.
e. int mmap(. . .)—Memory-map a file.
Linux VFS provides a set of common functionalities for each filesystem, using function pointers accessed
through a table. The same functionality is accessed through the same table position for all filesystem
types, though the actual functions pointed to by the pointers may be filesystem-specific. See
/usr/include/linux/fs.h for full details. Common operations provided include open ( ), read( ), write( ), and
mmap( ).
9. Explain the Various File Allocation Methods.(or) Explaina bput Contiguous allocation and
linked allocation with example and diagrams.[April/May-2021,23] [Nov/Dec-2021]
There are three major methods of storing files on disks: contiguous, linked, and indexed.
Contiguous Allocation requires that all blocks of a file be kept together contiguously.
Performance is very fast, because reading successive blocks of the same file generally requires no
movement of the disk heads, or at most one small step to the next adjacent cylinder.
Storage allocation involves the same issues discussed earlier for the allocation of contiguous
blocks of memory shown in Fig 4.18 .
Problems can arise when files grow, or if the exact size of a file is unknown at creation time:
o Over-estimation of the file's final size increases external fragmentation and wastes disk
space.
o If a file grows slowly over a long time period and the total final space must be allocated
initially, then a lot of space becomes unusable before the file fills the space.
A variation is to allocate file space in large contiguous chunks, called extents. When a file outgrows its
original extent, then an additional one is allocated.
Advantages:
Both the Sequential and Direct Accesses are supported by this. For direct access, the address of the kth
block of the file which starts at block b can easily be obtained as (b+k).
This is extremely fast since the number of seeks are minimal because of contiguous allocation of file
block
Disadvantages:
This method suffers from both internal and external fragmentation. This makes it inefficient in terms of
memory utilization.
Increasing file size is difficult because it depends on the availability of contiguous memory at a
particular instance.
(ii) Linked Allocation
Disk files can be stored as linked lists, with the expense of the storage space consumed by each link. (
E.g. a block may be 508 bytes instead of 512. )
Linked allocation involves no external fragmentation, does not require pre-known file sizes, and allows
files to grow dynamically at any time.
Allocating clusters of blocks reduces the space wasted by pointers, at the cost of internal fragmentation
shown in Fig 4.19.
The File Allocation Table, FAT, used by DOS is a variation of linked allocation, where all the links
are stored in a separate table at the beginning of the disk. The benefit of this approach is that the FAT
table can be cached in memory, greatly improving random access speeds shown in Fig 4.20.
Advantages:
This is very flexible in terms of file size. File size can be increased easily since the system does not
have to look for a contiguous chunk of memory.
This method does not suffer from external fragmentation. This makes it relatively better in terms of
memory utilization.
Disadvantages:
Because the file blocks are distributed randomly on the disk, a large number of seeks are needed to
access every block individually. This makes linked allocation slower.
It does not support random or direct access
Pointers required in the linked allocation incur some extra overhead
Indexed Allocation combines all of the indexes for accessing each file into a common block , as
opposed to spreading them all over the disk or storing them in a FAT table.
Some disk space is wasted ( relative to linked lists or FAT tables ) because an entire index block must
be allocated for each file, regardless of how many data blocks the file contains.
This leads to questions of how big the index block should be, and how it should be implemented shown
in Fig 4.21
Linked Scheme - An index block is one disk block, which can be read and written in a single disk operation.
The first index block contains some header information, the first N block addresses, and if necessary a pointer
to additional linked index blocks.
Multi-Level Index - The first index block contains a set of pointers to secondary index blocks, which in turn
contain pointers to the actual data blocks.
Advantages:
This supports direct access to the blocks occupied by the file and therefore provides fast access to the
file blocks.
It overcomes the problem of external fragmentation.
Disadvantages:
The pointer overhead for indexed allocation is greater than linked allocation.
For very small files, say files that expand only 2-3 blocks, the indexed allocation would keep one entire
block (index block) for the pointers which is inefficient in terms of memory utilization.
Combined Scheme :
Another alternative, used in UNIX-based file systems, is to keep the first, say, 15 pointers of the index block in
the file’s inode.
The first 12 of these pointers point to direct blocks; that is, they contain addresses of blocks that contain
Performance:
A System with mostly sequential access should not use the same method as a system with mostly random
access. For any type of access, contiguous allocation requires only one access to get a disk block.
Since we can easily keep the initial address of the file in memory, we can calculate immediately the
disk address of the ith block (or the next block) and read it directly.
For linked allocation, we can also keep the address of the next block in memory and read it directly.
This method is fine for sequential access; for direct access, however, an access to the ith block might
require i disk reads.
.
10. Write about the Free Space Management. [Apr/May 2010,12, 13& 15] [Nov/Dec 2015 &17]
Another important aspect of disk management is keeping track of and allocating free space.
One simple approach is to use a bit map or bit vector, in which each bit represents a disk block,
set to 1 if free or 0 if allocated.
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 bit map would be
0011110011111100011000000111………
A linked list can also be used to keep track of all free blocks.
Traversing the list and/or finding a contiguous block of a given size are not easy, but fortunately are not
frequently needed operations. Generally, the system just adds and removes single blocks from the
beginning of the list shown in Fig 4.23.
The FAT table keeps track of the free list as just one more linked list on the table.
(iii) Grouping:
A modification of the free-list approach is to store the addresses of n free blocks in the first free block. The
first n-1 of these blocks is actually free.
The last block contains the addresses of another n free block, and so on.
(iv)Counting:
Another approach is to take advantage of the fact that, generally, several contiguous blocks may be
allocated or freed simultaneously, particularly when space is allocated with the contiguous-allocation
algorithm or through clustering.
(v)Space Maps:
Oracle’s ZFS file system (found in Solaris and other operating systems) was designed to encompass huge
numbers of files, directories, and even file systems (in ZFS,we can create file-system hierarchies).
In its management of free space, ZFS uses a combination of techniques to control the size of data structures
and minimize the I/O needed to manage those structures.
First, ZFS creates metaslabs to divide the space on the device into chunks of manageable size. A given
volume may contain hundreds of metaslabs.
Directory Implementation:
The selection of directory-allocation and directory-management algorithms has a large effect on the
efficiency, performance, and reliability of the file system.
Linear List:
To create a new file, we must first search the directory to be sure that no existing file has the same
name. Then, we add a new entry at the end of the directory.
To delete a file, we search the directory for the named file, then release the space allocated to it. To
reuse the directory entry, we can do one of several things.
Disadvantage
A linear list of directory entries is the linear search to find a file is the major disadvantage.
Directory information is used frequently, and users would notice a slow implementation of
access to it.
Advantage:
The sorted list is that a sorted directory listing can be produced without a separate sort step.
Hash Table:
Another data structure that has been used for a file directory is a hash table. In this method, a linear list
stores the directory entries, but a hash data structure is also used.
The hash table takes a value computed from the file name and returns a pointer to the file name
in the linear list.
Disadvantage:
The major difficulties with a hash table are its generally fixed size and the dependence of the hash function
on that size.
12. Explain in detail about I/O Hardware. [Nov/Dec 2010] [Apr/May 2013]
A device communicates with a computer system by sending signals over a cable or even through the air. The
device communicates with the machine via a connection point, or port—for example, a serial port. If devices
share a common set of wires, the connection is called a bus.A typical PC bus structure appears in Figure 4.24 .
A PCI bus (the common PC system bus) connects the processor–memory subsystem to fast devices,
and an expansion bus connects relatively slow devices, such as the keyboard and serial and USB ports.
In the upper-right portion of the figure, four disks are connected together on a Small Computer
System Interface (SCSI) bus plugged into a SCSI controller.
Other common buses used to interconnect main parts of a computer include PCI Express (PCIe), with
throughput of up to 16 GB per second, and Hyper Transport, with throughput of up to 25 GB per
second.
A serial-port controller is a simple device controller. It is a single chip (or portion of a chip) in the
computer that controls the signals on the wires of a serial port.
A SCSI bus controller is not simple. Because the SCSI protocol is complex, the SCSI bus controller is
often implemented as a separate circuit board (or a host adapter) that plugs into the computer.
Registers may be one to four bytes in size, and may typically include ( a subset of ) the following four:
The data-in register is read by the host to get input from the device.
The data-out register is written by the host to send output.
The status register has bits read by the host to ascertain the status of the device, such as idle,
ready for input, busy, error, transaction complete, etc.
The control register has bits written by the host to issue commands or to change settings of the
device such as parity checking, word length, or full- versus half-duplex operation shown in
Table 4.2.
Polling:
1. The host repeatedly checks the busy bit on the device until it becomes clear.
2. The host writes a byte of data into the data-out register, and sets the write bit in the command
register (in either order. )
3. The host sets the command ready bit in the command register to notify the device of the
pending command.
4. When the device controller sees the command-ready bit set, it first sets the busy bit.
5. Then the device controller reads the command register, sees the write bit set, reads the byte of
data from the data-out register, and outputs the byte of data.
6. The device controller then clears the error bit in the status register, the command-ready bit, and
finally clears the busy bit, signaling the completion of the operation.
Interrupts:
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.
The CPU has an interrupt-request line that is sensed after every instruction.
o A device's controller raises an interrupt by asserting a signal on the interrupt request line.
o The CPU then performs a state save, and transfers control to the interrupt handler routine at a
fixed address in memory. (The CPU catches the interrupt and dispatches the interrupt handler.
o The interrupt handler determines the cause of the interrupt, performs the necessary processing,
performs a state restore, and executes a return from interrupt instruction to return control to the
The above description is adequate for simple interrupt-driven I/O, but there are three needs in modern
computing which complicate the picture:
These issues are handled in modern computer architectures with interrupt-controller hardware.
o Most CPUs now have two interrupt-request lines: One that is non-maskable for critical error
conditions and one that is maskable, that the CPU can temporarily ignore during critical
processing.
o The interrupt mechanism accepts an address, which is usually one of a small set of numbers for
an offset into a table called the interrupt vector. This table (usually located at physical address
zero?) holds the addresses of routines prepared to process specific interrupts.
o The number of possible interrupt handlers still exceeds the range of defined interrupt numbers,
so multiple handlers can be interrupt chained. Effectively the addresses held in the interrupt
vectors are the head pointers for linked-lists of interrupt handlers.
Table 4.3 shows the Intel Pentium interrupt vector. Interrupts 0 to 31 are non-maskable and reserved for
serious hardware and other errors. Maskable interrupts, including normal device I/O interrupts begin at
interrupt
At boot time the system determines which devices are present, and loads the appropriate handler
addresses into the interrupt table.
During operation, devices signal errors or the completion of commands via interrupts.
Exceptions, such as dividing by zero, invalid memory accesses, or attempts to access kernel mode
instructions can be signaled via interrupts.
Instead this work can be off-loaded to a special processor, known as the Direct Memory Access, DMA, and
Controller.
The host issues a command to the DMA controller, indicating the location where the data is located, the
location where the data is to be transferred to, and the number of bytes of data to transfer. The DMA
controller handles the data transfer, and then interrupts the CPU when the transfer is complete.
A simple DMA controller is a standard component in modern PCs, and many bus-mastering I/O cards
contain their own DMA hardware.
Handshaking between DMA controllers and their devices is accomplished through two wires called the
DMA-request and DMA-acknowledge wires are shown in Fig 4.26.
13. Describe the important concepts of Application I/O Interface. [Nov/Dec 2011]
Character-stream or block. A character-stream device transfers bytes one by one, whereas a block
device transfers a block of bytes as a unit.
Sequential or random access. A sequential device transfers data in a fixed order determined by the
device, whereas the user of a random-access device can instruct the device to seek to any of the
PREPARED BY: Mr.D.Srinivasan,AP/CSE , Mrs.A.Thilagavathi,AP/CSE & Mr.R.Arunkumar, AP/CSE 47
MAILAM ENGINEERING COLLEGE CS3451-Introduction to Operating System UNIT-IV
available data storage locations.
Synchronous or asynchronous. A synchronous device performs data transfers with predictable
response times, in coordination with other aspects of the system. An asynchronous device exhibits
irregular or unpredictable response times not coordinated with other computer events.
Sharable or dedicated. A sharable device can be used concurrently by several processes or threads; a
dedicated device cannot.
Speed of operation. Device speeds range from a few bytes per second to a few gigabytes per second.
Read–write, read only, or write only. Some devices perform both input and output, but others support
only one data transfer direction.
Most operating systems also have an escape (or back door) that transparently passes arbitrary
commands from an application to a device driver.
In UNIX this is the ioctl( ) system call ( I/O Control ). Ioctl( ) takes three arguments - The file
descriptor for the device driver being accessed, an integer indicating the desired function to be
performed, and an address used for communicating or transferring additional information.
Block devices are accessed a block at a time, and are indicated by a "b" as the first character in a long listing on
UNIX systems. Operations supported include read ( ), write ( ), and seek ( ).
o Accessing blocks on a hard drive directly (without going through the file system structure) is
called raw I/O, and can speed up certain operations by bypassing the buffering and locking
normally conducted by the OS. (It then becomes the application's responsibility to manage those
issues.)
o A new alternative is direct I/O, which uses the normal file system access, but which disables
buffering and locking operations.
o Rather than reading in the entire file, it is mapped to a range of memory addresses, and then
PREPARED BY: Mr.D.Srinivasan,AP/CSE , Mrs.A.Thilagavathi,AP/CSE & Mr.R.Arunkumar, AP/CSE 48
MAILAM ENGINEERING COLLEGE CS3451-Introduction to Operating System UNIT-IV
paged into memory as needed using the virtual memory system.
o Access to the file is then accomplished through normal memory accesses, rather than through
read ( ) and write ( ) system calls. This approach is commonly used for executable program
code.
Character stream interface are accessed one byte at a time, and are indicated by a "c" in UNIX long listings.
Supported operations include get ( ) and put ( ), with more advanced functionality such as reading an entire line
supported by higher-level library routines.
Network Devices:
Because network access is inherently different from local disk access, most systems provide a
separate interface for network devices.
One common and popular interface is the socket interface, which acts like a cable or pipeline
connecting two networked entities. Data can be put into the socket at one end, and read out sequentially
at the other end. Sockets are normally full-duplex, allowing for bi-directional data transfer.
The select ( ) system call allows servers (or other applications) to identify sockets which have data
waiting, without having to poll all available sockets.
A programmable interrupt timer, PIT can be used to trigger operations and to measure elapsed time. It can be
set to trigger an interrupt at a specific future time, or to trigger interrupts periodically on a regular basis.
o The scheduler uses a PIT to trigger interrupts for ending time slices.
o The disk system may use a PIT to schedule periodic maintenance cleanup, such as flushing
buffers to disk.
o Networks use PIT to abort or repeat operations that are taking too long to complete. I.e.
resending packets if an acknowledgement is not received before the timer goes off.
When an application issues a blocking system call, the execution of the application is suspended. The
application is moved from the operating system’s run queue to a wait queue. After the system call
completes, the application is moved back to the run queue, where it is eligible to resume execution.
Some user-level processes need nonblocking I/O. One example is a user interface that receives
keyboard and mouse input while processing and displaying data on the screen.
Some operating systems provide another major variation of I/O via their applications interfaces.
Vectored I/O allows one system call to perform multiple I/O operations involving multiple locations.
For example, the UNIX readv system call accepts a vector of multiple buffers and either reads from a
source to that vector or writes from that vector to a destination.
The same transfer could be caused by several individual invocations of system calls, but this scatter–
gather method is useful for a variety of reasons.
I/O Scheduling:
To schedule a set of I/O requests means to determine a good order in which to execute them.
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.
Suppose that a disk arm is near the beginning of a disk and that three-applications issue blocking read calls to
that disk.
Application 1 requests a block near the end of the disk,
Application 2 requests one near the beginning,
Application 3 requests one in the middle of the disk. The operating system can reduce
the distance that the disk arm travels by serving the applications in the order 2, 3, 1.
Rearranging the order of service in this way is the essence of I/O scheduling.
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. The operating system might attach the wait queue
to a device-status table.
The kernel manages this table, which contains an entry for each I/O device, as shown in Figure 13.9.
Each table entry indicates the device’s type, address, and state (not functioning, idle, or busy).
If the device is busy with a request, the type of request and other parameters will be stored in the table
entry for that device.
Scheduling I/O operations is one way in which the I/O subsystem improves the efficiency of the
computer shown in Fig 4.28.
Another way is by using storage space in main memory or on disk via buffering, caching, and spooling.
Buffering
Caching:
A cache is a region of fast memory that holds copies of data. Access to the cached copy is more
efficient than access to the original.
Caching involves keeping a copy of data in a faster-access location than where the data is normally
stored.
Buffering and caching are very similar, except that a buffer may hold the only copy of a given data
A spool is a buffer that holds output for a device, such as a printer, that cannot accept interleaved
data streams.
Although a printer can serve only one job at a time, several applications may wish to print their output
concurrently, without having their output mixed together. The operating system solves this problem by
intercepting all output to the printer.
Each application’s output is spooled to a separate disk file. When an application finishes printing, the
spooling system queues the corresponding spool file for output to the printer.
The spooling system copies the queued spool files to the printer one at a time.
Error Handling
An operating system that uses protected memory can guard against many kinds of hardware and
application errors, so that a complete system failure is not the usual result of each minor mechanical
malfunction.
Device is reported by the SCSI protocol in three levels of detail: a sense key that identifies the general
nature of the failure, such as a hardware error or an illegal request;
An additional sense code that states the category of failure, such as a bad command parameter or a
self-test failure;
An additional sense-code qualifier that gives even more detail, such as which command parameter
was in error or which hardware subsystem failed its self-test.
I/O Protection:
The I/O system must protect against either accidental or deliberate erroneous I/O.
User applications are not allowed to perform I/O in user mode - All I/O requests are handled through
system calls that must be performed in kernel mode shown in Fig 4.30.
Memory mapped areas and I/O ports must be protected by the memory management system, but access
to these areas cannot be totally denied to user programs.
The kernel needs to keep state information about the use of I/O components. The kernel uses many similar
structures to track network connections, character-device communications, and other I/O activities.
UNIX provides file-system access to a variety of entities, such as user files, raw devices, and the
address spaces of processes. Although each of these entities supports a read () operation, the semantics
differ.
To read a user file, the kernel needs to probe the buffer cache before deciding whether to perform a disk
I/O.
To read a raw disk, the kernel needs to ensure that the request size is a multiple of the disk sector size
and is aligned on a sector boundary.
The open-file record, contains a dispatch table that holds pointers to the appropriate routines, depending on the
type of file.
Windows uses a message-passing implementation for I/O. An I/O request is converted into a message
that is sent through the kernel to the I/O manager and then to the device driver, each of which may
change the message contents.
For output, the message contains the data to be written Shown in Fig 4.31. For input, the message
contains a buffer to receive the data.
Swap-space management is another low-level task of the operating system. Virtual memory uses disk space
as an extension of main memory. Since disk access is much slower than memory access, using swap space
significantly decreases system performance.
Swap-Space Use:
The systems that implement swapping may use swap space to hold the entire process image, including
the code and data segments.
Paging systems may simply store pages that have been pushed out of main memory.
Swap-Space Location:
A swap space can reside in two places: Swap space can be carved out of the normal file system, or it can be in
a separate disk partition.
If the swap space is simply a large file within the file system, normal file-system routines can be used to create
it, name it, and allocate its space. This approach, though easy to implement, is also inefficient.
swap-space storage manager is used to allocate and deallocate the blocks. This manager uses algorithms
optimized for speed, rather than for storage efficiency.
.
Swap-Space Management: An Example
To illustrate the methods used to manage swap space, we now follow the evolution of swapping and paging in
UNIX.
In Fig 4.32 BSD, swap space is allocated to a process when the process is started. Enough space is set aside to
hold the program, known as the text pages or the text segment, and the data segment of the process.
o Pre allocating all the needed space in this way generally prevents a process from running out of swap
space while it executes. When a process starts, its text is paged in from the file system.
o These pages are written out to swap when necessary, and are read back in from there, so the file system
is consulted only once for each text page.
o Pages from the data segment are read in from the file system, or are created (if they are uninitialized),
and are written to swap space and paged back in as needed.
o One optimization (for instance, when two users run the same editor) is that processes with identical text
pages share these pages, both in physical memory and in swap space. Two per-process swap maps are
used by the kernel to track swap-space use.
o The text segment is a fixed size, so its swap space is allocated in 512 KB chunks, except for the final
chunk, which holds the remainder of the pages, in 1 KB increments
The data-segment swap map is more complicated, because the data segment can grow over time. The map is of
fixed size, but contains swap addresses for blocks of varying size. Given index i, a block pointed to by swap-
map entry i is of size 2' x 16 KB, to a maximum of 2 MB.
o When a process tries to grow its data segment beyond the final allocated block in its swap area, the
operating system allocates another block, twice as large as the previous one.
o This scheme results in small processes using only small blocks. It also minimizes fragmentation. The
blocks of large processes can be found quickly, and the swap map remains small.
o In Solaris 1 (SunOS 4), the designers made changes to standard UNIX methods to improve efficiency
and reflect technological changes Shown in Fig 4.33.
File-System Mounting:
A file must be opened before it is used, a file system must be mounted before it can be available to processes
on the system. More specifically, the directory structure can be built out of multiple partitions, which must be
mounted to make them available within the file system name space.
The mount procedure is straightforward. The operating system is given the name of the device, and the location
within the file Shown in Fig 4.34
Structure at which to attach the file system (or mount point). Typically, a mount point is an empty directory at
which the mounted file system will be attached.
For instance, on a UNIX system, a file system containing user's home directories might be mounted as
home; then, to access the directory structure within that file system, one could precede the directory
names with /home, as in /honze/jane. Mounting that file system under /users would result in the path
name /usersljane to reach the same directory.
Next, the operating system verifies that the device contains a valid file system. It does so by asking the
device driver to read the device directory and verifying that the directory has the expected format.
To illustrate file mounting, consider the file system depicted is Shown in Fig 4.35, where the triangles
represent subtrees of directories that are of interest. an existing file system is shown, while in an unmounted
partition residing on /device/dsk is shown.
At this point, only the files on the existing file system can be accessed. the effects of the mounting of the
partition residing on /device/dsk over /users are shown. If the partition is unmounted, the file system is restored
to the situation depicted in
For example, a system may disallow a mount over a directory that contains files, or make the mounted file
system available at that directory and obscure the directory's existing files until the file system is unmounted,
terminating the use of the file system and allowing access to the original files in that directory.
As another example, a system may allow the same file system to be mounted repeatedly, at different mount
points, or it may only allow one mount per file system.
Consider the actions of the Macintosh operating system. Whenever the system encounters a disk for the first
time (hard disks are found at boot time, floppy disks are seen when they are inserted into the drive), the
Macintosh operating system searches for a file system on the device.
If it finds one, it automatically mounts the file system at the root level, adding a folder icon on the screen
labeled with the name of the file system (as stored in the device directory). The user then is able to click on the
icon and thus to display the newly mounted file system.
Problem-01:
Solution-FCFS
= (98 – 53) + (183 – 98) + (183 – 41) + (122 – 41) + (122 – 14) + (124 – 14) + (124 – 65) + (67 – 65)
= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (183 – 14) + (41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 169 + 27
= 326
LOOK SCHEDULING:
= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (183 – 41) + (41 – 14)
= 299
Alternatively,
= 130 + 169
= 299
SSTF:
= (65 – 53) + (67 – 65) + (67 – 41) + (41 – 14) + (98 – 14) + (122 – 98) + (124 – 122) + (183 – 124)
= 12 + 2 + 26 + 27 + 84 + 24 + 2 + 59
= 236
= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (199 – 183) + (199 – 41) + (41
– 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 16 + 158 + 27
= 331
Alternatively,
= 146 + 185
= 331
= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (199 – 183) + (199 – 0) + (14 –
0) + (41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 16 + 199 + 14 + 27
= 386
Alternatively,
= 146 + 199 + 41
= 386
29. Following are the references attempted to hard disks : 67,22,78,34,21,78,99. Recommend a suitable
disk scheduling algorithm among FIFO, SSTF, SCAN AND LOOK after applying all. Provide
statements that support your recommendation.(Note : Initial head position is at 20)(Nov/Dec-2023)
Given the initial head position is at 20, and the list of references attempted to the hard disks is 67, 22, 78, 34,
21, 78, 99, we can simulate each algorithm and calculate the total head movement for each. After analyzing the
total head movement for each algorithm, we can recommend the most suitable one.
1. FIFO:
Total head movement: Calculate the sum of absolute differences between each consecutive
request.
2. SSTF:
Total head movement: Choose the request with the shortest seek time to the current head
position.
3. SCAN:
Total head movement: Calculate the total distance traveled by the head moving from the initial
position to the end of the disk and then back.
4. LOOK:
Total head movement: Calculate the total distance traveled by the head moving from the initial
position to the last request and then back.
After calculating the total head movement for each algorithm, we can compare them to recommend the most
suitable one based on the lowest total head movement.
30.Is disk scheduling, other than FCFS scheduling, useful in a single- user environment? Explain your
answer. ( APRIL / MAY-2024)
Disk scheduling refers to the method used by an operating system to determine the order in which disk I/O
requests are processed. Disk I/O is typically a time-consuming operation, and optimizing how requests are
handled can greatly improve system performance.
In single-user environments, where there may still be multiple disk I/O requests queued up, using more
advanced scheduling algorithms can lead to reduced wait times and better overall system efficiency.
Fairness: While FCFS is simple, it does not prioritize efficiency. It simply handles requests in the order
they arrive.
Long Waiting Times: FCFS can result in long waiting times, especially if a disk request far away from
the current head position arrives before others, leading to inefficient disk arm movements.
Uneven Disk Head Movement: FCFS may cause the disk arm to move unnecessarily back and forth,
causing delays in servicing I/O requests. This could increase the overall seek time, especially in
systems with a high volume of I/O requests.
How it Works: SSTF selects the disk request that is closest to the current disk head position.
Benefits in a Single-User Environment:
o Reduced Seek Time: It minimizes the time spent by the disk arm moving back and forth.
o Improved Performance: It can greatly speed up I/O operations by reducing head movements
compared to FCFS.
o Fairness: While not as fair as FCFS, SSTF is still effective in single-user environments where
performance optimization is critical.
How they Work: The disk arm moves in one direction, serving requests along the way until it reaches
the end (or beginning), then reverses direction (SCAN) or wraps around (C-SCAN).
Benefits in a Single-User Environment:
o Better Disk Arm Utilization: These algorithms avoid the inefficiency of moving the disk arm
back and forth and ensure a more predictable and systematic approach to servicing requests.
o Improved Seek Time: SCAN and C-SCAN tend to minimize the average seek time compared
to FCFS.
o Less Starvation: While SCAN avoids some of the issues of SSTF (where far requests might
How they Work: Similar to SCAN and C-SCAN, but instead of going to the end of the disk, the arm
stops at the last request in the direction of movement.
Benefits in a Single-User Environment:
o Reduced Seek Time: LOOK and C-LOOK provide a more efficient approach than SCAN,
especially when requests are clustered in specific parts of the disk.
o Optimal for Unpredictable Request Patterns: These algorithms adjust to request locations
dynamically, reducing unnecessary movements.
Improved Performance: Even in a single-user environment, there may be several disk operations
queued at any given time. Algorithms like SSTF, SCAN, and LOOK can optimize the order in which
these operations are executed, reducing seek times and improving overall throughput.
Efficient Resource Utilization: The disk arm’s movement can be optimized, leading to better use of
the mechanical resources of the disk. This is especially important for systems running applications that
involve frequent disk access (e.g., databases or multimedia editing).
Time Sensitivity: In scenarios where disk I/O performance is critical (e.g., real-time processing),
advanced scheduling algorithms can help meet time constraints by minimizing delays and reducing the
overall time spent servicing requests.
Adaptability: Some algorithms (like LOOK and C-LOOK) adapt better to the nature of the request
queue, providing more efficient handling of disk requests that might otherwise cause excessive seek
times under FCFS.
31. Describe three circumstances under which blocking I/O should be used. Describe three
circumstances under which non-blocking I/O should be used? ( APRIL / MAY-2024)
Blocking I/O
Blocking I/O operations halt the execution of a program until the operation is complete. This approach is
simpler and often preferred in scenarios where waiting for the result is acceptable or beneficial:
Non-blocking I/O
Non-blocking I/O allows the program to continue executing while the I/O operation is performed. This
approach is advantageous in scenarios requiring responsiveness and concurrency:
32. Consider a file system in which a file can be deleted and its disk space reclaimed while links to that
file still exist. What problems may occur if a new file is created in the same storage area or with the same
absolute path name? How can these problems be avoided? (APRIL / MAY-2024)
In a file system where files can be deleted and their disk space reclaimed while links to the file still exist,
creating a new file in the same storage area or with the same absolute path name can cause the following
problems:
Problems
1. Dangling Links
o Description: Links pointing to the old file (now deleted) may now point to the newly created
file with the same name or in the same storage area. This can lead to unintended access to
incorrect data or corruption of data integrity.
o Example: If a symbolic link (symlink) points to the deleted file's absolute path, and a new file
is created with the same path, the link will resolve to the new file.
2. Data Corruption
o Description: If the storage area of the deleted file is reused for a new file, but some processes
still reference the old file's metadata, it can result in data corruption or unexpected behavior.
o Example: A program attempting to write to the old file's blocks may inadvertently modify the
new file's data.
3. Security Risks
o Description: Sensitive data might be inadvertently exposed if the new file is accessible through
Solutions
33. Contrast the performance of the three techniques for allocating disk blocks (contiguous, linked, and
indexed) for both sequential and random file access.(APRIL / MAY-2024)
The three common techniques for allocating disk blocks are contiguous, linked, and indexed. Their
performance varies significantly depending on whether file access is sequential or random.
1. Contiguous Allocation
Technique Description:
Allocates consecutive disk blocks for a file. The entire file occupies a single continuous block of
storage.
Performance: Excellent
o Data is stored contiguously, so reading sequentially requires minimal seek time and no
additional disk operations.
o High performance, as all required data can often be read in a single I/O operation.
Advantages: Optimal for workloads involving large, sequential reads or writes (e.g., multimedia files).
Random Access:
2. Linked Allocation
Technique Description:
Each disk block contains a pointer to the next block of the file. Blocks can be scattered across the disk.
Sequential Access:
Performance: Good
o Reading blocks sequentially involves following the pointers, which requires additional disk
operations for pointer traversal.
o Still relatively efficient for small to medium-sized files but slower than contiguous allocation
for large files.
Random Access:
Performance: Poor
o Random access requires traversing pointers from the start of the file or an index, resulting in
significant overhead and higher seek times.
Disadvantages: Particularly inefficient for frequent random access due to high pointer traversal
overhead.
3. Indexed Allocation
Technique Description:
Uses an index block that contains pointers to all the blocks of the file. The file's data blocks can be
located anywhere on the disk.
Performance: Moderate
o Requires reading the index block initially, then accessing data blocks sequentially.
o Slower than contiguous allocation but avoids fragmentation issues.
Random Access:
Performance: Good
o Random access is efficient because the index block provides direct access to any data block
without traversal.
o Index lookup time is minimal compared to traversing linked blocks.
A directory is a data structure used by file systems to organize and manage files. Its organization determines
how files are stored, accessed, and manipulated.
Single-Level Directory:
A simple structure where all files are stored in a single directory. Easy to implement but becomes
cumbersome as the number of files grows.
Example: Early personal computers.
Two-Level Directory:
Provides separate directories for each user. This improves organization and prevents filename conflicts
but can complicate file sharing.
Hierarchical (Tree-Structured) Directory:
Organizes directories in a tree-like structure, allowing for nested directories (subdirectories). It provides
flexibility and scalability.
Example: Most modern file systems (e.g., Windows, Linux).
Acyclic-Graph Directory:
Allows sharing of files or directories by using links, forming an acyclic graph. This supports better
collaboration but requires mechanisms to handle dangling references.
General Graph Directory:
Permits cyclic links, requiring additional mechanisms to prevent infinite loops during directory
traversal.
File system mounting is the process of making a file system accessible to the operating system and its users. It
Steps in Mounting:
1. Verify File System: The OS ensures the integrity of the file system on the device.
2. Attach to Hierarchy: The file system is attached to a mount point, typically an empty
directory.
3. Access: Once mounted, the files and directories on the device become accessible through the
mount point.
Types of Mounting:
o Automatic Mounting: File systems are mounted automatically during boot.
o Manual Mounting: Users or administrators explicitly mount file systems as needed.
o Unmounting: A file system must be unmounted before the device can be safely removed or
ejected.
Purpose: File system mounting allows seamless integration of additional storage devices or remote file
systems into a single directory tree.
The kernel's I/O system is responsible for managing all input and output operations between the hardware
devices and the user-level processes. It abstracts device-specific details and provides a uniform interface.
Components:
1. Device Drivers: Software modules that enable communication with specific hardware devices.
2. Buffering: Temporarily stores data to handle speed mismatches between devices or between
devices and the CPU.
3. Caching: Maintains a copy of frequently accessed data in memory to improve performance.
4. Spooling: Allows devices like printers to handle one job at a time while queuing others.
Responsibilities:
o Device independence: Provides a standard interface regardless of the underlying hardware.
o Error handling: Detects and handles errors in I/O operations.
o Resource management: Allocates and manages I/O resources like disk blocks and buffers.
I/O Scheduling: The kernel prioritizes and schedules I/O requests to optimize performance and reduce
latency, particularly in multi-tasking environments.
35. Suppose that a disk drive has 5000 cylinders numbered 0 to 4999 the drive currently services a
request at cylinder 143, and the previous request was at cylinder 125. the queue of pending requests in
the FIFO order is 86, 1470, 913, 1774, 948, 1509, 1022, 1750 and 130. Starting from the current position,
what is the total distance (in cylinders) that the disk arm moves to satisfy all pending requests for each
of the following algorithms:
(i) FCFS
(ii) SSFT
(iii) SCAN
(iv) LOOK
PREPARED BY: Mr.D.Srinivasan,AP/CSE , Mrs.A.Thilagavathi,AP/CSE & Mr.R.Arunkumar, AP/CSE 70
MAILAM ENGINEERING COLLEGE CS3451-Introduction to Operating System UNIT-IV
(v)C-SCAN. (NOV / DEC-2024)
To calculate the total distance the disk arm moves for each algorithm, we simulate the request servicing order.
Below are detailed calculations for each algorithm:
Sequence:
Calculation:
Distance:
∣143−86∣+∣86−1470∣+∣1470−913∣+∣913−1774∣+∣1774−948∣+∣948−1509∣+∣1509−1022∣+∣1022−1750∣+
∣1750−130∣|143 - 86| + |86 - 1470| + |1470 - 913| + |913 - 1774| + |1774 - 948| + |948 - 1509| +
|1509 - 1022| + |1022 - 1750| +|1750 - 130|∣143−86∣+∣86−1470∣+ ∣1470−913∣+∣913−1774∣+
∣1774−948∣+∣948−1509∣+∣1509−1022∣+ ∣1022−1750∣+∣1750−130∣
57+1384+557+861+826+561+487+728+1620=708157 + 1384 + 557 + 861 + 826 + 561 + 487 + 728 +
1620 = 708157+1384+557+861+826+561+487+728+1620=7081
Sequence:
Calculation:
Distance:
∣143−130∣+∣130−86∣+∣86−913∣+∣913−948∣+∣948−1022∣+∣1022−1470∣+∣1470−1509∣+∣1509−1750∣+
∣1750−1774∣|143 - 130| + |130 - 86| + |86 - 913| + |913 - 948| + |948 - 1022| + |1022 - 1470| +
|1470 - 1509| + |1509 - 1750| + |1750 -
1774|∣143−130∣+∣130−86∣+∣86−913∣+∣913−948∣+∣948−1022∣+∣1022−1470∣+∣1470−1509∣+
∣1509−1750∣+∣1750−1774∣
13+44+827+35+74+448+39+241+24=174513 + 44 + 827 + 35 + 74 + 448 + 39 + 241 + 24 =
PREPARED BY: Mr.D.Srinivasan,AP/CSE , Mrs.A.Thilagavathi,AP/CSE & Mr.R.Arunkumar, AP/CSE 71
MAILAM ENGINEERING COLLEGE CS3451-Introduction to Operating System UNIT-IV
174513+44+827+35+74+448+39+241+24=1745
The disk arm moves in one direction, servicing all requests until it reaches the end of the disk, then reverses
direction.
Sequence:
143 → 913 → 948 → 1022 → 1470 → 1509 → 1750 → 1774 → 4999 → 130 → 86
Calculation:
Distance (upwards):
∣143−913∣+∣913−948∣+∣948−1022∣+∣1022−1470∣+∣1470−1509∣+∣1509−1750∣+∣1750−1774∣+
∣1774−4999∣|143 - 913| + |913 - 948| + |948 - 1022| + |1022 - 1470| + |1470 - 1509| + |1509 - 1750| +
|1750 - 1774| + |1774 -
4999|∣143−913∣+∣913−948∣+∣948−1022∣+∣1022−1470∣+∣1470−1509∣+∣1509−1750∣+∣1750−1774∣+
∣1774−4999∣
=770+35+74+448+39+241+24+3225=4856= 770 + 35 + 74 + 448 + 39 + 241 + 24 + 3225 =
4856=770+35+74+448+39+241+24+3225=4856
Distance (downwards):
∣4999−130∣+∣130−86∣=4869+44=4913|4999 - 130| + |130 - 86| = 4869 + 44 =
4913∣4999−130∣+∣130−86∣=4869+44=4913
(iv) LOOK
LOOK is similar to SCAN but does not move to the ends of the disk unless there are requests there. The disk
arm changes direction once all requests in the current direction are serviced.
Sequence:
Calculation:
Distance (upwards):
The disk arm moves in one direction (upwards), servicing requests until it reaches the end of the disk, then
jumps back to the beginning and continues.
Sequence:
143 → 913 → 948 → 1022 → 1470 → 1509 → 1750 → 1774 → 4999 → 86 → 130
Calculation:
Distance (upwards):
∣143−913∣+∣913−948∣+∣948−1022∣+∣1022−1470∣+∣1470−1509∣+∣1509−1750∣+∣1750−1774∣+
∣1774−4999∣|143 - 913| + |913 - 948| + |948 - 1022| + |1022 - 1470| + |1470 - 1509| + |1509 - 1750| +
|1750 - 1774| + |1774 -
4999|∣143−913∣+∣913−948∣+∣948−1022∣+∣1022−1470∣+∣1470−1509∣+∣1509−1750∣+∣1750−1774∣+
∣1774−4999∣
=770+35+74+448+39+241+24+3225=4856= 770 + 35 + 74 + 448 + 39 + 241 + 24 + 3225 =
4856=770+35+74+448+39+241+24+3225=4856
Jump to start:
∣4999−0∣=4999|4999 - 0| = 4999∣4999−0∣=4999
Distance (upwards from start):
∣0−86∣+∣86−130∣=86+44=130|0 - 86| + |86 - 130| = 86 + 44 = 130∣0−86∣+∣86−130∣=86+44=130
PART – B
1) What is a directory? Outline a tree structured directory structure and an acycle graph directory structure with
appropriate example. (Q.NO: 4)
2) Explain contiguous allocation and linked allocation of disk space with an examples. (Q.NO: 9)
PART – C
1) Consider a disk queue with requests for i/o to blocks on cylinders in this following order.
98,183,37,122,14,124,65,67.
The disk head pointer is initially at cylinder 53. Outline first come first serve disk scheduling algorithm,
SCAN disk scheduling algorithms and Shortest seek time first disk scheduling algorithm with a
diagram.(Q.No:1)
PART – B
1. Write detailed notes on file system interface and file system structure.(Q.NO:7)
2. Following are the references attempted to hard disks : 67,22,78,34,21,78,99. Recommend a suitable
disk scheduling algorithm among FIFO, SSTF, SCAN AND LOOK after applying all. Provide
statements that support your recommendation.(Note : Initial head position is at 20)(Q.NO:29)
PART – B
1. Is disk scheduling, other than FCFS scheduling, useful in a single- user environment? Explain your
answer. (Q.No.30)
2. Describe three circumstances under which blocking I/O should be used. Describe three circumstances
under which non-blocking I/O should be used. ( Q.No.31)
3. Consider a file system in which a file can be deleted and its disk space reclaimed while links to that file
still exist. What problems may occur if a new file is created in the same storage area or with the same absolute
path name? How can these problems be avoided? (Q.No.32)
4. Contrast the performance of the three techniques for allocating disk blocks (contiguous, linked, and
indexed) for both sequential and random file access? (Q.No.33)
PART – B
2. Suppose that a disk drive has 5000 cylinders numbered 0 to 4999 the drive currently services a request
at cylinder 143, and the previous request was at cylinder 125. the queue of pending requests in the FIFO order
is 86, 1470, 913, 1774, 948, 1509, 1022, 1750 and 130. Starting from the current position, what is the total
distance (in cylinders) that the disk arm moves to satisfy all pending requests for each of the following
algorithms:
(i) FCFS
(ii) SSFT
(iii) SCAN
(iv) LOOK
(v) C-SCAN (Q.No.35)
● Virtualization uses software to create an abstraction layer over computer hardware that allows the
hardware elements of a single computer—processors, memory, storage and more—to be divided
into multiple virtual computers, commonly called virtual machines (VMs).
● Each VM runs its own operating system (OS) and behaves like an independent computer, even
though it is running on just a portion of the actual underlying computer hardware.
3) What are the applications of virtual machines?
● Building and deploying apps to the cloud.
● Trying out a new operating system (OS), including beta releases.
● Spinning up a new environment to make it simpler and quicker for developers to run dev-test
scenarios.
● Backing up your existing OS.
● Accessing virus-infected data or running an old application by installing an older OS.
Para virtualization is the category of CPU virtualization which uses hypercalls for operations to
handle instructions at compile time. In para virtualization, guest OS is not completely isolated but it is
partially isolated by the virtual machine from the virtualization layer and hardware. VMware and Xen are
some examples of para virtualization.
A system with virtualization, even a single-CPU system, frequently acts like a multiprocessor
system. The virtualization software presents one or more virtual CPUs to each of the virtual machines
running on the system and then schedules the use of the physical CPUs among the virtual machines.
Virtual to physical (V2P) is the process of converting or porting a virtual machine (VM) onto
and/or as a standard physical machine. V2P allows a VM to transform into a physical machine without
losing its state, data and overall operations.
Network Virtualization
Storage Virtualization
Server Virtualization
Application Virtualization
Desktop Virtualization
The Core OS Layer occupies the bottom position of the iOS stack and, as such, sits directly on top
of the device hardware.
The layer provides a variety of services including low level networking, access to external
accessories and the usual fundamental operating system services such as memory management, file
system handling and threads.
Advantages: The code can be written faster, is more compact, and is easier to understand and debug. In
addition, improvements in compiler technology will improve the generated code for the entire operating
system by simple recompilation.
An operating system is far easier to port — to move to some other hardware — if it is written in a higher-
level language.
Disadvantages: Using high level language for implementing an operating system leads to a loss in
speed and increase in storage requirements. However in modern systems only a small amount of code is
needed for high performance, such as the CPU scheduler and memory manager.
26) List any two components that are unique for mobile OS. (Nov/Dec-2023)
Its design lets users manipulate the mobile devices intuitively, with finger movements that mirror
common motions, such as pinching, swiping, and tapping.
27) What is the major design goal for the android platform? (April/May-2024)
The major design goal for the Android platform is to provide an open-source, flexible, and
customizable environment that enables developers to create applications that can run on a wide variety
of devices. Android's design emphasizes:
1. Portability
2. User Experience
3. Interoperability
4. Security
5. Developer Flexibility.
1. Open Source
2. Wide Device Compatibility
3. Customization Options
4. Google Integration
5. Large App Ecosystem
6. Multi-tasking
7. Hardware Variety
8. Google Assistant
9. Frequent Software Updates.
PART-B
Virtual machines first appeared commercially on IBM mainframes in 1972. Virtualization was
provided by the IBM VM operating system. This system has evolved and is still available. In addition, many
of its original concepts are found in other systems, making it worth exploring.
IBM VM370 divided a mainframe into multiple virtual machines, each running its own operating
system. A major difficulty with the VM approach involved disk systems. Suppose that the physical machine
had three disk drives but wanted to support seven virtual machines.
It could not allocate a disk drive to each virtual machine. The solution was to provide virtual disks—
termed minidisks in IBM’s VM operating system.
● The minidisks Virtual Machines to the system’s hard disks in all respects except size. The
system implemented each minidisk by allocating as many tracks on the physical disks as the
minidisk needed.
● Once the virtual machines were created, users could run any of the operating systems or software
packages that were available on the underlying machine. For the IBM VM system, a user
normally ran CMS—a single-user interactive operating system.
● For many years after IBM introduced this technology, virtualization remained in its domain.
Most systems could not support virtualization. However, a formal definition of virtualization
helped to establish system requirements and a target for functionality.
1. A VMM provides an environment for programs that is essentially identical to the original machine.
2. Programs running within that environment show only minor performance decreases.
3. The VMM is in complete control of system resources. These requirements of fidelity, performance,
and safety still guide virtualization efforts today. By the late 1990s, Intel 80x86 CPUs had become
common, fast, and rich in features. Accordingly, developers launched multiple efforts to implement
virtualization on that platform.
● Both Xen and VMware created technologies, still used today, to allow guest operating systems
to run on the 80x86. Since that time, virtualization has expanded to include all common CPUs,
many commercial and open-source tools, and many operating systems.
● For example, the open-source Virtual Box project (http://www.virtualbox.org) provides a
program than runs on Intel x86 and AMD64 CPUs and on Windows, Linux, Mac OS X, and
Several advantages make virtualization is more attractive. Most of them are fundamentally related
to the ability to share the same hardware yet run several different execution environments (that is,
different operating systems) concurrently. One important advantage of virtualization is that the host
system is protected from the virtual machines, just as the virtual machines are protected from each other.
● A virus inside a guest operating system might damage that operating system but is unlikely to
affect the host or the other guests. Because each virtual machine is almost completely isolated
from all other virtual machines, there are almost no protection problems.
● A potential disadvantage of isolation is that it can prevent sharing of resources. Two approaches
to provide sharing have been implemented.
● First, it is possible to share a file-system volume and thus to share files. Second, it is possible to
define a network of virtual machines, each of which can send information over the virtual
communications network.
● The network is modeled after physical communication networks but is implemented in software.
Of course, the VMM is free to allow any number of its guests to use physical resources, such as a
physical network connection (with sharing provided by the VMM), in which case the allowed
guests could communicate with each other via the physical network.
● The copy can be used to create a new VM or to move a VM from one machine to another with
its current state intact. The guest can then resume where it was, as if on its original machine,
creating a clone. The snapshot records a point in time, and the guest can be reset to that point if
necessary (for example, if a change was made but is no longer wanted).
● Often, VMMs allow many snapshots to be taken. For example, snapshots might record a guest’s
state every day for a month, making restoration to any of those snapshot states possible. These
abilities are used to good advantage in virtual environments. A virtual machine system is a perfect
vehicle for operating-system research and development.
● Normally, changing an operating system is a difficult task. Operating systems are large and
complex programs, and a change in one part may cause obscure bugs to appear in some other part.
● Furthermore, the operating system runs on and controls the entire machine, meaning that the
system must be stopped and taken out of use while changes are made and tested. This period is
commonly called system-development time. Since it makes the system unavailable to users,
system-development time on shared systems is often scheduled late at night or on weekends,
when system load is low.
● A virtual-machine system can eliminate much of this latter problem. System programmers are
given their own virtual machine, and system development is done on the virtual machine instead
of on a physical machine. Normal system operation is disrupted only when a completed and tested
change is ready to be put into production.
● Another advantage of virtual machines for developers is that multiple operating systems can
run concurrently on the developer’s workstation. This virtualized workstation allows for rapid
porting and testing of programs in varying environments.
● In addition, multiple versions of a program can run, each in its own isolated operating system,
within one system. Similarly, quality assurance engineers can test their applications in multiple
environments without buying, powering, and maintaining a computer for each environment.
● Virtual Machines Consider, too, that management tools that are part of the VMM allow
system administrators to manage many more systems than they otherwise could. A virtual
environment might include 100 physical servers, each running 20 virtual servers.
● Without virtualization, 2,000 servers would require several system administrators. With
virtualization and its tools, the same work can be managed by one or two administrators. One of
the tools that make this possible is templating, in which one standard virtual machine image,
● Other features include managing the patching of all guests, backing up and restoring the guests,
and monitoring their resource use. Virtualization can improve not only resource utilization but
also resource management. Some VMMs include a live migration feature that moves a running
guest from one physical server to another without interrupting its operation or active network
connections.
● If a server is overloaded, live migration can thus free resources on the source host while not
disrupting the guest. Similarly, when host hardware must be repaired or upgraded, guests can be
migrated to other servers, the evacuated host can be maintained, and then the guests can be
migrated back.
● This operation occurs without downtime and without interruption to users. Think about the
possible effects of virtualization on how applications are deployed. If a system can easily add,
remove, and move a virtual machine, then why install applications on that system directly?
Instead, the application could be preinstalled on a tuned and customized operating system in a
virtual machine.
● Thus, they need not be expensive, high-performance components. Other uses of virtualization are
sure to follow as it becomes more prevalent and hardware support continues to improve.
Although the virtual machine concept is useful, it is difficult to implement. Much work is required
to provide an exact duplicate of the underlying machine. This is especially a challenge on dual-mode
systems, where the underlying machine has only user mode and kernel mode.
● The building blocks that are needed for efficient virtualization. The ability to virtualize
depends on the features provided by the CPU. If the features are sufficient, then it is possible to
write a VMM that provides a guest environment. Otherwise, virtualization is impossible.
● VMMs use several techniques to implement virtualization, including trap-and-emulate and
binary translation. We discuss each of these techniques in this section, along with the hardware
support needed to support virtualization.
● One important concept found in most virtualization options is the implementation of a virtual
CPU (VCPU). The VCPU does not execute code. Rather, it represents the state of the CPU as the
guest machine believes it to be.
● The kernel, of course, runs in kernel mode, and it is not safe to allow user-level code to run in
kernel mode. Just as the physical machine has two modes, however, so must the virtual machine.
Consequently, we must have a virtual user mode and a virtual kernel mode, both of which run in
physical user mode.
● Those actions that cause a transfer from user mode to kernel mode on a real machine (such as a
system call, an interrupt, or an attempt to execute a privileged instruction) must also cause a
transfer from virtual user mode to virtual kernel mode in the virtual machine. How can such a
transfer be accomplished?
● The procedure is as follows: When the kernel in the guest attempts to execute a privileged
instruction, that is an error (because the system is in user mode) and causes a trap to the VMM in
the real machine.
● The VMM gains control and executes (or “emulates”) the action that was attempted by the guest
kernel on the part of the guest. It then returns control to the virtual machine. This is called the
trap-and-emulate method.
● Most virtualization products use this method to one extent or other. With privileged instructions,
time becomes an issue. All non privileged instructions run natively on the hardware, providing the
same performance
● Privileged instructions create extra overhead, however, causing the guest to run more slowly
than it would natively. In addition, the CPU is being multiprogrammed among many virtual
machines, which can further slow down the virtual machines in unpredictable ways.
● This problem has been approached in various ways. IBM VM, for example, allows normal
instructions for the virtual machines to execute directly on the hardware. Only the privileged
instructions (needed mainly for I/O) must be emulated and hence execute more slowly.
(i) Trap-and-Emulate
On a typical dual-mode system, the virtual machine guest can execute only in user mode
(unless extra hardware support is provided). The kernel, of course, runs in kernel mode, and it is not safe
to allow user-level code to run in kernel mode.
● Just as the physical machine has two modes, however, so must the virtual machine. Consequently,
we must have a virtual user mode and a virtual kernel mode, both of which run in physical user
mode.
● Those actions that cause a transfer from user mode to kernel mode on a real machine (such as a
system call, an interrupt, or an attempt to execute a privileged instruction) must also cause a
transfer from virtual user mode to virtual kernel mode in the virtual machine.
● How can such a transfer be accomplished? The procedure is as follows: When the kernel in the
guest attempts to execute a privileged instruction, that is an error (because the system is in user
mode) and causes a trap to the VMM in the real machine.
● The VMM gains control and executes (or “emulates”) the action that was attempted by the guest
kernel on the part of the guest. It then returns control to the virtual machine. This is called the
trap-and-emulate method and is shown in Fig 5.1.
Most virtualization products use this method to one extent or other. With privileged instructions, time
becomes an issue. All nonprivileged instructions run natively on the hardware, providing the same
performance
● This problem has been approached in various ways. IBM VM, for example, allows normal
instructions for the virtual machines to execute directly on the hardware. Only the privileged
instructions (needed mainly for I/O) must be emulated and hence execute more slowly.
● In general, with the evolution of hardware, the performance of trap-and-emulate functionality has
been improved, and cases in which it is needed have been reduced. For example, many CPUs now
have extra modes added to their standard dual-mode operation.
The VCPU need not keep track of what mode the guest operating system is in, because the physical
CPU performs that function. In fact, some CPUs provide guest CPU state management in hardware, so
the VMM need not supply that functionality, removing the extra overhead.
Some CPUs do not have a clean separation of privileged and non privileged instructions.
Unfortunately for virtualization implementers, the Intel x86 CPU line is one of them.
● No thought was given to running virtualization on the x86 when it was designed. (In fact, the first
CPU in the family—the Intel 4004, released in 1971—was designed to be the core of a
calculator.) The chip has maintained backward compatibility throughout its lifetime, preventing
changes that would have made virtualization easier through many generations.
● Let’s consider an example of the problem. The command popf loads the flag register from the
contents of the stack. If the CPU is in privileged mode, all of the flags are replaced from the stack.
If the CPU is in user mode, then only some flags are replaced, and others are ignored.
Binary translation is fairly simple in concept but complex in implementation. The basic steps are as
follows:
1. If the guest VCPU is in user mode, the guest can run its instructions natively on a physical CPU.
2. If the guest VCPU is in kernel mode, then the guest believes that it is running in kernel mode. The
VMM examines every instruction the guest executes in virtual kernel mode by reading the next few
instructions that the guest is going to execute, based on the guest’s program counter. Instructions other
than special instructions are run natively. Special instructions are translated into a new set of instructions
that perform the equivalent task—for example changing the flags in the VCPU. Binary translation is
shown in Fig 5.2.
The basic method of binary translation just described would execute correctly but perform poorly.
Fortunately, the vast majority of instructions would execute natively.
● VMware tested the performance impact of binary translation by booting one such system,
Windows XP, and immediately shutting it down while monitoring the elapsed time and the
number of translations produced by the binary translation method.
● The result was 950,000 translations, taking 3 microseconds each, for a total increase of 3 seconds
(about 5%) over native execution of Windows XP. To achieve that result, developers used many
performance improvements that we do not discuss here. For more information, consult the
bibliographical notes at the end of this chapter.
Without some level of hardware support, virtualization would be impossible. The more hardware
support available within a system, the more feature-rich and stable the virtual machines can be and the
better they can perform. In the Intel x86 CPU family, Intel added new virtualization support in successive
generations (the VT-x instructions) beginning in 2005.
● Now, binary translation is no longer needed. In fact, all major general-purpose CPUs are
providing extended amounts of hardware support for virtualization. For example, AMD
virtualization technology (AMD-V) has appeared in several AMD processors starting in 2006.
● In guest mode, the virtualized operating system thinks it is running on native hardware and
sees whatever devices are included in the host’s definition of the guest.
● The functionality in Intel VT-X is similar, providing root and non root modes, equivalent to
host and guest modes. Both provide guest VCPU state data structures to load and save guest CPU
state automatically during guest context switches.
● In addition, virtual machine control structures (VMCSs) are provided to manage guest and
host state, as well as the various guest execution controls, exit controls, and information about
why guests exit back to the host.
● In the latter case, for example, a nested page-table violation caused by an attempt to access
unavailable memory can result in the guest’s exit. AMD and Intel have also addressed memory
management in the virtual environment. With AMD’s RVI and Intel’s EPT memory management
enhancements, VMMs no longer need to implement software NPTs.
● In essence, these CPUs implement nested page tables in hardware to allow the VMM to fully
control paging while the CPUs accelerate the translation from virtual to physical addresses. The
NPTs add a new layer, one representing the guest’s view of logical-to-physical address
translation.
● The CPU page-table walking function includes this new layer as necessary, walking through
the guest table to the VMM table to find the physical address desired. A TLB miss results in a
performance penalty, because more tables must be traversed (the guest and host page tables) to
complete the lookup.
● Shows the extra translation work performed by the hardware to translate from a guest virtual
address to a final physical address. I/O is another area improved by hardware assistance. Consider
that the standard direct-memory-access (DMA) controller accepts a target memory address and a
source I/O device and transfers data between the two without operating-system action.
● First, the VMM sets up protection domains to tell the CPU which physical memory belongs to
each guest. Next, it assigns the I/O devices to the protection domains, allowing them direct access
to those memory regions and only those regions.
● The hardware then transforms the address in a DMA request issued by an I/O device to the host
physical memory address associated with the I/O. In this manner DMA transfers are passed
through between a guest and a device without VMM interference. Similarly, interrupts must be
delivered to the appropriate guest and must not be visible to other guests.
● By providing an interrupt remapping feature, CPUs with virtualization hardware assistance
automatically deliver an interrupt destined for a guest to a core that is currently running a thread
of that guest.
● That way, the guest receives interrupts without the VMM’s needing to intercede in their
delivery. Without interrupt remapping, malicious guests can generate interrupts that can be used
to gain control of the host system. (See the bibliographical notes at the end of this chapter for
more details.)
4) Explain in detail about Types of Virtual Machines and Their Implementations. (April/May-2023
& Nov/Dec-2023)
Without some level of hardware support, virtualization would be impossible. The more hardware
support available within a system, the more feature-rich and stable the virtual machines can be and the
better they can perform.
● In the Intel x86 CPU family, Intel added new virtualization support in successive generations
(the VT-x instructions) beginning in 2005. Now, binary translation is no longer needed. In
fact, all major general-purpose CPUs are providing extended amounts of hardware support for
virtualization.
● The NPTs add a new layer, one representing the guest’s view of logical-to-physical address
translation. The CPU page-table walking function includes this new layer as necessary, walking
through the guest table to the VMM table to find the physical address desired.
● In CPUs that provide hardware-assisted DMA. First, the VMM sets up protection domains to tell
the CPU which physical memory belongs to each guest. Next, it assigns the I/O devices to the
protection domains, allowing them direct access to those memory regions and only those regions.
● The hardware then transforms the address in a DMA request issued by an I/O device to the host
physical memory address associated with the I/O. In this manner DMA transfers are passed
through between a guest and a device without VMM interference. Similarly, interrupts must
be delivered to the appropriate guest and must not be visible to other guests.
We’ve now looked at some of the techniques used to implement virtualization. Next, we consider
the major types of virtual machines, their implementation, their functionality, and how they use the
building blocks just described to create a virtual environment.
Of course, the hardware on which the virtual machines are running can cause great variation in
implementation methods. Here, we discuss the implementations in general, with the understanding that
VMMs take advantage of hardware assistance where it is available Shown in Fig 5.3.
Whatever the hypervisor type, at the time a virtual machine is created, its creator gives the
VMM certain parameters. These parameters usually include the number of CPUs, amount of memory,
networking details, and storage details that the VMM will take into account when creating the guest.
For example, a user might want to create a new guest with two virtual CPUs, 4 GB of memory,
10 GB of disk space, one network interface that gets its IP address via DHCP, and access to the DVD
drive.
● The VMM then creates the virtual machine with those parameters. In the case of a type 0
hypervisor, the resources are usually dedicated. In this situation, if there are not two virtual CPUs
available and unallocated, the creation request in our example will fail. For other hypervisor
types, the resources are dedicated or virtualized, depending on the type.
● Certainly, an IP address cannot be shared, but the virtual CPUs are usually multiplexed on the
physical CPUs. Similarly, memory management usually involves allocating more memory to
guests than actually exists in physical memory.
● These steps are quite simple compared with building, configuring, running, and removing
physical machines. Creating a virtual machine from an existing one can be as easy as clicking the
“clone” button and providing a new name and IP address.
● This ease of creation can lead to virtual machine sprawl, which occurs when there are so many
virtual machines on a system that their use, history, and state become confusing and difficult to
track.
Type 0 hypervisors have existed for many years under many names, including “partitions” and
“domains”. They are a hardware feature, and that brings its own positives and negatives. Operating
systems need do nothing special to take advantage of their features. The VMM itself is encoded in the
firmware and loaded at boot time. In turn, it loads the guest images to run in each partition.
The feature set of a type 0 hypervisor tends to be smaller than those of the other types because it
is implemented in hardware. For example, a system might be split into four virtual systems, each with
dedicated CPUs, memory, and I/O devices.
● Each guest believes that it has dedicated hardware because it does, simplifying many
implementation details. I/O presents some difficulty, because it is not easy to dedicate I/O devices
to guests if there are not enough.
● What if a system has two Ethernet ports and more than two guests? For example, either all guests
must get their own I/O devices, or the system must provide I/O device sharing. In these cases, the
hypervisor manages shared access or grants all devices to a control partition.
● In the control partition, a guest operating system provides services (such as networking) via
daemons to other guests, and the hypervisor routes I/O requests appropriately.
● Some type 0 hypervisors are even more sophisticated and can move physical CPUs and memory
between running guests. In these cases, the guests are para virtualized, aware of the virtualization
and assisting in its execution is Shown in Fig 5.4.
(iii)Type 1 Hypervisor
Type 1 hypervisors are commonly found in company data centers and are in a sense becoming
“the data-center operating system.” They are special-purpose operating systems that run natively on the
hardware, but rather than providing system calls and other interfaces for running programs, they create,
run, and manage guest operating systems.
● In addition to running on standard hardware, they can run on type 0 hypervisors, but not on other
type 1 hypervisors. Whatever the platform, guests generally do not know they are running on
anything but the native hardware.
● Type 1 hypervisors run in kernel mode, taking advantage of hardware protection. Where the host
CPU allows, they use multiple modes to give guest operating systems their own control and
improved performance. They implement device drivers for the hardware they run on, because no
other component could do so.
● Because they are operating systems, they must also provide CPU scheduling, memory
management, I/O management, protection, and even security. Frequently, they provide APIs, but
those APIs support applications in guests or external applications that supply features like
backups, monitoring, and security.
● The price of this increased manageability is the cost of the VMM (if it is a commercial product),
the need to learn new management tools and methods, and the increased complexity. Another
type of type 1 hypervisor includes various general-purpose operating systems with VMM
functionality.
● This type of VMM is simply another process run and managed by the host, and even the host does
not know virtualization is happening within the VMM. Type 2 hypervisors have limits not
associated with some of the other types.
● For example, a user needs administrative privileges to access many of the hardware assistance
features of modern CPUs. If the VMM is being run by a standard user without additional
privileges, the VMM cannot take advantage of these features.
● Due to this limitation, as well as the extra overhead of running a general-purpose operating
system as well as guest operating systems, type 2 hypervisors tend to have poorer overall
performance than type 0 or 1.
● As is often the case, the limitations of type 2 hypervisors also provide some benefits. They run on
a variety of general-purpose operating systems, and running them requires no changes to the host
operating system. A student can use a type 2 hypervisor, for example, to test a non-native
operating system without replacing the native operating system.
● In fact, on an Apple laptop, a student could have versions of Windows, Linux, Unix, and less
common operating systems all available for learning and experimentation.
As we’ve seen, Para virtualization takes a different tack than the other types of virtualizations.
Rather than try to trick a guest operating system into believing it has a system to itself, Para virtualization
presents the guest with a system that is similar but not identical to the guest’s preferred system.
● The guest must be modified to run on the Para virtualized virtual hardware. The gain for this extra
work is more efficient use of resources and a smaller virtualization layer. The Xen VMM, which
is the leader in Para virtualization, has implemented several techniques to optimize the
performance of guests as well as of the host system.
● For example, as we have seen, some VMMs present virtual devices to guests that appear to be real
devices. Instead of taking that approach, the Xen VMM presents clean and simple device
abstractions that allow efficient I/O, as well as good communication between the guest and the
VMM about device I/O. For each device used by each guest, there is a circular buffer shared by
the guest and the VMM via shared memory. Read and write data are placed in this buffer.
● For memory management, Xen does not implement nested page tables. Rather, each guest has its
own set of page tables, set to read-only. Xen requires the guest to use a specific mechanism, a
hyper call from the guest to the hypervisor VMM, when a page-table change is needed.
● This means that the guest operating system’s kernel code must be changed from the default code
to these Xen-specific methods. To optimize performance, Xen allows the guest to queue up
multiple page-table changes asynchronously via hyper calls and then check to ensure that the
changes are complete before continuing operation.
● Xen allowed virtualization of x86 CPUs without the use of binary translation, instead requiring
modifications in the guest operating systems like the one described above. Over time, Xen has
taken advantage of hardware features supporting virtualization.
● As a result, it no longer requires modified guests and essentially does not need the Para
virtualization method. Para virtualization is still used in other solutions, however, such as type 0
hypervisors Shown in Fig 5.5.
● For example, Oracle’s Java has many features that depend on its running in the Java virtual
machine (JVM), including specific methods for security and memory management. If we define
virtualization as including only duplication of hardware, this is not really virtualization at all.
● This arrangement means that Java programs are written once and then can run on any system
(including all of the major operating systems) on which a JVM is available. The same can be said
for interpreted languages, which run inside programs that read each instruction and interpret it
into native operations.
(vii) Emulation
Virtualization is probably the most common method for running applications designed for one
operating system on a different operating system, but on the same CPU. This method works relatively
efficiently because the applications were compiled for the same instruction set as the target system uses.
● But what if an application or operating system needs to run on a different CPU? Here, it is
necessary to translate the entire source CPU’s instructions so that they are turned into the
equivalent instructions of the target CPU.
● Such an environment is no longer virtualized but rather is fully emulated. Emulation is useful
when the host system has one system architecture and the guest system was compiled for a
different architecture.
● For example, suppose a company has replaced its outdated computer system with a new system
but would like to continue to run certain important programs that were compiled for the old
system. The programs could be run in an emulator that translates each of the outdated system’s
instructions into the native instruction set of the new system.
● Emulation can increase the life of programs and allow us to explore old architectures without
having an actual old machine. As may be expected, the major challenge of emulation is
performance. Instruction-set emulation can run an order of magnitude slower than native
instructions.
● Consider one example of application containment. Starting with version 10, Oracle Solaris has
included containers, or zones, that create a virtual layer between the operating system and the
applications.
● In this system, only one kernel is installed, and the hardware is not virtualized. Rather, the
operating system and its devices are virtualized, providing processes within a zone with the
impression that they are the only processes on the system.
● One or more containers can be created, and each can have its own applications, network stacks,
network address and ports, user accounts, and so on. CPU and memory resources can be divided
among the zones and the system-wide processes.
● Each zone in fact can run its own scheduler to optimize the performance of its applications on the
allotted resources.
Thus far, we have explored the building blocks of virtualization and the various types of
virtualizations. In this section, we take a deeper dive into the operating system aspects of virtualization,
including how the VMM provides core operating-system functions like scheduling, I/O, and memory
management.
A system with virtualization, even a single-CPU system, frequently acts like a multiprocessor
system. The virtualization software presents one or more virtual CPUs to each of the virtual machines
running on the system and then schedules the use of the physical CPUs among the virtual machines.
● The significant variations among virtualization technologies make it difficult to summarize the
effect of virtualization on scheduling. First, let’s consider the general case of VMM scheduling.
The VMM has a number of physical CPUs available and a number of threads to run on those
CPUs.
● In this situation, the guests act much like native operating systems running on native CPUs. Of
course, in other situations, there may not be enough CPUs to go around. The VMM itself needs
some CPU cycles for guest management and I/O management and can steal cycles from the
guests by scheduling its threads across all of the system CPUs, but the impact of this action is
relatively minor.
● More difficult is the case of over commitment, in which the guests are configured for more CPUs
than exist in the system. Here, a VMM can use standard scheduling algorithms to make progress
on each thread but can also add a fairness aspect to those algorithms.
● For example, if there are six hardware CPUs and 12 guest-allocated CPUs, the VMM could
allocate CPU resources proportionally, giving each guest half of the CPU resources it believes it
has.
● The VMM can still present all 12 virtual CPUs to the guests, but in mapping them onto physical
CPUs, the VMM can use its scheduler to share them appropriately. Even given a scheduler that
provides fairness, any guest operating-system scheduling algorithm that assumes a certain amount
of progress in a given amount of time will be negatively affected by virtualization.
● Consider a timesharing operating system that tries to allot 100 milliseconds to each time slice to
give users a reasonable response time. Within a virtual machine, this operating system is at the
mercy of the virtualization system as to what CPU resources it actually receives.
Efficient memory use in general-purpose operating systems is one of the major keys to
performance. In virtualized environments, there are more users of memory (the guests and their
applications, as well as the VMM), leading to more pressure on memory use.
● For example, VMware ESX uses at least three methods of memory management. Before memory
optimization can occur, the VMM must establish how much real memory each guest should use.
To do that, the VMM first evaluates the maximum memory size of each guest as dictated when it
is configured.
● General-purpose operating systems do not expect the amount of memory in the system to change,
so VMMs must maintain the illusion that the guest has that amount of memory. Next, the VMM
computes a target real memory allocation for each guest based on the configured memory for that
guest and other factor, such as over commitment and system load.
● It then uses the three low-level mechanisms below to reclaim memory from the guests. The
overall effect is to enable guests to behave and perform as if they had the full amount of memory
requested although in reality they have less.
● Recall that a guest believes it controls memory allocation via its page table management, whereas
in reality the VMM maintains a nested page table that re-translates the guest page table to the real
page table. The VMM can use this extra level of indirection to optimize the guest’s use of
memory without the guest’s knowledge or help.
● One approach is to provide double paging, in which the VMM has its own page-replacement
algorithms and pages to backing-store pages that the guest believes are in physical memory. Of
course, the VMM has knows less about the guest’s memory access patterns than the guest does,
so its paging is less efficient, creating performance problems.
● VMMs do use this method when other methods are not available or are not providing enough free
memory. However, it is not the preferred approach.
● At the same time, the guest is using its own memory management and paging algorithms to
manage the available memory, which is the most efficient option. If memory pressure within the
entire system decreases, the VMM will tell the balloon process within the guest to unpin and free
some or all of the memory, allowing the guest more pages for its use.
Another common method for reducing memory pressure is for the VMM to determine if the same
page has been loaded more than once. If this is the case, to the VMM reduces the number of copies of the
page to one and maps the other users of the page to that one copy.
● If they are, one page is freed, and its logical address is mapped to the other’s physical address.
This technique might seem at first to be ineffective, but consider that guests run operating
systems. If multiple guests run the same operating system, then only one copy of the active
operating-system pages need be in memory.
In the area of I/O, hypervisors have some leeway and can be less concerned with exactly
representing the underlying hardware to their guests. Because of all the variation in I/O devices,
operating systems are used to dealing with varying and flexible I/O mechanisms.
● For example, operating systems have a device-driver mechanism that provides a uniform interface
to the operating system whatever the I/O device. Device-driver interfaces are designed to allow
third-party hardware manufacturers to provide device drivers connecting their devices to the
operating system.
● In the area of networking, VMMs also have work to do. General-purpose operating systems
typically have one Internet protocol (IP) address, although they sometimes have more than one—
for example, to connect to a management network, backup network, and production network.
● With virtualization, each guest needs at least one IP address, because that is the guest’s main
mode of communication. Therefore, a server running a VMM may have dozens of addresses, and
the VMM acts as a virtual switch to route the network packets to the addressed guest. The guests
can be “directly” connected to the network by an IP address that is seen by the broader network
(this is known as bridging).
● Alternatively, the VMM can provide a network address translation (NAT) address. The NAT
address is local to the server on which the guest is running, and the VMM provides routing
between the broader network and the guest. The VMM also provides firewalling, moderating
connections between guests within the system and between guests and external systems.
● Even the standard multi boot method of slicing the root disk into partitions, installing a boot
manager in one partition, and installing each other operating system in another partition is not
● Once again, the solution to this problem depends on the type of hypervisor. Type 0 hypervisors do
tend to allow root disk partitioning, partly because these systems tend to run fewer guests than
other systems.
● Alternatively, they may have a disk manager as part of the control partition, and that disk
manager provides disk space (including boot disks) to the other partitions.
● The guest then executes as usual, with the VMM translating the disk I/O requests coming from
the guest into file I/O commands to the correct files. Frequently, VMMs provide a mechanism to
capture a physical system as it is currently configured and convert it to a guest that the VMM can
manage and run.
● Based on the discussion above, it should be clear that this physicalto-virtual (P-to-V) conversion
reads the disk blocks of the physical system’s disks and stores them within files on the VMM’s
system or on shared storage that the VMM can access.
One feature not found in general-purpose operating systems but found in type 0 and type 1
hypervisors is the live migration of a running guest from one system to another. We mentioned this
capability earlier.
1. The source VMM establishes a connection with the target VMM and confirms that it is allowed to
send a guest.
2. The target creates a new guest by creating a new VCPU, new nested page table, and other state
storage.
4. The source sends all read-write pages to the target, marking them as clean.
5. The source repeats step 4, as during that step some pages were probably modified by the guest and
are now dirty. These pages need to be sent again and marked again as clean.
6. When the cycle of steps 4 and 5 becomes very short, the source VMM freezes the guest, sends the
VCPU’s final state, sends other state details, sends the final dirty pages, and tells the target to start
running the guest. Once the target acknowledges that the guest is running, the source terminates the guest
is shown in fig 5.7.
● Before virtualization, this did not happen, as the MAC address was tied to physical hardware.
With virtualization, the MAC must be movable for existing networking connections to continue
without resetting. Modern network switches understand this and route traffic wherever the MAC
address is, even accommodating a move. A limitation of live migration is that no disk state is
transferred.
6) Write a note on Mobile OS – iOS and Android of Architecture and SDK Framework.
(April/May-2021)(Nov/Dec-2023)
iPhone OS becomes iOS
Prior to the release of the iPad in 2010, the operating system running on the iPhone was generally
referred to as iPhone OS. Unfortunately, iOS is also the name used by Cisco for the operating
system on its routers. When performing an internet search for iOS, therefore, be prepared to see
large numbers of results for Cisco “iOS which have absolutely nothing to do with Apple “iOS.
iOS consists of a number of different software layers, each of which provides programming
frameworks for the development of applications that run on top of the underlying hardware.
Some diagrams designed to graphically depict the iOS software stack show an additional box
positioned above the Cocoa Touch layer to indicate the applications running on the device.
In the above diagram we have not done so since this would suggest that the only interface
available to the app is Cocoa Touch. In practice, an app can directly call down any of the layers of
the stack to perform tasks on the physical device.
That said, however, each operating system layer provides an increasing level of abstraction away
from the complexity of working with the hardware.
The Cocoa Touch layer sits at the top of the iOS stack and contains the frameworks that are most
commonly used by iPhone application developers. Cocoa Touch is primarily written in Objective-
C, is based on the standard Mac OS X Cocoa API (as found on Apple desktop and laptop
computers) and has been extended and modified to meet the needs of the iPhone hardware.
The Cocoa Touch layer provides the following frameworks for iPhone app development:
The UIKit framework is a vast and feature rich Objective-C based programming interface.
It is, without question, the framework with which you will spend most of your time
working. Entire books could, and probably will, be written about the UIKit framework
alone.
User interface creation and management (text fields, buttons, labels, colors, fonts etc)
Application lifecycle management
Application event handling (e.g. touch screen user interaction)
Multitasking
Wireless Printing
The Map Kit framework provides a programming interface which enables you to build map-based
capabilities into your own applications. This allows you to, amongst other things, display
scrollable maps for any location, display the map corresponding to the current geographical
location of the device and annotate the map in a variety of ways.
The Push Notification Service allows applications to notify users of an event even when the
application is not currently running on the device. Since the introduction of this service it has
most commonly been used by news based applications.
Typically, when there is breaking news, the service will generate a message on the device with the
news headline and provide the user the option to load the corresponding news app to read more
details. This alert is typically accompanied by an audio alert and vibration of the device. This
feature should be used sparingly to avoid annoying the user with frequent interruptions.
The Message UI framework provides everything you need to allow users to compose and send
email messages from within your application. In fact, the framework even provides the user
interface elements through which the user enters the email addressing information and message
content.
Alternatively, this information may be pre-defined within your application and then displayed for
the user to edit and approve prior to sending
The Game Kit framework provides peer-to-peer connectivity and voice communication between
multiple devices and users allowing those running the same app to interact.
When this feature was first introduced it was anticipated by Apple that it would primarily be used
in multi-player games (hence the choice of name) but the possible applications for this feature
clearly extend far beyond games development.
The purpose of the iAd Framework is to allow developers to include banner advertising within
their applications. All advertisements are served by Apple‟s own ad service. Event Kit UI
Framework (EventKit.framework) The Event Kit UI framework was introduced in iOS 4 and is
provided to allow the calendar and reminder events to be accessed and edited from within an
application.
The Social Framework allows Twitter, Facebook and SinaWeibo integration to be added to
applications. The framework operates in conjunction the Accounts Framework to gain access to
the user‟s social network account information.
The role of the Media layer is to provide iOS with audio, video, animation and graphics
capabilities. As with the other layers comprising the iOS stack, the Media layer comprises a
number of frameworks which may be utilized when developing iPhone apps. In this section we
will look at each one in turn.
The Assets Library provides a mechanism for locating and retrieving video and photo files
located on the iPhone device. In addition to accessing existing images and videos, this framework
also allows new photos and videos to be saved to the standard device photo album.
The iOS Core Graphics Framework (otherwise known as the Quartz 2D API) provides a
lightweight two-dimensional rendering engine. Features of this framework include PDF document
creation and presentation, vector-based drawing, transparent layers, path-based drawing, anti-
aliased rendering, color manipulation and management, image rendering and gradients. Those
familiar with the Quartz 2D API running on MacOS X will be pleased to learn that the
implementation of this API is the same on iOS.
A new framework introduced with iOS 5 providing a set of video and image filtering and
manipulation capabilities for application developers.
The purpose of the Quartz Core framework is to provide animation capabilities on the iPhone. It
provides the foundation for the majority of the visual effects and animation used by the UIKit
framework and provides an Objective-C based programming interface for creation of specialized
animation within iPhone apps.
For many years the industry standard for high performance 2D and 3D graphics drawing has been
OpenGL. Originally developed by the now defunct Silicon Graphics, Inc (SGI) during the 1990s
in the form of GL, the open version of this technology (OpenGL) is now under the care of a non-
profit consortium comprising a number of major companies including Apple, Inc., Intel, Motorola
and ARM Holdings.
The GLKit framework is an Objective-C based API designed to ease the task of creating OpenGL
ES based applications.
An Objective-C based framework designed to allow the playback, recording and management of
audio content.
The frameworks that comprise Core Audio for iOS define supported audio types, playback and
recording of audio files and streams and also provide access to the device‟s built-in audio
processing units.
OpenAL is a cross platform technology used to provide high-quality, 3D audio effects (also
referred to as positional audio). Positional audio may be used in a variety of applications though is
typically used to provide sound effects in games.
The iOS Media Player framework is able to play video in .mov, .mp4, .m4v, and .3gp formats at a
variety of compression standards, resolutions and frame rates.
Introduced in iOS 4, the Core MIDI framework provides an API for applications to interact with
MIDI compliant devices such as synthesizers and keyboards via the iPhone‟s dock connector.
The iOS Core Services layer provides much of the foundation on which the previously referenced
layers are built and consists of the following frameworks.
The CFNetwork framework provides a C-based interface to the TCP/IP networking protocol stack
and low level access to BSD sockets. This enables application code to be written that works with
HTTP, FTP and Domain Name servers and to establish secure and encrypted connections using
Secure Sockets Layer (SSL) or Transport Layer Security (TLS).
This framework is provided to ease the creation of data modeling and storage in Model-View
Controller (MVC) based applications. Use of the Core Data framework significantly reduces the
amount of code that needs to be written to perform common tasks when working with structured
data within an application.
The Core Foundation framework is a C-based Framework which provides basic functionality such
as data types, string manipulation, raw block data management, URL manipulation, threads and
run loops, date and times, basic XML manipulation and port and socket communication.
Additional XML capabilities beyond those included with this framework are provided via the
libXML2 library. Though this is a C-based interface, most of the capabilities of the Core
Foundation framework are also available with Objective-C wrappers via the Foundation
Framework.
The Core Media framework is the lower level foundation upon which the AV Foundation layer is
built. Whilst most audio and video tasks can, and indeed should, be performed using the higher
level AV Foundation framework, access is also provided for situations where lower level control
is required by the iOS application developer.
The iOS Core Telephony framework is provided to allow applications to interrogate the device
for information about the current cell phone service provider and to receive notification of
telephony related events.
An API designed to provide applications with access to the calendar, reminders and alarms on the
device.
The Foundation framework is the standard Objective-C framework that will be familiar to those
who have programmed in Objective-C on other platforms (most likely Mac OS X). Essentially,
this consists of Objective-C wrappers around much of the C-based Core Foundation Framework.
The iOS Mobile Core Services framework provides the foundation for Apple‟s Uniform Type
Identifiers (UTI) mechanism, a system for specifying and identifying data types.
A vast range of predefined identifiers have been defined by Apple including such diverse data
types as text, RTF, HTML, JavaScript, PowerPoint .ppt files, PhotoShop images and MP3 files.
The purpose of the Store Kit framework is to facilitate commerce transactions between your
application and the Apple App Store. Prior to version 3.0 of iOS, it was only possible to charge a
customer for an app at the point that they purchased it from the App Store. iOS 3.0 introduced the
concept of the “in app purchase” whereby the user can be given the option to make additional
payments from within the application.
SQLite library
Allows for a lightweight, SQL based database to be created and manipulated from within your
iPhone application.
The System Configuration framework allows applications to access the network configuration
settings of the device to establish information about the “reachability” of the device (for example
whether Wi-Fi or cell connectivity is active and whether and how traffic can be routed to a
server).
The Quick Look framework provides a useful mechanism for displaying previews of the contents
of file types loaded onto the device (typically via an internet or network connection) for which the
application does not already provide support. File format types supported by this framework
include iWork, Microsoft Office document, Rich Text Format, Adobe PDF, Image files,
public.text files and comma separated (CSV).
The Core OS Layer occupies the bottom position of the iOS stack and, as such, sits directly on top
of the device hardware. The layer provides a variety of services including low level networking,
access to external accessories and the usual fundamental operating system services such as
memory management, file system handling and threads.
The Accelerate Framework provides a hardware optimized C-based API for performing complex
and large number math, vector, digital signal processing (DSP) and image processing tasks and
calculations.
Provides the ability to interrogate and communicate with external accessories connected
physically to the iPhone via the 30-pin dock connector or wirelessly via Bluetooth.
The iOS Security framework provides all the security interfaces you would expect to find on a
device that can connect to external networks including certificates, public and private keys, trust
policies, keychains, encryption, digests and Hash-based Message Authentication Code (HMAC).
System (LibSystem)
As we have previously mentioned, iOS is built upon a UNIX-like foundation. The System
component of the Core OS Layer provides much the same functionality as any other UNIX like
operating system. This layer includes the operating system kernel (based on the Mach kernel
developed by Carnegie Mellon University) and device drivers.
The kernel is the foundation on which the entire iOS platform is built and provides the low-level
interface to the underlying hardware. Amongst other things, the kernel is responsible for memory
allocation, process lifecycle management, input/output, inter-process communication, thread
management, low level networking, file system access and thread management.
Mobile devices are becoming less about the hardware and more about the operating system (OS)
running atop of it. Here are four of the most important aspects of a mobile operating system:
1. Speed:
Menus and buttons are about as vital to a mobile experience as much as what the user can do with
them. Impossible is it, to download apps and access the very things that a device is supposed to allow us
to do if the settings and options to do are as complicated as figuring out quantum physics. It’s the
difference between ‘Open App’ and ‘Begin Using Software Application’. It’s also the difference between
button shapes and if they’re easily noticeable and understandable.
When it comes to our gadgets, there are few things we enjoy more than a breadth of options. Given
the option to change everything from colour schemes to simple concepts like being able to change the
background image on the device or to decide how the device greets us on switching it on, usually, the
more options the better.
The developer of the operating system want a completely different design to that of the user so while
simplistic use may be fine for some, allowing them to add nuts, bolts, screws and brackets to the
operating system bracket (besides apps) could be a great thing.
3. Apps
Smartphones and tablets made such a big splash when they were first introduced to the market in
part because of how wondrous and fantastical were the devices’ touchscreens, the other reason for the
success, is likely down to apps.
Eschewing having to load up the device’s built-in web browser to fire up a website and access it
that way, apps make that far easier, often providing even more features to their browser
counterparts.
In fact, apps are so advanced that you can even download a brand-new browser to access the
Internet on. The only problem is that not every app is available on every OS.
As it stands, Apple’s iOS has far more apps listen on its store and some even have iOS exclusivity
so if you want to get your hands on plenty of applications application, that’s where you should
4. Multi-Tasking
The hardware of a device covers how well and how fast each app or process on the device runs.
It’s responsible for how many crashes an app will log in a use and what keeps them running as smoothly
as possible and, with your hardware up to the challenge of running all of these apps as they should, why
not take advantage and ask for more of it?
Multi-tasking is mostly a new feature in terms of operation systems, with Apple’s updated iOS
allowing for multiple apps at one time and with Android’s latest Jellybean update also letting
users multi-task too.
With devices more and more being used as extensions of offices and workspaces, it makes sense
for them to allow us to run as many things as we’d want from our laptops and with devices that do
that, it’s a wonder why we’d find much use from computers at all.
The iOS SDK (Software Development Kit) (formerly iPhone SDK) is a software development
kit developed by Apple Inc. The kit allows for the development of mobile apps on Apple's iOS operating
system.
While originally developing iPhone prior to its unveiling in 2007, Apple's then-CEO Steve
Jobs did not intend to let third-party developers build native apps for iOS, instead directing them
to make web applications for the Safari web browser.
However, backlash from developers prompted the company to reconsider, with Jobs announcing
in October 2007 that Apple would have a software development kit available for developers by
February 2008. The SDK was released on March 6, 2008.
The SDK is a free download for users of Mac personal computers. It is not available for Microsoft
Windows PCs. The SDK contains sets giving developers access to various functions and services
of iOS devices, such as hardware and software attributes.
It also contains an iPhone simulator to mimic the look and feel of the device on the computer
while developing. New versions of the SDK accompany new versions of iOS. In order to test
applications, get technical support, and distribute apps through App Store, developers are required
to subscribe to the Apple Developer Program.
The Android mobile operating system is Google's open and free software stack that includes an
operating system, middleware and also key applications for use on mobile devices, including
smartphones.
Updates for the open source Android mobile operating system have been developed under "dessert-
inspired" version names (Cupcake, Donut, Eclair, Gingerbread, Honeycomb, Ice Cream Sandwich) with
each new version arriving in alphabetical order with new enhancements and improvements.
Bada is a proprietary Samsung mobile OS that was first launched in 2010. The Samsung Wave
was the first smartphone to use this mobile OS. Bada provides mobile features such as multipoint-touch,
3D graphics and of course, application downloads and installation.
The BlackBerry OS is a proprietary mobile operating system developed by Research In Motion for
use on the company’s popular BlackBerry handheld devices.
The BlackBerry platform is popular with corporate users as it offers synchronization with Microsoft
Exchange, Lotus Domino, Novell GroupWise email and other business software, when used with the
BlackBerry Enterprise Server.
Apple's iPhone OS was originally developed for use on its iPhone devices. Now, the mobile
operating system is referred to as iOS and is supported on a number of Apple devices including the
iPhone, iPad, iPad 2 and iPod Touch.
The iOS mobile operating system is available only on Apple's own manufactured devices as the
company does not license the OS for third-party hardware. Apple iOS is derived from Apple's Mac OS X
operating system.
A joint open source mobile operating system which is the result of merging two products based on
open source technologies: Maemo (Nokia) and Moblin (Intel). MeeGo is a mobile OS designed to work
on a number of devices including smartphones, netbooks, tablets, in-vehicle information systems and
various devices using Intel Atom and ARMv7 architectures.
The Palm OS is a proprietary mobile operating system (PDA operating system) that was originally
released in 1996 on the Pilot 1000 handheld.
Newer versions of the Palm OS have added support for expansion ports, new processors, external
memory cards, improved security and support for ARM processors and smartphones.
Palm OS 5 was extended to provide support for a broad range of screen resolutions, wireless connections
and enhanced multimedia capabilities and is called Garnet OS.
7. Symbian OS (Nokia)
Symbian is a mobile operating system (OS) targeted at mobile phones that offers a high-level of
integration with communication and personal information management (PIM) functionality. Symbian OS
combines middleware with wireless communications through an integrated mailbox and the integration
of Java and PIM functionality (agenda and contacts).
Nokia has made the Symbian platform available under an alternative, open and direct model, to
work with some OEMs and the small community of platform development collaborators. Nokia does not
maintain Symbian as an open source development project.
8. webOS (Palm/HP)
WebOS is a mobile operating system that runs on the Linux kernel. WebOS was initially
developed by Palm as the successor to its Palm OS mobile operating system. It is a proprietary Mobile
OS which was eventually acquired by HP and now referred to as webOS (lower-case w) in HP literature.
HP uses webOS in a number of devices including several smartphones and HP TouchPads. HP has
pushed its webOS into the enterprise mobile market by focusing on improving security features and
management with the release of webOS 3.x. HP has also announced plans for a version of webOS to run
within the Microsoft Windows operating system and to be installed on all HP desktop and notebook
computers in 2012.
Windows Mobile is Microsoft's mobile operating system used in smartphones and mobile devices –
with or without touchscreens. The Mobile OS is based on the Windows CE 5.2 kernel.
13) Compare the features of iOS and Android. (Nov/Dec-2019 & Nov/Dec-2023)
Comparing iOS with Android OS involves examining various aspects such as user experience,
design philosophy, customization, ecosystem, security, and availability across devices. Here's a
comparison:
iOS: Known for its simplicity, consistency, and intuitive design. Apple emphasizes a
controlled and uniform user experience across all iOS devices.
Android: Offers more flexibility and customization options. Different manufacturers
often implement their own user interfaces (UI), leading to a more diverse user experience
across devices.
Customization:
iOS: Limited customization options compared to Android. Users have control over
wallpapers, app arrangement, and some widget placement, but customization beyond that
is restricted.
Android: Highly customizable. Users can change themes, install custom launchers,
widgets, and even modify system-level settings with greater freedom.
Ecosystem:
iOS: Tightly integrated with Apple's ecosystem, including services like iCloud, iMessage,
FaceTime, and seamless integration with other Apple devices like Macs, iPads, and Apple
Watch.
Android: Offers a more open ecosystem with integration across various Google services
such as Gmail, Google Drive, and Google Photos. It also supports integration with other
platforms and devices.
Security:
14) Describe four virtualization-like execution environments, and explain how they differ from
"true" virtualization. (April/May-2024)
Description: Containers are lightweight execution environments that package applications and
their dependencies together.
Difference from True Virtualization: Unlike true virtualization (where each virtual machine
runs its own full OS), containers share the host OS kernel and do not require a hypervisor.
Difference from True Virtualization: Emulation emulates hardware at a low level, which
typically incurs higher performance overhead compared to true virtualization. In contrast, true
virtualization involves direct interaction with physical hardware via a hypervisor, often offering
more efficient execution.
15) Why are VMMs unable to implement trap-and-emulate-based virtualization on some CPUs?
Lacking the ability to trap and emulate, what method can a VMM use to implement virtualization?
(April/May-2024)
Lack of Hardware Support for Privileged Instructions: Some CPUs don't have the ability to
trap certain privileged instructions (such as those that modify memory management, interrupt
handling, or hardware control registers) that are necessary for virtualization.
Complexity of Emulation: Even if trapping works for certain privileged instructions, the process
of emulating the entire instruction set and managing the state changes during these traps can be
computationally expensive.
Non-Virtualizable Hardware: Some CPU architectures (e.g., older x86 processors before Intel
VT-x and AMD-V were introduced) weren't designed with virtualization in mind.
When trap-and-emulate is not feasible or efficient, VMMs can use binary translation (BT) as an
alternative method to implement virtualization. Here's how it works:
Dynamic Code Translation: The VMM translates guest instructions that would normally cause
traps into equivalent instructions that can be safely executed on the host hardware.
Instruction Replacement: Instead of trapping the instruction and emulating it, the VMM
replaces it with instructions that achieve the same outcome without causing conflicts with the
hypervisor.
Efficiency: Binary translation allows for more efficient execution in cases where trap-and-
emulate would incur high overhead, although it can still introduce performance costs, especially if
the translation process is frequent or the code is complex.
Traditional hypervisors are software solutions that enable virtualization by creating and
managing virtual machines (VMs) on a host system. There are three main types of hypervisors, each with
its own method of interacting with the host system and virtualizing hardware. These types are:
Description: A Type 1 hypervisor runs directly on the physical hardware of the host system,
without the need for an underlying operating system. It is the "bare-metal" hypervisor because it
interacts directly with the machine’s hardware, managing VMs that operate in isolation from one
another.
Key Characteristics:
No Host OS: The hypervisor is installed directly on the physical machine and is
responsible for managing the hardware, including CPU, memory, storage, and I/O devices.
Greater Security: As there is no host OS, the attack surface is smaller, potentially
offering better security. VMs are more isolated from the host system.
Examples:
o VMware ESXi
o Microsoft Hyper-V (in some configurations)
o Xen
o KVM (Kernel-based Virtual Machine, when used with Linux kernel)
Key Characteristics:
Lower Performance: Since it depends on the host OS for access to hardware, a Type 2
hypervisor introduces additional overhead, which may reduce performance compared to
Type 1.
Ease of Use: Type 2 hypervisors are typically easier to install and configure, making them
more suitable for personal use, testing, or development environments.
Examples:
o VMware Workstation
o Oracle Virtual Box
o Parallels Desktop
o QEMU (when used in a hosted configuration)
Description: A Type 3 hypervisor is less common and is typically a hybrid approach that
combines elements of both Type 1 and Type 2 hypervisors. It might run directly on the hardware
like a Type 1 hypervisor but still leverage some components of a host OS for managing certain
tasks or virtual machine management.
Combination of Type 1 and Type 2: A Type 3 hypervisor may run some components directly
on the hardware, but still rely on certain host OS elements for specific functions (like device
drivers or user management). It often involves a modular architecture.
Use in Specialized or Proprietary Systems: Type 3 hypervisors are more specialized and
are often used in proprietary or niche systems where some elements of a host OS are
needed for compatibility or functionality.
Flexibility: Type 3 hypervisors are typically more flexible in terms of system integration
and can potentially combine the strengths of both Type 1 and Type 2 approaches.
Examples:
17) Discuss about the mobile operating system with suitable example. (April/May-2024)
A mobile operating system (OS) is software that manages a mobile device's hardware and
provides the necessary platform for running applications and services on that device. Mobile OSes are
designed to optimize performance, battery life, and connectivity in mobile environments, while also
supporting a wide range of sensors, touch interfaces, and wireless communication options.
Touch Interface Support: Mobile OSes are typically optimized for touchscreens, supporting
multi-touch gestures, swipes, taps, and other touch-based interactions.
Battery Efficiency: Mobile OSes are designed to minimize power consumption, managing
resources like CPU, memory, and network usage to maximize battery life.
App Management: Mobile OSes include app stores or marketplaces for downloading and
updating apps, along with app management features like permissions and multitasking.
Connectivity: They provide robust support for wireless communication technologies, including
Wi-Fi, Bluetooth, cellular networks, NFC, and GPS.
Security: Mobile OSes implement features like encryption, app sandboxing, and biometric
authentication to ensure user data and privacy are protected.
Here are some of the most widely used mobile operating systems:
Developer: Google
Market Share: Android is the most widely used mobile OS globally, with a market share that
exceeds 70%.
Key Features:
o Open-Source: Android is based on the Linux kernel and is open-source, meaning that
manufacturers and developers can modify and customize the OS for various devices.
o Google Play Store: The primary app marketplace, which provides a wide variety of apps
for users.
o Customizability: Android allows deep customization, such as changing the look and feel
of the OS, using third-party launchers, and modifying system settings.
o Multitasking: Android supports running multiple apps simultaneously with advanced
task-switching features.
Examples of Devices: Samsung Galaxy series, Google Pixel, Xiaomi, OnePlus, and many
more.
II. iOS
Developer: Apple
Market Share: iOS holds a significant share of the global mobile market, especially in high-end
smartphones, and is particularly popular in the United States and Europe.
Key Features:
Developer: Microsoft
Key Features:
o Live Tiles: The Windows Mobile operating system was known for its unique "Live Tiles"
interface, where apps displayed real-time information on the home screen.
o Integration with Microsoft Services: It offered seamless integration with Microsoft
Office, OneDrive, and other Microsoft services, which were particularly attractive to
enterprise users.
o Continuum: In later versions, Windows Phone featured Continuum, allowing the OS to
be used as a desktop OS when connected to a monitor and keyboard.
IV. HarmonyOS
Developer: Huawei
Market Share: HarmonyOS is a relatively new mobile OS primarily designed for Huawei
smartphones and other IoT devices.
Key Features:
Examples of Devices: Huawei Mate 40, Huawei P40, Honor devices, and more.
V. Ubuntu Touch
Key Features:
o Linux-Based: Ubuntu Touch is built on the Ubuntu Linux distribution and offers a
familiar experience to Linux desktop users.
Examples of Devices: PinePhone, Fairphone, and some older Nexus devices (via community
ports).
VI. KaiOS
Market Share: KaiOS is a mobile OS used primarily on feature phones and is growing in
popularity, especially in emerging markets.
Key Features:
18.) Distinguish the various functional behaviors of IOS and Android with suitable examples.
(Nov/Dec-2024)
iOS and Android are the two dominant mobile operating systems, each with distinct
functional behaviors and design philosophies. Below is a comparison of the functional behaviors of iOS
and Android, along with suitable examples:
iOS:
o Consistency and Simplicity: iOS is known for its clean, minimalistic design with a focus
on consistency.
o Example: The Home Screen has a uniform grid of icons and a predictable, consistent
layout across devices.
Android:
iOS:
o App Store Exclusivity: iOS apps are distributed through the Apple App Store. Apple has
a strict app review process to ensure that all apps meet quality and security standards.
Apps also must adhere to Apple's privacy policies.
o Example: To install an app, users must visit the App Store, search for the app, and
download it. Apps like WhatsApp, Instagram, and TikTok are distributed exclusively
through the App Store.
Android:
o Multiple App Stores and Side Loading: Android provides access to multiple app stores,
including the Google Play Store and other third-party stores (e.g., Amazon App store).
Android also allows side-loading of apps, meaning users can install APK files from
external sources.
o Example: Besides the Google Play Store, users can download apps like Amazon App
store or side load apps via APKs, enabling more flexibility in app acquisition.
iOS:
Android:
o Extensive Customization: Android provides a high level of control over the system and
user interface. Users can change default apps, use third-party widgets, customize the home
screen, and modify system settings via developer options.
o Example: Android users can set Google Chrome as the default browser, WhatsApp as
the default messaging app, and install third-party apps like Tasker to automate tasks
based on conditions (e.g., location, time).
iOS:
o Frequent and Unified Updates: iOS offers regular, unified system updates across all
compatible devices. Apple releases major updates (e.g., iOS 14, iOS 15) and security
patches to all supported devices at the same time.
o Example: iOS 15 introduced new features such as Focus mode, improved FaceTime, and
better privacy controls, and was rolled out to all compatible devices in one go.
Android:
o Fragmented Updates: Android updates are more fragmented because multiple device
manufacturers (e.g., Samsung, Google, OnePlus) provide their own software versions.
While Google Pixel devices receive quick updates, other manufacturers often have delays.
o Example: Samsung devices may receive updates later than Google Pixel devices, and
some older models may not receive major Android version upgrades (e.g., Android 12).
iOS:
o Granular Privacy Controls: iOS emphasizes user privacy, offering granular permission
controls. Users are notified when an app accesses sensitive data (e.g., camera, microphone,
location), and they can control access on an app-by-app basis.
o Example: iOS 14 introduced App Tracking Transparency, where apps must ask for user
permission before tracking them across other apps or websites.
Android:
o Flexible Permission Model: Android allows users to manage permissions, but it's
generally less restrictive than iOS. Starting from Android 6.0 (Marshmallow), Android
introduced runtime permissions, giving users control over app-specific permissions.
o Example: In Android, users can go into Settings to control permissions such as location,
camera, and contacts for individual apps. Android 12 enhanced privacy features with
indicators showing when the camera or microphone is in use.
iOS:
Android:
o True Multitasking and Split-Screen: Android supports true multitasking, allowing users
to run two apps simultaneously in split-screen mode or use picture-in-picture (PiP) for
video playback.
o Example: On Android, users can open apps like Google Chrome and YouTube in split-
screen mode, allowing them to browse and watch videos simultaneously.
iOS:
o Siri: Apple's voice assistant, Siri, is deeply integrated into the iOS ecosystem. It can
perform tasks like setting reminders, sending messages, playing music, and controlling
smart home devices.
o Example: Users can activate Siri by saying "Hey Siri" or holding the home button. Siri
can also be used for in-car integration (CarPlay).
Android:
o Google Assistant: Google Assistant is Android's voice assistant, providing more powerful
AI-driven features. It integrates with Google's vast search and cloud services and offers
multi-lingual support.
o Example: Google Assistant is available on most Android devices and can perform tasks
like searching the web, controlling smart devices, setting reminders, and even making
phone calls. It can also be used on Android TV and other devices in the Google
ecosystem.
iOS:
o App Store: iOS apps are available through the Apple App Store, and Apple maintains
tight control over app approval and content. This results in a curated, high-quality app
ecosystem, but it can limit app availability (especially apps that don’t meet Apple’s strict
guidelines).
o Example: Popular apps like Apple Music, Safari, and Pages are pre-installed, and all
third-party apps must pass Apple’s review process before being published.
Android:
o Google Play Store and Other Stores: Android allows multiple app stores and side
loading, resulting in a more diverse ecosystem. While Google Play is the primary store,
19.) Explain the concept of virtual machines with a suitable sketch. Also, bring out its benefits and
features. (Nov/Dec-2024)
Hypervisor: The hypervisor is the layer between the physical hardware and the virtual machines.
It is responsible for allocating physical resources to each VM and ensuring they operate
independently.
o Type 1 Hypervisor (Bare-Metal): Runs directly on the host hardware (e.g., VMware
ESXi, Microsoft Hyper-V).
o Type 2 Hypervisor (Hosted): Runs on top of a host OS (e.g., VMware Workstation,
Oracle Virtual Box).
Guest OS: The operating system that runs inside the virtual machine. Each VM can have a
different guest OS (e.g., Windows, Linux, macOS) on the same host system.
VM: A virtual machine runs its own OS and applications, independently of other VMs, even
though they share the same physical resources.
Resource Isolation:
o Each VM operates independently of the others, even though they share the same physical
hardware. This isolation ensures that one VM’s failure or resource usage does not affect
other VMs.
o Example: Running a Linux VM and a Windows VM on the same machine without
conflicts.
Hardware Utilization:
o VMs allow better utilization of physical hardware by running multiple guest operating
systems simultaneously on a single machine. This maximizes the use of CPU, memory,
and storage resources.
o Example: On a high-performance server, you can run several VMs for different purposes
(web server, database server, etc.) instead of using separate physical machines.
o Virtual machines can be easily backed up, cloned, or restored. VMs can be snapshot at any
point in time, creating a restore point for disaster recovery.
o Example: You can take a snapshot of a critical application VM before performing an
upgrade, allowing you to revert to the previous state if something goes wrong.
Cross-Platform Compatibility:
o VMs allow running different operating systems on the same physical machine. For
instance, you can run Windows on a host machine that uses Linux, or vice versa.
o VMs are ideal for software testing and development because they provide isolated
environments where developers can test applications on different OSes or configurations
without the need for multiple physical machines.
o Example: A developer can test their application on multiple versions of Windows or
different Linux distributions by running separate VMs.
Cost Savings:
Portability:
o VMs are portable because they are encapsulated in virtualized files. VMs can be easily
migrated from one host machine to another, allowing for flexible workload distribution.
o Example: Moving a VM from an old server to a new server is as simple as copying the
VM files and configuring the new host.
o VMs emulate physical hardware for the guest OS, providing virtualized CPU, memory,
storage, network interfaces, etc.
o Example: A VM might be allocated 2GB of RAM, 2 virtual CPUs, and 100GB of virtual
disk space, even if the physical host machine has more resources.
o VMs support snapshots (point-in-time copies) and cloning, which allow for easy recovery,
testing, and deployment.
Resource Allocation:
o Hypervisors allow resource allocation such as CPU cores, memory, and disk space to each
VM, making efficient use of physical hardware.
o Example: The hypervisor can allocate 4 GB of RAM to one VM and 8 GB to another
based on their needs.
Live Migration:
o Many virtualization platforms support live migration, where VMs can be moved between
physical machines without shutting them down. This is useful for load balancing and
maintenance without downtime.
o Example: A VM can be moved from one server to another in a cloud data center without
any interruption to the services it provides.
PART – A
PART – B
2) Outline the operating system aspects of virtualization in the context of operating system
NOV /DEC-2023
PART – A
PART – B
1. Explain various types of virtual machines and their implementations in detail. (Q. No:4)
APRIL / MAY-2024
PART – A
2. What is the major design goal for the android platform? (Q.NO:27)
PART – B
1. Describe four virtualization-like execution environments, and explain how they differ from "true"
virtualization. (Q.NO:14)
4. Discuss about the mobile operating system with suitable example. (Q.NO:17)
NOV /DEC-2024
PART – A
PART – B
1. Distinguish the various functional behaviors of IOS and Android with suitable examples.
(Q.NO:18)
2. Explain the concept of virtual machines with a suitable sketch. Also, bring out its benefits and
features. (Q.NO:19)