OS Merged Notes
OS Merged Notes
INTRODUCTION
Operating System is a program that acts as an interface between a user of a computer and the
computer hardware. Eg. Windows (Microsoft), iOS (Apple), Android (Google), Linux/Ubuntu (open
source)
Goals of Operating System:
Execute user programs and make solving the user problems easier
Make the computer system convenient to use
Use the computer hardware in an efficient manner
1. COMPUTER SYSTEM
A computer system can be divided roughly into four components: the hardware, the
operating system, the application programs, and a user
Hardware: The Central Processing Unit (CPU), the Memory, and the Input/output (I/O) devices
provides the basic computing resources for the system.
Application Programs: Such as word processors, spreadsheets, compilers, and web browsers
define the ways in which these resources are used to solve users’ computing problems.
Operating System: Controls the hardware and coordinates its use among the various application
programs for the various users.
1
Figure : Computer System
The operating system provides the means for proper use of these resources in the operation of
the computer system.
Operating Systems from two viewpoints:
User View
System View
User View
The user’s view of the computer varies according to the interface being used. Many
computer users sit with a laptop or in front of a PC consisting of a monitor, keyboard, and mouse.
Such a system is designed for one user to control its resources. For this, the operating system is
designed mostly for ease of use, performance and security and not to resource utilization.
Many users interact with mobile devices such as smartphones and tablets. These devices
are connected to networks through cellular or other wireless technologies. The user interface for
mobile computers generally features a touch screen, where the user interacts with the system by
pressing and swiping fingers across the screen rather than using a physical keyboard and mouse.
Many mobile devices also allow users to interact through a voice recognition interface, such as
Apple’s Siri.
System View
From the computer’s point of view, the operating system is the program most intimately
involved with the hardware. It is a resource allocator. A computer system has many resources
that may be required to solve a problem: CPU time, memory space, storage space, I/O devices, and
so on. The operating system acts as the manager of these resources. The operating system must
decide how to allocate the resources to specific programs and users so that it can operate the
computer system efficiently and fairly.
2
Components of Operating System
Shell :
Environment that gives a user an interface to access the
operating system’s services.
Launch Applications
User Mode
Kernel :
Keep track of the hardware and computer’s operations.
Kernel Mode
3
2. COMPUTER SYSTEM – ELEMENTS AND ORGANIZATION
A computer system consists of CPU and a number of device controllers connected through
a common bus that provides access between components and shared memory. Each device
controller is in charge of a specific type of device, more than one device may be attached. For
example, one system USB port can connect to a USB hub, to which several devices can be
connected. A device controller maintains some local buffer storage and a set of special purpose
registers. The device controller is responsible for moving the data between the peripheral devices
that it controls and its local buffer storage.
Operating systems have a device driver for each device controller. This device driver
understands the device controller and provides the rest of the operating system with a uniform
interface to the device. The CPU and the device controllers can execute in parallel.
Interrupts
Storage Structure
I/O Structure
Interrupts
Hardware may trigger an interrupt by sending a signal to the CPU. Software may trigger an
interrupt by executing a special operation called a system call. When the CPU is interrupted, it
stops what it is doing and immediately transfers execution to a fixed location. The fixed location
usually contains the starting address where the service routine for the interrupt is located. The
interrupt service routine executes; on completion, the CPU resumes the interrupted computation.
A time line of this operation is shown below
4
The interrupt routine is called indirectly through the table, The table holds the addresses
of the interrupt service routines for the various devices. This array, or interrupt vector, of
addresses is then indexed by a unique device number, given with the interrupt request, to provide
the address of the interrupt service routine for the interrupting device.
The interrupt architecture must also save the address of the interrupted instruction. After
the interrupt is serviced, the saved return address is loaded into the program counter, and the
interrupted computation resumes as though the interrupt had not occurred. The device controller
raises an interrupt by asserting a signal on the interrupt request line, the CPU catches the interrupt
and dispatches it to the interrupt handler, and the handler clears the interrupt by servicing the
device.
Most CPUs have two interrupt request lines. One is the nonmaskable interrupt, which is
reserved for events such as unrecoverable memory errors. The second interrupt line is maskable:
it can be turned off by the CPU before the execution of critical instruction sequences that must not
be interrupted. The maskable interrupt is used by device controllers to request service.
Storage Structure
KB : 1024 Bytes
MB : 1024 2 Bytes
GB : 1024 3 Bytes (1 Million Bytes )
TB : 1024 4 Bytes (1 Billion Bytes )
PB : 1024 5 Bytes
5
The CPU load the instructions from memory. General-purpose computers run most of their
programs from rewritable memory, called main memory (RAM).
The first program to run on computer to power ON is a bootstrap program, which then
loads the operating system. Since RAM is volatile, loses its content when power is turned off or
otherwise lost. So the bootstrap program cannot be stored in RAM. So the computer uses
electrically erasable programmable read-only memory (EEPROM) and other forms of firmware,
storage that is infrequently written to and is nonvolatile. EEPROM can be changed but cannot be
changed frequently. In addition, it is low speed, and so it contains mostly static programs and data
that aren’t frequently used. For example, the iPhone uses EEPROM to store serial numbers and
hardware information about the device.
All forms of memory provide an array of bytes. Each byte has its own address. Interaction
is achieved through a sequence of load or store instructions to specific memory addresses. The
load instruction moves a byte or word from main memory to an internal register within the CPU,
whereas the store instruction moves the content of a register to main memory.
The CPU automatically loads instructions from main memory for execution from the
location stored in the program counter. First fetches an instruction from memory and stores that
instruction in the instruction register. The instruction is then decoded and may cause operands
to be fetched from memory and stored in some internal register. After the instruction on the
operands has been executed, the result may be stored back in memory.
The programs and data must be in main memory permanently. This arrangement is not
possible on most systems for two reasons:
Main memory is usually too small to store all needed programs and data permanently.
Main memory, is volatile, it loses its contents when power is turned off or otherwise lost.
Most computer systems provide secondary storage as an extension of main memory. The
main requirement for secondary storage is that it be able to hold large quantities of data
permanently. The most common secondary-storage devices are hard-disk drives (HDDs) and
nonvolatile memory (NVM) devices, which provide storage for both programs and data. Most
programs are stored in secondary storage until they are loaded into memory.
Secondary storage is also much slower than main memory. Other possible components
include cache memory, CD-ROM, magnetic tapes, and so on. Those that are slow enough and large
enough that they are used only for special purposes, to store backup copies of material stored on
other devices, are called tertiary storage.
The wide variety of storage systems can be organized in a hierarchy according to storage
capacity and access time.
Smaller and faster memory closer to the CPU. Various storage systems are either volatile
or nonvolatile. Volatile storage, loses its contents when the power to the device is removed, so
data must be written to nonvolatile storage for safekeeping.
The top four levels of memory are constructed using semiconductor memory, which
consists of semiconductor based electronic circuits. Non Volatile Memory devices, at the fourth
level, are faster than hard disks. The most common form of NVM device is flash memory, which is
popular in mobile devices such as smartphones and tablets. Increasingly, flash memory is being
used for long term storage on laptops, desktops, and servers as well.
6
Volatile storage will be referred to simply as memory. Nonvolatile storage retains its contents
when power is lost. This type of storage can be classified into two distinct types:
Mechanical : Storage systems are HDDs, optical disks, holographic storage, and magnetic
tape.
Electrical : Storage systems are flash memory, FRAM, NRAM, and SSD.
Mechanical storage is generally larger and less expensive per byte than electrical storage.
Conversely, electrical storage is typically costly, smaller, and faster than mechanical storage.
I/O Structure
A large portion of operating system code is dedicated to manage I/O. General purpose
computer system consists of multiple devices, all of which exchange data via a common bus. The
form of interrupt driven I/O is fine for moving small amounts of data, direct memory access
(DMA) is used for bulk data transfer.
7
DMA Data Transfer
Normal Data Transfer
After setting up buffers, pointers, and counters for the I/O device, the device controller
transfers an entire block of data directly to or from the device and main memory, with no
intervention by the CPU. Only one interrupt is generated per block, to tell the device driver that
the operation has completed, rather than the one interrupt per byte generated for low speed
devices. While the device controller is performing these operations, the CPU is available to
accomplish other work.
Some high-end systems use switch rather than bus architecture. On these systems, multiple
components can talk to other components concurrently, rather than competing for cycles on a
shared bus.
8
3. EVOLUTION OF OPERATING SYSTEM
On a single-processor system, there is one main CPU capable of executing the instructions.
Most computer systems use a single processor containing one CPU with a single processing core.
The core is the component that executes instructions and registers for storing data locally. The
one main CPU with its core is capable of executing a general-purpose instruction set, including
instructions from processes.
Multiprocessor Systems
9
They have more processors, each with a single-core CPU. The processors share the
computer bus and sometimes the clock, memory, and peripheral devices. The main advantages
are
Increased throughput
Economy of scale
Increased reliability – graceful degradation or fault tolerance
The Figure illustrates a typical SMP architecture with two processors, each with its own CPU. Each
CPU processor has its own set of registers, and local cache. Main Memory is shared. The benefit is
that many processes can run simultaneously N processes can run if there are N CPUs without
causing performance to deteriorate significantly. However, since the CPUs are separate, one may
be sitting idle while another is overloaded, resulting in inefficiencies. These inefficiencies can be
avoided if the processors share certain data structures. The definition of multiprocessor has
evolved over time and now includes multicore systems, in which multiple computing cores reside
on a single chip. Multicore systems can be more efficient than multiple chips with single cores.
10
In a dual-core design with two cores on the same processor chip. In this design, each core has its
own register set, as well as its own local cache, often known as a level 1, or L1, cache. Notice, too,
that a level 2 (L2) cache is local to the chip but is shared by the two processing cores.
Adding additional CPUs to a multiprocessor system will increase computing power; and
adding too many CPUs, becomes a bottleneck and performance begins to degrade. Instead to
provide each CPU (or group of CPUs) with its own local memory that is accessed via a small, fast
local bus. The CPUs are connected by a shared system interconnect, so that all CPUs share one
physical address space. This approach known as Non-Uniform Memory Access, or NUMA
The advantage is that, when a CPU accesses its local memory, it is fast, and no contention
over the system interconnect. Thus, NUMA systems can scale more effectively as more processors
are added. A drawback is increased latency. For example, CPU0 cannot access the local memory
of CPU3 as quickly as it can access its own local memory, slowing down performance.
Because NUMA systems can scale to accommodate a large number of processors, they are
becoming increasingly popular on servers as well as high-performance computing systems.
11
Clustered Systems
Clustered computers share storage and are closely linked via a local-area network LAN or
a faster interconnect. Clustering is usually used to provide high availability service that is,
service that will continue even if one or more systems in the cluster fail.
A layer of cluster software runs on the cluster nodes. Each node can monitor one or more
of the others (over the network). If the monitored machine fails, the monitoring machine can take
ownership of its storage and restart the applications that were running on the failed machine.
High availability provides increased reliability, which is crucial in many applications. The ability
to continue providing service proportional to the level of surviving hardware is called graceful
degradation. Some systems go beyond graceful degradation and are called fault tolerant,
because they can suffer a failure of any single component and still continue operation. Fault
tolerance requires a mechanism to allow the failure to be detected, diagnosed, and, if possible,
corrected.
In Asymmetric Clustering, one machine is in hot standby mode while the other is running the
applications. The hot standby host machine does nothing but monitor the active server. If that
server fails, the hot standby host becomes the active server.
In symmetric clustering, two or more hosts are running applications and are monitoring each
other. This structure is obviously more efficient, as it uses all of the available hardware.
12
4. OPERATING SYSTEM OPERATIONS
Multiprogramming
Multiprogramming increases CPU utilization, so that the CPU always has one to execute.
In a multiprogrammed system, a program in execution is termed as process.
Max
Operating System
Process 1
Process 2
Process 3
0
The operating system picks and begins to execute one of these processes. Eventually, the
process may have to wait for some task, such as an I/O operation, to complete. In a non-
multiprogrammed System, the CPU would sit idle. In a multiprogrammed system, the operating
system simply switches to, and executes, another process. When that process needs to wait, the
CPU switches to another process, and so on. Eventually, the first process finishes waiting and gets
the CPU back. As long as at least one process needs to execute, the CPU is never idle.
Multitasking
CPU switches jobs so frequently that users can interact with each job while it is running,
creating interactive computing
Response time should be < 1 second
Each user has at least one program executing in memory
If several jobs ready to run at the same time [ CPU scheduling]
If processes don’t fit in memory, swapping moves them in and out to run
Virtual memory allows execution of processes not completely in memory
Operating system running a user application such as handling a text editor. The transition
from user mode to kernel mode occurs when the application requests the help of operating system
or an interrupt or a system call occurs. The mode bit is set to 1 in the user mode. It is changed from
1 to 0 when switching from user mode to kernel mode.
Kernel Mode
The system starts in kernel mode when it boots and after the operating system is loaded,
it executes applications in user mode. There are some privileged instructions that can only be
executed in kernel mode. These are interrupt instructions, input output management etc. If the
privileged instructions are executed in user mode, it is illegal and a trap is generated. The mode
bit is set to 0 in the kernel mode. It is changed from 0 to 1 when switching from kernel mode to
user mode.
The concept of modes of operation in operating system can be extended beyond the dual
mode. Known as the multimode system. In those cases more than 1 bit is used by the CPU to set
and handle the mode.
Timer
A user program cannot get stuck in an infinite loop or to fail to call system services and
never return control to the operating system. A timer is used to accomplish this goal. A timer can
be set to interrupt the computer after a specified period. A variable timer is generally
implemented by a fixed-rate clock and a counter. The operating system sets the counter. Every
time the clock ticks, the counter is decremented. When the counter reaches 0, an interrupt occurs.
Furthermore, the operating system, in one form or another, provides certain services to the
computer system.
User Interface
Program Execution
I/O Operations
File System Manipulation
Communications
Error Detection
Resource Allocation
Accounting
Protection and Security
14
User Interface
Almost all operating systems have a user interface (UI). Two types of User Interface are
Command Based Interface and Graphical User Interface
15
Program Execution:
The OS is in charge of running all types of programs, whether they are user or system
programs. The operating system makes use of a variety of resources to ensure that all types of
functions perform smoothly.
Input/Output Operations:
The operating system is in charge of handling various types of inputs, such as those from
the keyboard, mouse, and desktop. Regarding all types of inputs and outputs, the operating system
handles all interfaces in the most appropriate manner.
For instance, the nature of all types of peripheral devices, such as mice or keyboards, differs, and
the operating system is responsible for transferring data between them.
File System Manipulation:
The OS is in charge of deciding where data or files should be stored, such as on a floppy
disk, hard disk, or pen drive. The operating system determines how data should be stored and
handled.
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 network. Communications may be implemented via shared memory, in which two
or more processes read and write to a shared section of memory, or message passing, in which
packets of information in predefined formats are moved between processes by the operating
system.
16
Error Detection:
The operating system needs to be detecting and correcting errors constantly. 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 or an attempt to access an illegal
memory location). 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:
The operating system guarantees that all available resources are properly utilized by
determining which resource should be used by whom and for how long. The operating system
makes all of the choices.
Accounting:
The operating system keeps track of all the functions that are active in the computer system
at any one time. The operating system keeps track of all the facts, including the types of mistakes
that happened.
The operating system is in charge of making the most secure use of all the data and
resources available on the machine. Any attempt by an external resource to obstruct data or
information must be foiled by the operating system.
There are different types of user interfaces each of which provides a different functionality:
Command based interface requires a user to enter the commands to perform different
tasks like creating, opening, editing or deleting a file, etc. The user has to remember the names of
all such programs or specific commands which the operating system supports. The primary input
17
device used by the user for command based interface is the keyboard. Command-based interface
is often less interactive and usually allows a user to run a single program at a time. Examples of
operating systems with command-based interfaces include MS-DOS and Unix.
Users run programs or give instructions to the computer in the form of icons, menus and
other visual options. Icons usually represent files and programs stored on the computer and
windows represent running programs that the user has launched through the operating system.
The input devices used to interact with the GUI commonly include the mouse and the keyboard.
Examples of operating systems with GUI interfaces include Microsoft Windows, Ubuntu, Fedora
and Macintosh, among others.
Modern computers have been designed to address the needs of all types of users including
people with special needs and people who want to interact with computers or smartphones while
18
doing some other task. For users who cannot use input devices like the mouse, keyboard, and
touchscreens, modern operating systems provide other means of human-computer interaction.
Users today can use voice-based commands to make a computer work in the desired way. Some
operating systems which provide voice-based control to users include iOS (Siri), Android (Google
Now or “OK Google”), Microsoft Windows 10 (Cortana), and so on.
Some smartphones based on Android and iOS as well as laptops let users interact with the
devices using gestures like waving, tilting, eye motion, and shaking. This technology is evolving
faster and it has promising potential for application in gaming, medicine, and other areas.
7. SYSTEM CALLS
A system call is a mechanism that provides the interface between a process and the
operating system. It is a programmatic method in which a computer program requests a service
from the kernel of the OS. System call offers the services of the operating system to the user
programs via API (Application Programming Interface). System calls are the only entry points for
the kernel system.
Working of System Call
19
Step 1) The processes executed in the user mode till the time a system call interrupts it.
Step 2) After that, the system call is executed in the kernel-mode on a priority basis.
Step 3) Once system call execution is over, control returns to the user mode.,
Step 4) The execution of user processes resumed in Kernel mode.
A second approach is for the program to ask the user for the names.
In an interactive system, this approach will require a sequence of system calls, first to write
a prompting message on the screen and then to read from the keyboard the characters that define
the two files. On mouse-based and icon-based systems, a menu of file names is usually displayed
in a window. The user can then use the mouse to select the source name, and a window can be
opened for the destination name to be specified. This sequence requires many I/O system calls.
Once the two file names have been obtained, the program must open the input file and create and
open the output file. Each of these operations requires another system call. Possible error
conditions for each system call must be handled. For example, when the program tries to open the
input file, it may find that there is no file of that name or that the file is protected against access.
In these cases, the program should output an error message (another sequence of system
calls) and then terminate abnormally (another system call). If the input file exists, then we must
create a new output file. We may find that there is already an output file with the same name. This
situation may cause the program to abort (a system call), or we may delete the existing file
(another system call) and create a new one (yet another system call). Another option, in an
interactive system, is to ask the user (via a sequence of system calls to output the prompting
message and to read the response from the terminal) whether to replace the existing file or to
abort the program.
20
When both files are set up, we enter a loop that reads from the input file (a system call) and
writes to the output file (another system call). Each read and write must return status information
regarding various possible error conditions. On input, the program may find that the end of the
file has been reached or that there was a hardware failure in the read (such as a parity error). The
write operation may encounter various errors, depending on the output device (for example, no
more available disk space).
Finally, after the entire file is copied, the program may close both files (two system calls),
write a message to the console or window (more system calls), and finally terminate normally (the
final system call).
21
Rules for passing Parameters for System Call
Here are general common rules for passing parameters to the System Call:
Parameters should be pushed on or popped off the stack by the operating system.
Parameters can be passed in registers. For five or fewer parameters, registers are used.
More than five parameters, the block method is used. 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
Process Control
File Management
Device Management
Information Maintenance
Communications
Process Control
This system calls perform the task of process creation, process termination, etc.
Functions:
End and Abort
Load and Execute
Create Process and Terminate Process
Wait and Signal Event
Allocate and free memory
File Management
File management system calls handle file manipulation jobs like creating a file, reading, and
writing, etc.
Functions:
Create a file
Delete file
Open and close file
Read, write, and reposition
Get and set file attributes
Device Management
Device management does the job of device manipulation like reading from device buffers, writing
into device buffers, etc.
22
Functions:
Request and release device
Logically attach/ detach devices
Get and Set device attributes
Information Maintenance
It handles information and its transfer between the OS and the user program.
Functions:
Get or set time and date
Get process and device attributes
Communication:
These types of system calls are specially used for interprocess communications.
Functions:
Create, delete communications connections
Send, receive message
Help OS to transfer status information
Attach or detach remote devices
wait()
A process needs to wait for another process to complete its execution. This occurs when a
parent process creates a child process, and the execution of the parent process remains suspended
until its child process executes. The suspension of the parent process automatically occurs with a
wait() system call. When the child process ends execution, the control moves back to the parent
process.
fork()
Processes use this system call to create processes that are a copy of themselves. With the
help of this system Call parent process creates a child process, and the execution of the parent
process will be suspended till the child process executes.
exec()
This system call runs when an executable file in the context of an already running process
that replaces the older executable file. However, the original process identifier remains as a new
process is not built, but stack, data, head, data, etc. are replaced by the new process.
kill():
The kill() system call is used by OS to send a termination signal to a process that urges the
process to exit. However, a kill system call does not necessarily mean killing the process and can
have various meanings.
exit():
The exit() system call is used to terminate program execution. Specially in the multi-
threaded environment, this call defines that the thread execution is complete. The OS reclaims
resources that were used by the process after the use of exit() system call.
23
8. SYSTEM PROGRAMS
System programs provide a convenient environment for program development and execution. It
can be divided into:
File manipulation
Status information
File modification
Programming language support
Program loading and execution
Communications
Application programs
File management.
These programs create, delete, copy, rename, print, list, and generally access and
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. Typically, these programs format and
print the output to the terminal or other output devices or files or display it in a window of the
GUI. Some systems also support a 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. There may also be special commands to search contents of files or
perform transformations of the text.
Programming-language support:
Compilers, assemblers, debuggers, and interpreters for common programming languages
(such as C, C++, Java, and Python) are often provided with the operating system or available
as a separate download.
Communications:
These programs provide the mechanism for creating virtual connections among processes,
users, and computer systems. They allow users to send messages to one another’s screens, to
24
browse web pages, to send e-mail messages, to log in remotely, or to transfer files from one
machine to another.
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. Constantly running system-program processes
are known as services, subsystems, or daemons
DESIGN GOALS
The first problem in designing a system is to define goals and specifications. At the highest
level, the design of the system will be affected by the choice of hardware and the type of system:
traditional desktop/laptop, mobile, distributed, or real time. Beyond this highest design level, the
requirements may be much harder to specify.
The requirements can, however, be divided into two basic groups:
System goals
Easy to design, implement, and maintain , Flexible, reliable, error-free, and efficient
25
10. OPERATING SYSTEM STRUCTURE
Operating system can be implemented with the help of various structures. The structure of the
OS depends mainly on how the various common components of the operating system are
interconnected and melded into the kernel.
Depending on this we have following structures of the operating system:
Monolithic Structure
Layered Approach
Microkernels
Modules
Hybrid Systems
macOS and iOS
Android
Monolithic structure:
Such operating systems do not have well defined structure and are small, simple and limited
systems. The interfaces and levels of functionality are not well separated. MS-DOS is an example
of such operating system. In MS-DOS application programs are able to access the basic I/O
routines. These types of operating system cause the entire system to crash if one of the user
programs fails. Diagram of the structure of MS-DOS is shown below.
An example of such limited structuring is the original UNIX operating system, which
consists of two separable parts: the kernel and the system programs. The kernel is further
separated into a series of interfaces and device drivers, which have been added and expanded
over the years as UNIX has evolved. Everything below the system-call interface and above the
physical hardware is the kernel. The kernel provides the file system, CPU scheduling, memory
management, and other operating system functions through system calls. Taken in sum, that is an
enormous amount of functionality to be combined into one single address space. UNIX Structure
is shown below
26
The Linux operating system is based on UNIX shown in the figure below. Applications typically
use the glibc standard C library when communicating with the system call interface to the kernel.
The Linux kernel is monolithic in that it runs entirely in kernel mode in a single address space, it
does have a modular design that allows the kernel to be modified during run time.
Layered Approach
An OS can be broken into pieces and retain much more control on system. In this
structure the OS is broken into number of layers (levels). The bottom layer (layer 0) is the
hardware and the topmost layer (layer N) is the user interface. These layers are so designed that
each layer uses the functions of the lower level layers only. This simplifies the debugging process
as if lower level layers are debugged and an error occurs during debugging then the error must
be on that layer only as the lower level layers have already been debugged. The main
27
disadvantage of this structure is that at each layer, the data needs to be modified and passed on
which adds overhead to the system. Moreover careful planning of the layers is necessary as a
layer can use only lower level layers. UNIX is an example of this structure.
Micro-kernel:
This structure designs the operating system by removing all non-essential components
from the kernel and implementing them as system and user programs. This result in a smaller
kernel called the micro-kernel.
Advantages of this structure are that all new services need to be added to user space and
does not require the kernel to be modified. Thus it is more secure and reliable as if a service fails
then rest of the operating system remains untouched. Mac OS is an example of this type of OS.
28
Modular structure or approach:
The best approach for an OS. It involves designing of a modular kernel. The kernel has
only set of core components and other services are added as dynamically loadable modules to
the kernel either during run time or boot time. It resembles layered structure due to the fact
that each kernel has defined and protected interfaces but it is more flexible than the layered
structure as a module can call any other module. For example Solaris OS is organized as shown
in the figure.
Hybrid Systems
The Apple macOS operating system and the two mobile operating systems—iOS and Android.
Apple’s macOS operating system is designed to run primarily on desktop and laptop
computer systems, whereas iOS is a mobile operating system designed for the iPhone smartphone
and iPad tablet computer. Highlights of the various layers include the following:
User experience layer. This layer defines the software interface that allows users to
interact with the computing devices. macOS uses the Aqua user interface, which is
designed for a mouse or trackpad, whereas iOS uses the Springboard user interface, which
is designed for touch devices.
Application frameworks layer. This layer includes the Cocoa and Cocoa Touch
frameworks, which provide an API for the Objective-C and Swift programming languages.
The primary difference between Cocoa and Cocoa Touch is that the former is used for
developing macOS applications, and the latter by iOS to provide support for hardware
features unique to mobile devices, such as touch screens.
29
Core frameworks. This layer defines frameworks that support graphics and media
including, Quicktime and OpenGL.
Kernel environment. This environment, also known as Darwin, includes the Mach
microkernel and the BSD UNIX kernel.
Applications can be designed to take advantage of user-experience features or to bypass them and
interact directly with either the application framework or the core framework. Additionally, an
application can forego frameworks entirely and communicate directly with the kernel
environment.
Some significant distinctions between macOS and iOS include the following:
Because macOS is intended for desktop and laptop computer systems, it is compiled to run on
Intel architectures. iOS is designed for mobile devices and thus is compiled for ARM-based
architectures. Similarly, the iOS kernel has been modified somewhat to address specific
features and needs of mobile systems, such as power management and aggressive memory
management. Additionally, iOS has more stringent security settings than macOS.
The iOS operating system is generally much more restricted to developers than macOS and
may even be closed to developers. For example, iOS restricts access to POSIX and BSD APIs on
iOS, whereas they are openly available to developers on macOS.
Darwin OS
Darwin OS is a layered system that consists primarily of the Mach microkernel and the
BSD UNIX kernel. Darwin’s structure is shown below
Darwin provides two system-call interfaces: Mach system calls (known as traps) and BSD
system calls (which provide POSIX functionality). The interface to these system calls is a rich set
30
of libraries that includes not only the standard C library but also libraries that provide networking,
security, and programming language support.
Beneath the system-call interface, Mach provides fundamental operating system services,
including memory management, CPU scheduling, and inter process communication (IPC) facilities
such as message passing and remote procedure calls (RPCs). Much of the functionality provided
by Mach is available through kernel abstractions, which include tasks (a Mach process), threads,
memory objects, and ports (used for IPC). As an example, an application may create a new process
using the BSD POSIX fork() system call. Mach will, in turn, use a task kernel abstraction to
represent the process in the kernel.
In addition to Mach and BSD, the kernel environment provides an I/O kit for development
of device drivers and dynamically loadable modules (which macOS refers to as kernel
extensions, or kexts).
Android
Developed for Android smartphones and tablet computers. Whereas iOS is designed to run
on Apple mobile devices and is close-sourced, Android runs on a variety of mobile platforms and
is open sourced, partly explaining its rapid rise in popularity. Android is similar to iOS in that it is
a layered stack of software that provides a rich set of frameworks supporting graphics, audio, and
hardware features. These features, in turn, provide a platform for developing mobile applications
that run on a multitude of Android-enabled devices.
Software designers for Android devices develop applications in the Java language, but they
do not generally use the standard Java API. Google has designed a separate Android API for Java
development. Java applications are compiled into a form that can execute on the Android RunTime
ART, a virtual machine designed for Android and optimized for mobile devices with limited
31
memory and CPU processing capabilities. Java programs are first compiled to a Java bytecode
.class file and then translated into an executable .dex file. Whereas many Java virtual machines
perform just-in-time (JIT) compilation to improve application efficiency, ART performs ahead-of-
time (AOT) compilation
The structure of Android appears is shown below
.dex files are compiled into native machine code when they are installed on a device, from
which they can execute on the ART. AOT compilation allows more efficient application execution
as well as reduced power consumption, features that are crucial for mobile systems.
Programs written using Java native interface JNI are generally not portable from one
hardware device to another. The set of native libraries available for Android applications includes
frameworks for developing web browsers (webkit), database support (SQLite), and network
support, such as secure sockets (SSLs). Android can run on an almost unlimited number of
hardware devices, Google has chosen to abstract the physical hardware through the hardware
abstraction layer, or HAL. By abstracting all hardware, such as the camera, GPS chip, and other
sensors, the HAL provides applications with a consistent view independent of specific hardware.
This feature, of course, allows developers to write programs that are portable across different
hardware platforms.
The standard C library used by Linux systems is the GNU C library (glibc). Google instead
developed the Bionic standard C library for Android. Not only does Bionic have a smaller memory
footprint than glibc, but it also has been designed for the slower CPUs that characterize mobile
devices. At the bottom of Android’s software stack is the Linux kernel. Google has modified the
Linux kernel used in Android in a variety of areas to support the special needs of mobile systems,
such as power management. It has also made changes in memory management and allocation.
32
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
UNIT-IV
Mass Storage system – Overview of Mass Storage Structure, Disk Structure, Disk Scheduling and
Management, swap space 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, Efficiency and Performance, Recovery; I/O Systems – I/O Hardware, Application I/O
interface, Kernel I/O subsystem, Streams, Performance.
Magnetic disk provides bulk of secondary storage for modern computer systems.
In operation the disk rotates at high speed, such as 7200 rpm (120 revolutions per second.) The rate at
which data can be transferred from the disk to the computer is composed of several steps:
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page 1
Moving-head disk mechanism.
The positioning time, the seek time or random access time is the time required to move the heads from
one cylinder to another, and for the heads to settle down after the move. This is typically the slowest step in the
process and the predominant bottleneck to overall transfer rates.
The rotational latency is the amount of time required for the desired sector to rotate around and come
under the read-write head. This can range anywhere from zero to one full revolution, and on the average will equal
one-half revolution. The transfer rate, which is the time required to move the data electronically from the disk to
the computer. Disk heads "fly" over the surface on a very thin cushion of air. If they should accidentally contact
the disk, then a head crash occurs, which may or may not permanently damage the disk or even destroy it
completely.
Floppy disks are normally removable.Hard drives can also be removable, and some are even hot-
swappable, meaning they can be removed while the computer is running, and a new hard drive inserted in their
place.
Disk drives are connected to the computer via a cable known as the I/O Bus. Some of the common
interface formats include Enhanced Integrated Drive Electronics, EIDE; Advanced Technology Attachment, ATA;
Serial ATA, SATA, Universal Serial Bus, USB; Fiber Channel, FC, and Small Computer Systems Interface, SCSI.
The host controller is at the computer end of the I/O bus, and the disk controller is built into the disk itself.
The CPU issues commands to the host controller via I/O ports. Data is transferred between the magnetic surface
and onboard cache by the disk controller, and then the data is transferred from that cache to the host controller and
the motherboard memory at electronic speeds.
Sometimes old technologies are used in new ways as economics change or the technologies evolve.
An example is the growing importance of Solid-State Disks, or SSDs. Simply described, an SSD is non-
volatile memory that is used like a hard drive. There are many variations of this technology, from DRAM
with a battery to allow it to maintain its state in a power failure through flash-memory technologies like
single-level cell (SLC) and multilevel cell (MLC) chips.
Magnetic Tapes
Magnetic tape was used as an early secondary-storage medium. Although it is relatively permanent and
can hold large quantities of data, its access time is slow compared with that of main memory and magnetic disk.
In addition, random access to magnetic tape is about a thousand times slower than random access to magnetic
disk, so tapes are not very useful for secondary storage.
Tapes are used mainly for backup, for storage of infrequently used information, and as a medium for
transferring information from one system to another. Some tapes have built-in compressions that can more than
double the effective storage. Tapes and their drivers are usually categorized by width, including 4, 8, and 19
millimeters and 1/4 and 1/2 inch. Some are named according to technology, such as LTO-5 and SDLT.
Disk Structure:
A hard disk is a memory storage device which looks like this:
The disk is divided into tracks. Each track is further divided into sectors. The point to be noted here is that
outer tracks are bigger in size than the inner tracks but they contain the same number of sectors and have equal
storage capacity.
This is because the storage density is high in sectors of the inner tracks whereas the bits are sparsely
arranged in sectors of the outer tracks.
Some space of every sector is used for formatting. So, the actual capacity of a sector is less than the given
capacity. Read-Write(R-W) head moves over the rotating hard disk.
It is this Read-Write head that performs all the read and write operations on the disk and hence, position
of the R-W head is a major concern. To perform a read or write operation on a memory location, we need to place
the R-W head over that position.
In questions, if the seek time and controller time is not mentioned, take them to be zero. If the amount of data to
be transferred is not given, assume that no data is being transferred. Otherwise, calculate the time taken to transfer
the given amount of data.
The average of rotational latency is taken when the current position of R-W head is not given. Because, the R-W
may be already present at the desired position or it might take a whole rotation to get the desired sector under the
R-W head. But, if the current position of the R-W head is given then the rotational latency must be calculated.
Example –
Consider a hard disk with:
2. The disk is rotating at 3600 RPM, what is the data transfer rate?
60 sec -> 3600 rotations
1 sec -> 60 rotations
Data transfer rate = number of rotations per second * track capacity * number of surfaces (since 1 R-
W head is used for each surface)
Data transfer rate = 60 * 128 * 256 *
4 Data transfer rate = 7.5 MB/sec
3. The disk is rotating at 3600 RPM, what is the average access time?
Since, seek time, controller time and the amount of data to be transferred is not given, we consider all
the three terms as 0.
Therefore, Average Access time = Average rotational
delay Rotational latency => 60 sec -> 3600 rotations 1 sec
-> 60 rotations
Rotational latency = (1/60) sec = 16.67 msec.
Average Rotational latency = (16.67)/2
= 8.33 msec.
Average Access time = 8.33 msec.
Transfer Time: Transfer time is the time to transfer the data. It depends on the rotating speed of the disk and
number of bytes to be transferred.
Disk Response Time: Response Time is the average of time spent by a request waiting to perform its I/O
operation. Average Response time is the response time of the all requests. Variance Response Time is measure of
how individual request are serviced with respect to average response time. So the disk scheduling algorithm that
gives minimum variance response time is better.
1. FCFS: FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS, the requests are addressed in
the order they arrive in the disk queue.
Advantages:
Every request gets a fair chance
No indefinite postponement
Disadvantages:
Does not try to optimize seek time
May not provide the best possible service
2. SSTF: In SSTF (Shortest Seek Time First), requests having shortest seek time are executed first. So, the seek
time of every request is calculated in advance in queue and then they are scheduled according to their
calculated seek time. As a result, the request near the disk arm will get executed first. SSTF is certainly an
improvement over FCFS as it decreases the average response time and increases the throughput of system.
Advantages:
Average Response Time
Decreases Throughput increases
Disadvantages:
Overhead to calculate seek time in advance
Can cause Starvation for a request if it has higher seek time as compared to incoming
requests High variance of response time as SSTF favours only some requests
Disadvantages:
Long waiting time for requests for locations just visited by disk arm
4. CSCAN: In SCAN algorithm, the disk arm again scans the path that has been scanned, after reversing its
direction. So, it may be possible that too many requests are waiting at the other end or there may be zero or
few requests pending at the scanned area.
These situations are avoided in CSAN algorithm in which the disk arm instead of reversing its direction goes to
the other end of the disk and starts servicing the requests from there. So, the disk arm moves in a circular fashion
and this algorithm is also similar to SCAN algorithm and hence it is known as C-SCAN (Circular SCAN).
Advantages:
Provides more uniform wait time compared to SCAN
5. LOOK: It is similar to the SCAN disk scheduling algorithm except the difference that the disk arm in spite
of going to the end of the disk goes only to the last request to be serviced in front of the head and then
reverses its direction from there only. Thus it prevents the extra delay which occurred due to unnecessary
traversal to the end of the disk.
6. CLOOK: As LOOK is similar to SCAN algorithm, in similar way, CLOOK is similar to CSCAN disk
scheduling algorithm. In CLOOK, the disk arm inspite of going to the end goes only to the last request to be
serviced in front of the head and then from there goes to the other end’s last request. Thus, it also prevents
the extra delay which occurred due to unnecessary traversal to the end of the disk.
1. FCFS Scheduling:
The simplest form of disk scheduling is, of course, the first-come, first-served (FCFS) algorithm.
This algorithm is intrinsically fair, but it generally does not provide the fastest service. Consider, for
If the disk head is initially at cylinder 53, it will first move from 53 to 98, then to 183, 37, 122, 14,
124, 65, and finally to 67, for a total head movement of 640 cylinders. The wild swing from 122 to 14 and
then back to 124 illustrates the problem with this schedule. If the requests for cylinders 37 and 14 could be
serviced together, before or after the requests for 122 and 124, the total head movement could be decreased
substantially, and performance could be thereby improved.
2. SSTF(shortest-seek-time-first)Scheduling
Service all the requests close to the current head position, before moving the head far away
to service other requests. That is selects the request with the minimum seek time from the current
head position.
The disk head starts at one end of the disk, and moves toward the other end, servicing requests as it
reaches each cylinder, until it gets to the other end of the disk. At the other end, the direction of head
movement is reversed, and servicing continues.
4. C-SCAN Scheduling
Variant of SCAN designed to provide a more uniform wait time. It moves the head from one end of
the disk to the other, servicing requests along the way. When the head reaches the other end, however, it
immediately returns to the beginning of the disk, without servicing any requests on the return trip.
Both SCAN and C-SCAN move the disk arm across the full width of the disk. In this, the
arm goes only as far as the final request in each direction. Then, it reverses direction immediately,
without going all the way to the end of the disk. 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. The following diagram illustrates the circular form of LOOK:
Disk Management
1. Disk Formatting:
Before a disk can store data, the sector is divided into various partitions. This process is called
low- level formatting or physical formatting. It fills the disk with a special data structure for each
sector. The data structure for a sector consists of
✓ Header,
✓ Data area (usually 512 bytes in size),and
✓ Trailer.
To use a disk to hold files, the operating system still needs to record its own data structures on the
disk. It does so in two steps.
(a) The first step is Partition the disk into one or more groups of cylinders. Among the partitions,
one partition can hold a copy of the OS‘s executable code, while another holds user files.
(b) The second step is logical formatting .The operating system stores the initial file-system data
structures onto the disk. These data structures may include maps of free and allocated space and an
initial empty directory.
2. Boot Block:
For a computer to start running-for instance, when it is powered up or rebooted-it needs to have an
initial program to run. This initial program is called bootstrap program & it should be simple. It
initializes all aspects of the system, from CPU registers to device controllers and the contents of main
memory, and then starts the operating system.
Advantages:
2. It is at a fixed location that the processor can start executing when powered up or reset.
The full bootstrap program is stored in a partition called the boot blocks, at a fixed location on the
disk. A disk that has a boot partition is called a boot disk or system disk. The code in the boot ROM
instructs the disk controller to read the boot blocks into memory and then starts executing that code.
Bootstrap loader: load the entire operating system from a non-fixed location on disk, and to start the
operating system running.
Depending on the disk and controller in use, these blocks are handled in a variety of ways;
If blocks go bad during normal operation, a special program must be run manually to search for
the bad blocks and to lock them away as before. Data that resided on the bad blocks usually are lost.
Method 2: “sector sparing or forwarding”
The controller maintains a list of bad blocks on the disk. Then the controller can be told to replace each
bad sector logically with one of the spare sectors. This scheme is known as sector sparing or forwarding.
2. The controller calculates the ECC and finds that the sector is bad.
4. The next time that the system is rebooted, a special command is run to tell the controller to replace
the bad sector with a spare.
5. After that, whenever the system requests logical block 87, the request is translated into the
replacement sector's address by the controller.
For an example, suppose that logical block 17 becomes defective, and the first available spare
follows sector 202. Then, sector slipping would remap all the sectors from 17 to 202, moving them all
down one spot. That is, sector 202 would be copied into the spare, then sector 201 into 202, and then
200 into 201, and so on, until sector 18 is copied into sector 19. Slipping the sectors in this way frees up
the space of sector 18, so sector 17 can be mapped to it.
Modern systems typically swap out pages as needed, rather than swapping out entire processes. Hence
the swapping system is part of the virtual memory management system.
The amount of swap space needed by an OS varies greatly according to how it is used. Some
systems require an amount equal to physical RAM; some want a multiple of that; some want an
amount equal to the amount by which virtual memory exceeds physical RAM, and some systems
use little or none at all!
Some systems support multiple swap spaces on separate disks in order to speed up the virtual
memory system.
The interchange of data between virtual memory and real memory is called as swapping and space
on disk as “swap space”.
Swap-Space Location
As a large file which is part of the regular file system. This is easy to implement, but inefficient.
Not only must the swap space be accessed through the directory system, the file is also subject to
fragmentation issues. Caching the block location helps in finding the physical blocks, but that is not
a complete fix.
As a raw partition, possibly on a separate or little-used disk. This allows the OS more control over
swap space management, which is usually faster and more efficient. Fragmentation of swap space
is generally not a big issue, as the space is re-initialized every time the system is rebooted. The
downside of keeping swap space on a raw partition is that it can only be grown by repartitioning the
hard drive.
Historically OS swapped out entire processes as needed. Modern systems swap out only individual
pages, and only as needed. In the mapping system shown below for Linux systems, a map of swap
space is kept in memory, where each entry corresponds to a 4K block in the swap space. Zeros
indicate free slots and non-zeros refer to how many processes have a mapping to that particular
block ( >1 for shared pages only. )
File Attributes
Name - Some systems give special significance to names, and particularly extensions ( .exe, .txt,
etc. ), and some do not. Some extensions may be of significance to the OS ( .exe ), and others
only to certain applications ( .jpg )
Identifier
Type - Text, executable, other binary, etc.
Location - on the hard drive.
Size
Protection
Time & Date
User ID
File Operations
o Creating a file
o Writing a file
o Reading a file
o Deleting a file
o Truncating a file.
o An advisory lock is informational only, and not enforced. ( A "Keep Out" sign, which may
be ignored. )
o A mandatory lock is enforced. ( A truly locked door. )
File Types
Windows ( and some other systems ) use special file extensions to indicate the type of each file:
File Structure
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.
A File Structure should be according to a required format that the operating system can understand.
A file has a certain defined structure according to its type. A
An object file is a sequence of bytes organized into blocks that are understandable by the machine.
Files can be structured in several ways in which three common structures are given in this tutorial with their
short description one by one.
File Structure 1
Here, as you can see from the above figure, the file is an unstructured sequence of bytes. Therefore, the OS
doesn't care about what is in the file, as all it sees are bytes.
File Structure 2
File Structure 3
Now in the last structure of a file that you can see in the above figure, a file basically consists of a tree of records,
not necessarily all the same length, each containing a key field in a fixed position in the record. The tree is stored
on the field, just to allow the rapid searching for a specific key.
Access Methods
File access mechanism refers to the manner in which the records of a file may be accessed. There are several
ways to access files −
Sequential access
Direct/Random access
Sequential-access file.
Direct/Random access
Random access file organization provides, accessing the records directly.
Each record has its own address on the file with by the help of which it can be directly accessed for
reading or writing.
The records need not be in any sequence within the file and they need not be in adjacent locations on
the storage medium.
An index is created for each file which contains pointers to various blocks.
Index is searched sequentially and its pointer is used to access the file directly.
Storage Structure
A disk can be used in its entirety for a file system. Alternatively a physical disk can be broken up into
multiple partitions, slices, or mini-disks, each of which becomes a virtual disk and can have its own file
system( or be used for raw storage, swap space, etc. )Or, multiple physical disks can be combined into
one volume, i.e. a larger virtual disk, with its own file system spanning the physical disks.
Directory Overview
Directory organization
Single-Level Directory
Single-level directory.
Two-Level Directory
A master file directory is used to keep track of each users directory, and must be maintained when users
are added to or removed from the system.
Systems may or may not allow users to access other directories besides their own
o If access to other directories is allowed, then provision must be made to specify the directory
being accessed.
o If access is denied, then special consideration must be made for users to run programs located in
system directories. A search path is the list of directories in which to search for executable
programs, and can be set uniquely for each user.
Tree-Structured Directories
Acyclic-Graph Directories
When the same files need to be accessed in more than one place in the directory structure (e.g. because
they are being shared by more than one user / process), it can be useful to provide an acyclic-graph
structure. (Note the directed arcs from parent to child.)
UNIX provides two types of links for implementing the acyclic-graph structure. (See "man ln" for more
details.)
o 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 file system.
o 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 file systems, as well as
ordinary files in the current file system.
Windows only supports symbolic links, termed shortcuts.
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.
o One option is to find all the symbolic links and adjust them also.
o Another is to leave the symbolic links dangling, and discover that they are no longer valid the
next time they are used.
o What if the original file is removed, and replaced with another file having the same name before
the symbolic link is next used?
If cycles are allowed in the graphs, then several problems can arise:
o Search algorithms can go into infinite loops. One solution is to not follow links in search algorithms.
(Or not to follow symbolic links, and to only allow symbolic links to refer to directories.)
The basic idea behind mounting file systems is to combine multiple file systems into one large
tree structure.
The mount command is given a file system to mount and a mount point (directory) on which to
attach it.
Once a file system is mounted onto a mount point, any further references to that directory actually
refer to the root of the mounted file system.
File systems can only be mounted by root, unless root has previously configured certain filesystems to be
mountable onto certain pre-determined mount points. ( E.g. root may allow users to mount floppy
filesystems to /mnt or something like it. ) Anyone can run the mount command to see what file systems is
currently mounted.
Mount point.
The traditional Windows OS runs an extended two-tier directory structure, where the first tier of the
structure separates volumes by drive letters, and a tree structure is implemented below that level.
Macintosh runs a similar system, where each new volume that is found is automatically mounted and
added to the desktop when it is found.
More recent Windows systems allow filesystems to be mounted to any directory in the filesystem, much
like UNIX.
Multiple Users
o The owner ( user ) who owns the file, and who can control its access.
o The group of other user IDs that may have some special access to the file.
o What access rights are afforded to the owner (User ), the Group, and to the rest of the world ( the
universe, a.k.a. Others. )
The advent of the Internet introduces issues for accessing files stored on remote computers
o The original method was ftp, allowing individual files to be transported across systems as needed.
Ftp can be either account or password controlled, or anonymous, not requiring any user name or
password.
o Various forms of distributed file systems allow remote file systems to be mounted onto a local
directory structure, and accessed using normal file access commands. (The actual files are still
transported across the network as needed, possibly using ftp as the underlying transport mechanism.
)
o The WWW has made it easy once again to access files on remote systems without mounting their
filesystems, generally using (anonymous ) ftp as the underlying file transport mechanism.
When one computer system remotely mounts a file system that is physically located on another system,
the system which physically owns the files acts as a server, and the system which mounts them is the
client.
User IDs and group IDs must be consistent across both systems for the system to work properly. ( I.e. this
is most applicable across multiple computers managed by the same organization, shared by a common
group of users. )
The same computer can be both a client and a server. ( E.g. cross-linked file systems.
o Servers commonly restrict mount permission to certain trusted systems only. Spoofing ( a
computer pretending to be a different computer ) is a potential security risk.
o Servers may restrict remote access to read-only.
o Servers restrict which filesystems may be remotely mounted. Generally the information within
those subsystems is limited, relatively public, and protected by frequent backups.
The NFS (Network File System ) is a classic example of such a system.
The Domain Name System, DNS, provides for a unique naming system across all of the Internet.
Failure Modes
When a local disk file is unavailable, the result is generally known immediately, and is generally non-
recoverable. The only reasonable response is for the response to fail.
However when a remote file is unavailable, there are many possible reasons, and whether or not it is
unrecoverable is not readily apparent. Hence most remote access systems allow for blocking or delayed
response, in the hopes that the remote system ( or the network ) will come back up eventually.
Consistency Semantics
Consistency Semantics deals with the consistency between the views of shared files on a networked
system. When one user changes the file, when do other users see the changes?
At first glance this appears to have all of the synchronization issues discussed in Chapter 6. Unfortunately
the long delays involved in network operations prohibit the use of atomic operations as discussed in that
chapter.
UNIX Semantics
o Writes to an open file are immediately visible to any other user who has the file open.
o One implementation uses a shared location pointer, which is adjusted for all sharing users.
The file is associated with a single exclusive physical resource, which may delay some accesses.
Session Semantics
Immutable-Shared-Files Semantics
Under this system, when a file is declared as shared by its creator, it becomes immutable and the name
cannot be re-used for any other resource. Hence it becomes read-only, and shared access is simple.
Protection
The processes in an operating system must be protected from one another's activities. To provide such protection,
we can use various mechanisms to ensure that only processes that have gained proper authorization from the
operating system can operate on the files, memory segments, CPU, and other resources of a system.
Goals of Protection
Obviously to prevent malicious misuse of the system by users or programs. See chapter 15 for a more
thorough coverage of this goal.
To ensure that each shared resource is used only in accordance with system policies, which may be set
either by system designers or by system administrators.
To ensure that errant programs cause the minimal amount of damage possible.
Note that protection systems only provide the mechanisms for enforcing policies and ensuring reliable
systems. It is up to administrators and users to implement those mechanisms effectively.
Principles of Protection
The principle of least privilege dictates that programs, users, and systems be given just enough privileges
This ensures that failures do the least amount of harm and allow the least of harm to be done.
For example, if a program needs special privileges to perform a task, it is better to make it a SGID
program with group ownership of "network" or "backup" or some other pseudo group, rather than SUID
with root ownership. This limits the amount of damage that can occur if something goes wrong.
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page 29
Typically each user is given their own account, and has only enough privilege to modify their own files.
The root account should not be used for normal day to day activities - The System Administrator should
also have an ordinary account, and reserve use of the root account for only those tasks which need the
root privileges.
Domain of Protection
The need to know principle states that a process should only have access to those objects it needs to
accomplish its task, and furthermore only in the modes for which it needs access and only during the time
frame when it needs access.
The modes available for a particular object may depend upon its type.
Domain Structure
Each domain defines a set of objects and the types of operations that may be invoked on each
A domain is defined as a set of < object, { access right set } > pairs, as shown below. Note that some
domains may be disjoint while others overlap.
If the association is static, then the need-to-know principle requires a way of changing the contents of the
domain dynamically. If the association is dynamic, then there needs to be a mechanism for domain
switching. Domains may be realized in different fashions - as users, or as processes, or as procedures.
E.g. if each user corresponds to a domain, then that domain defines the access of that user, and changing
domains involves changing user ID. The model of protection that we have been discussing can be viewed
Access matrix.
Domain switching can be easily supported under this model, simply by providing "switch" access to
other domains:
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.
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page 31
The AFS uses this system for distributed access.
Control is very finely adjustable, but may be complicated, particularly when the specific users involved are
unknown. ( AFS allows some wild cards, so for example all users on a certain remote system may be trusted, or
a given username may be trusted when accessing from any remote system. )
UNIX uses a set of 9 access control bits, in three groups of three. These correspond to R, W, and X
permissions for each of the Owner, Group, and Others. ( See "man chmod" for full details. ) The RWX
bits control the following privileges for ordinary files and directories:
Read ( view )
R Read directory contents. Required to get a listing of the directory.
file contents.
Write
W ( change ) file Change directory contents. Required to create or delete files.
contents.
Hard disks have two important properties that make them suitable for secondary storage of files in file
systems: (1) Blocks of data can be rewritten in place, and (2) they are direct access, allowing any block
of data to be accessed with only (relatively) minor movements of the disk heads and rotational latency.
Disks are usually accessed in physical blocks, rather than a byte at a time. Block sizes may range from
512 bytes to 4K or larger.
File systems organize storage on disk drives, and can be viewed as a layered design:
o At the lowest layer are the physical devices, consisting of the magnetic media, motors & controls,
and the electronics connected to them and controlling them. Modern disk put more and more of the
electronic controls directly on the disk drive itself, leaving relatively little work for the disk controller
card to perform.
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page 32
o 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. Each controller card ( device ) on a system has a
different set of addresses ( registers, a.k.a. ports ) that it listens to, and a unique set of command codes and
results codes that it understands.
o 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. Depending on the system, blocks
may be referred to with a single block number, ( e.g. block # 234234 ), or with head-sector-cylinder
combinations.
o The file organization module knows about files and their logical blocks, and how they map to
physical blocks on the disk. In addition to translating from logical to physical blocks, the file organization
module also maintains the list of free blocks, and allocates free blocks to files as needed.
o The logical file system deals with all of the meta data associated with a file ( UID, GID, mode,
dates, etc ), i.e. everything about the file except the data itself. This level manages the directory structure
and the mapping of file names to file control blocks, FCBs, which contain all of the meta data as well as
block number information for finding the data on the disk.
The layered approach to file systems means that much of the code can be used uniformly for a wide
variety of different file systems, and only certain layers need to be file system specific. Common file systems in
use include the UNIX file system, UFS, the Berkeley Fast File System, FFS, Windows systems FAT, FAT32,
NTFS, CD-ROM systems ISO 9660, and for Linux the extended file systems ext2 and ext3 ( among 40 others
supported. )
Overview
o A boot-control block, (per volume) a.k.a. the boot block in UNIX or the partition boot sector in
Windows contains information about how to boot the system off of this disk. This will generally be
the first sector of the volume if there is a bootable system loaded on that volume, or the block will
be left vacant otherwise.
o A volume control block, (per volume ) a.k.a. the master file table in UNIX or the superblock in
Windows, which contains information such as the partition table, number of blocks on each file
system, and pointers to free blocks and free FCB blocks.
o A directory structure (per file system), containing file names and pointers to corresponding FCBs.
UNIX uses inode numbers, and NTFS uses a master file table.
o The File Control Block, FCB, (per file) containing details about ownership, size, permissions,
dates, etc. UNIX stores this information in inodes, and NTFS in the master file table as a relational
database structure.
o A system-wide open file table, containing a copy of the FCB for every currently open file in the
system, as well as some other related information.
Figure illustrates some of the interactions of file system components when files are created and/or used:
o 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.
o 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. 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.
o If another process already has a file open when a new request comes in for the same file, and it is
sharable, then a counter in the system-wide table is incremented and the per-process table is
adjusted to point to the existing entry in the system-wide table.
o When a file is closed, the per-process table entry is freed, and the counter in the system-wide table
is decremented. If that counter reaches zero, then the system wide table is also freed. Any data
currently stored in memory cache for this file is written out to disk if necessary.
Physical disks are commonly divided into smaller units called partitions. They can also be combined into
larger units, but that is most commonly done for RAID installations and is left for later chapters.
Partitions can either be used as raw devices (with no structure imposed upon them), or they can be
formatted to hold a file system ( i.e. populated with FCBs and initial directory structures as appropriate.)
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. Partitions containing filesystems can
generally only be accessed using the file system structure by ordinary users, but can often be accessed as a
raw device also by root.
The boot block is accessed as part of a raw partition, by the boot program prior to any operating system
being loaded. 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. (Older systems required that the root partition lie completely
within the first 1024 cylinders of the disk, because that was as far as the boot program could reach. Once
the kernel had control, then it could access partitions beyond the 1024 cylinder boundary. )
Virtual File Systems, VFS, provide a common interface to multiple different file system types. In
addition, it provides for a unique identifier (vnode ) for files across the entire space, including across all
file systems of different types. (UNIX inodes are unique only across a single file system, and certainly do
not carry across networked file systems)
Linux VFS provides a set of common functionalities for each file system, using function pointers
accessed through a table. The same functionality is accessed through the same table position for all file
system types, though the actual functions pointed to by the pointers may be file system-specific. Common
operations provided include open( ), read( ), write( ), and mmap( ).
Directories need to be fast to search, insert, and delete, with a minimum of wasted disk space.
Linear List
A linear list is the simplest and easiest directory structure to set up, but it does have some drawbacks.
Finding a file (or verifying one does not already exist upon creation) requires a linear search.
Deletions can be done by moving all entries, flagging an entry as deleted, or by moving the last entry into
the newly vacant position.
Sorting the list makes searches faster, at the expense of more complex insertions and deletions.
A linked list makes insertions and deletions into a sorted list easier, with overhead for the links.
More complex data structures, such as B-trees, could also be considered.
Hash Table
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 (first fit, best fit, fragmentation problems, etc.) The distinction is that the high time penalty
required for moving the disk heads from spot to spot may now justify the benefits of keeping files
contiguously when possible. In this scheme, each file occupies a contiguous set of blocks on the disk. For
example, if a file requires n blocks and is given a block b as the starting location, then the blocks assigned
to the file will be: b, b+1, b+2,……b+n-1.This means that given the starting block address and the length
of the file (in terms of blocks required), we can determine the blocks occupied by the file.
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page
The directory entry for a file with contiguous allocation contains
The file ‘mail’ in the following figure starts from the block 19 with length = 6 blocks. Therefore, it
occupies 19, 20, 21, 22, 23, 24 blocks.
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
blocks.
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.
Linked Allocation
Linked allocation involves no external fragmentation, does not require pre-known file sizes, and allows
files to grow dynamically at any time.
Unfortunately linked allocation is only efficient for sequential access files, as random access requires
starting at the beginning of the list for each new location access.
Allocating clusters of blocks reduces the space wasted by pointers, at the cost of internal fragmentation.
Another big problem with linked allocation is reliability if a pointer is lost or damaged. Doubly linked
lists provide some protection, at the cost of additional overhead and wasted space.
In this scheme, each file is a linked list of disk blocks which need not be contiguous. The disk blocks can
be scattered anywhere on the disk.
The directory entry contains a pointer to the starting and the ending file block. Each block contains a
pointer to the next block occupied by the file.
The file ‘jeep’ in following image shows how the blocks are randomly distributed. The last block (25)
contains -1 indicating a null pointer and does not point to any other block.
Advantages:
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.
File-allocation table.
Indexed Allocation
Indexed Allocation combines all of the indexes for accessing each file into a common block ( for that file
), as opposed to spreading them all over the disk or storing them in a FAT table.
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. However, in linked
allocation we lose the space of only 1 pointer per block.
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. There are several approaches:
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.
Combined Scheme - This is the scheme used in UNIX inodes, in which the first 12 or so data block
pointers are stored directly in the inode, and then singly, doubly, and triply indirect pointers provide
access to more data blocks as needed. (See below) The advantage of this scheme is that for small files (
which many are ), the data blocks are readily accessible ( up to 48K with 4K block sizes ); files up to
about 4144K ( using 4K blocks ) are accessible with only a single indirect block ( which can be cached ),
and huge files are still accessible using a relatively small number of disk accesses ( larger in theory than
can be addressed by a 32-bit address, which is why some systems have moved to 64-bit file pointers. )
Performance
The optimal allocation method is different for sequential access files than for random access files, and is
also different for small files than for large files.
Some systems support more than one allocation method, which may require specifying how the file is to
be used (sequential or random access) at the time it is allocated. Such systems also provide conversion
utilities.
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page 43
Some systems have been known to use contiguous access for small files, and automatically switch to an
indexed scheme when file sizes surpass a certain threshold.
And of course some systems adjust their allocation schemes (e.g. block sizes) to best match the
characteristics of the hardware for optimum performance.
Bit Vector
One simple approach is to use a bit vector, in which each bit represents a disk block, set to 1 if free or 0 if
allocated.
Fast algorithms exist for quickly finding contiguous blocks of a given size
The down side is that a 40GB disk requires over 5MB just to store the bitmap. (For example. )
Linked List
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.
The FAT table keeps track of the free list as just one more linked list on the table.
Grouping
A variation on linked list free lists is to use links of blocks of indices of free blocks. If a block holds up to
N addresses, then the first block in the linked-list contains up to N-1 addresses of free blocks and a
pointer to the next block of free addresses.
Counting
When there are multiple contiguous blocks of free space then the system can keep track of the starting
address of the group and the number of contiguous free blocks. As long as the average length of a
contiguous group of free blocks is greater than two this offers a savings in space needed for the free list.
(Similar to compression techniques used for graphics images when a group of pixels all the same color is
encountered.)
Sun's ZFS file system was designed for HUGE numbers and sizes of files, directories, and even file
systems.
The resulting data structures could be VERY inefficient if not implemented carefully. For example,
freeing up a 1 GB file on a 1 TB file system could involve updating thousands of blocks of free list
bit maps if the file was spread across the disk.
ZFS uses a combination of techniques, starting with dividing the disk up into (hundreds of ) metaslabs of
a manageable size, each having their own space map.
Free blocks are managed using the counting technique, but rather than write the information to a table, it
is recorded in a log-structured transaction record. Adjacent free blocks are also coalesced into a
larger single free block.
An in-memory space map is constructed using a balanced tree data structure, constructed from the log
data.
The combination of the in-memory tree and the on-disk log provide for very fast and
efficient management of these very large files and free blocks.
UNIX pre-allocates inodes, which occupies space even before any files are created.
UNIX also distributes inodes across the disk, and tries to store data files near their inode, to reduce the
distance of disk seeks between the inodes and the data.
Some systems use variable size clusters depending on the file size.
The more data that is stored in a directory (e.g. last access time), the more often the directory blocks have
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page 45
to be re-written.
As technology advances, addressing schemes have had to grow as well.
Sun's ZFS file system uses 128-bit pointers, which should theoretically never need to be expanded. (The
mass required to store 2^128 bytes with atomic storage would be at least 272 trillion kilograms! )
Kernel table sizes used to be fixed, and could only be changed by rebuilding the kernels. Modern
tables are dynamically allocated, but that requires more complicated algorithms for accessing them.
Performance
Disk controllers generally include on-board caching. When a seek is requested, the heads are moved into
place, and then an entire track is read, starting from whatever sector is currently under the heads
( reducing latency. ) The requested sector is returned and the unrequested portion of the track is cached
in the disk's electronics.
Some OSes cache disk blocks they expect to need again in a buffer cache.
A page cache connected to the virtual memory system is actually more efficient as memory addresses
do not need to be converted to disk block addresses and back again.
Some systems ( Solaris, Linux, Windows 2000, NT, XP ) use page caching for both process pages
and file data in a unified virtual memory.
Figures show the advantages of the unified buffer cache found in some versions of UNIX and Linux
- Data does not need to be stored twice, and problems of inconsistent buffer information are avoided.
Page replacement strategies can be complicated with a unified cache, as one needs to decide whether to
replace process or file pages, and how many pages to guarantee to each category of pages. Solaris, for
example, has gone through many variations, resulting in priority paging giving process pages priority over
file I/O pages, and setting limits so that neither can knock the other completely out of memory.
Another issue affecting performance is the question of whether to implement synchronous writes or
asynchronous writes. Synchronous writes occur in the order in which the disk subsystem receives them,
without caching; Asynchronous writes are cached, allowing the disk subsystem to schedule writes in a
more efficient order
The type of file access can also have an impact on optimal page replacement policies. For example, LRU
is not necessarily a good policy for sequential access files. For these types of files progression normally
goes in a forward direction only, and the most recently used page will not be needed again until after the
file has been rewound and re-read from the beginning, ( if it is ever needed at all. )
On the other hand, we can expect to need the next page in the file fairly soon. For this reason sequential
access files often take advantage of two special policies:
o Free-behind frees up a page as soon as the next page in the file is requested, with the assumption
that we are now done with the old page and won't need it again for a long time.
o Read-ahead reads the requested page and several subsequent pages at the same time, with the
assumption that those pages will be needed in the near future. This is similar to the track caching
that is already performed by the disk controller, except it saves the future latency of transferring
data from the disk controller memory into motherboard main memory.
The caching system and asynchronous writes speed up disk writes considerably, because the disk
subsystem can schedule physical writes to the disk to minimize head movement and disk seek times.
Recovery:
Consistency Checking
The storing of certain data structures (e.g. directories and inodes) in memory and the caching of disk
operations can speed up performance, but what happens in the result of a system crash? All volatile
memory structures are lost, and the information stored on the hard drive may be left in an inconsistent
state.
A Consistency Checker is often run at boot time or mount time, particularly if a filesystem was not
closed down properly. Some of the problems that these tools look for include:
Disk blocks allocated to files and also listed on the free list.
Disk blocks neither allocated to files nor on the free list.
Disk blocks allocated to more than one file.
The number of disk blocks allocated to a file inconsistent with the file's stated
size. Properly allocated files / inodes which do not appear in any directory entry.
Log-based transaction-oriented filesystems borrow techniques developed for databases, guaranteeing that
any given transaction either completes successfully or can be rolled back to a safe state before the
transaction commenced:
Sun's ZFS and Network Appliance's WAFL file systems take a different approach to file system
consistency.
No blocks of data are ever over-written in place. Rather the new data is written into fresh new blocks, and
In order to recover lost data in the event of a disk crash, it is important to conduct backups regularly.
Files should be copied to some removable medium, such as magnetic tapes, CDs, DVDs, or external
removable hard drives.
Incremental backups copy only files which have changed since some previous time.
A combination of full and incremental backups can offer a compromise between full recoverability, the
number and size of backup tapes needed, and the number of tapes that need to be used to do a full restore.
For example, one strategy might be:
o At the end of the first and again at the end of the second week, backup all files which have
changed since the beginning of the month.
o At the end of the third week, backup all files that have changed since the end of the second week.
o Every day of the month not listed above, do an incremental backup of all files that have changed
since the most recent of the weekly backups described above.
Backup tapes are often reused, particularly for daily backups, but there are limits to how many times the
same tape can be used.
Every so often a full backup should be made that is kept "forever" and not overwritten.
For optimal security, backup tapes should be kept off-premises, so that a fire or burglary cannot destroy
both the system and the backups. There are companies ( e.g. Iron Mountain ) that specialize in the secure
off-site storage of critical backup information.
Keep your backup tapes secure - The easiest way for a thief to steal all your data is to simply pocket
your backup tapes!
Note that incremental backups can also help users to get back a previous version of a file that they have
since changed in some way.
Beware that backups can help forensic investigators recover e-mails and other files that users had though
they had deleted!
I/O Systems:
Overview
Management of I/O devices is a very important part of the operating system - so important and so varied
that entire I/O subsystems are devoted to its operation. ( Consider the range of devices on a modern
computer, from mice, keyboards, disk drives, display adapters, USB devices, network connections, audio
I/O, printers, special devices for the handicapped, and many special-purpose peripherals. )
I/O Subsystems must contend with two (conflicting? ) trends: (1) The gravitation towards standard
interfaces for a wide range of devices, making it easier to add newly developed devices to existing systems,
and (2) the development of entirely new types of devices, for which the existing standard interfaces are not
always easy to apply.
Device drivers are modules that can be plugged into an OS to handle a particular device or category of
similar devices.
I/O Hardware:
other Devices communicate with the computer via signals sent over wires or through the air.
Devices connect with the computer via ports, e.g. a serial or parallel port. A
o Buses include rigid protocols for the types of messages that can be sent across the bus and the
procedures for resolving contention issues.
o Figure below illustrates three of the four bus types commonly found in a modern PC:
2. The expansion bus connects slower low-bandwidth devices, which typically deliver data
one character at a time (with buffering.)
3. The SCSI bus connects a number of SCSI devices to a common SCSI controller.
4. A daisy-chain bus, (not shown) is when a string of devices is connected to each other like
beads on a chain, and only one of the devices is directly connected to the host.
One way of communicating with devices is through registers associated with each port. Registers may be
one to four bytes in size, and may typically include ( a subset of ) the following four:
3. 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.
4. 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.
Figure shows some of the most common I/O port address ranges.
o In this case a certain portion of the processor's address space is mapped to the device,
and communications occur by reading and writing directly to/from those memory areas.
o Memory-mapped I/O is suitable for devices which must move large quantities of data
quickly, such as graphics cards.
o Memory-mapped I/O can be used either instead of or more often in combination with traditional
registers. For example, graphics cards still use registers for control information such as setting
the video mode.
o ( Note: Memory-mapped I/O is not the same thing as direct memory access, DMA.)
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, signalling the completion of the operation.
Polling can be very fast and efficient, if both the device and the controller are fast and if there is
significant data to transfer. It becomes inefficient, however, if the host must wait a long time in the busy
loop waiting for the device, or if frequent checks need to be made for data that is infrequently there.
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
CPU. (The interrupt handler clears the interrupt by servicing the device.)
Interrupt-
driven I/O procedure
The above description is adequate for simple interrupt-driven I/O, but there are three needs in modern
computing which complicate the picture:
1. The need to defer interrupt handling during critical processing,
2. The need to determine which interrupt handler to invoke, without having to poll all devices to see
which one needs attention, and
3. The need for multi-level interrupts, so the system can differentiate between high- and low-priority
interrupts for proper response.
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page 54
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.
o Figure 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 32.Modern interrupt hardware also supports interrupt priority levels, allowing
systems to mask off only lower-priority interrupts while servicing a high-priority interrupt, or
conversely to allow a high-priority signal to interrupt the processing of a low-priority one.
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 signalled via interrupts.
Time slicing and context switches can also be implemented using the interrupt mechanism.
o The scheduler sets a hardware timer before transferring control over to a user process.
o When the timer raises the interrupt request line, the CPU performs a state-save, and
transfers control over to the proper interrupt handler, which in turn runs the scheduler.
o The scheduler does a state-restore of a different process before resetting the timer and issuing
the return-from-interrupt instruction.
A similar example involves the paging system for virtual memory - A page fault causes an interrupt,
which in turn issues an I/O request and a context switch as described above, moving the interrupted
process into the wait queue and selecting a different process to run. When the I/O request has completed
( i.e. when the requested page has been loaded up into physical memory ), then the device interrupts,
and the interrupt handler moves the process from the wait queue into the ready queue, ( or depending on
scheduling algorithms and policies, may go ahead and context switch it back onto the CPU. )
System calls are implemented via software interrupts, a.k.a. traps. When a (library ) program needs work
performed in kernel mode, it sets command information and possibly data addresses in certain registers,
and then raises a software interrupt. ( E.g. 21 hex in DOS. ) The system does a state save and then calls
on the proper interrupt handler to process the request in kernel mode. Software interrupts generally
have low priority, as they are not as urgent as devices with limited buffering space.
Interrupts are also used to control kernel operations, and to schedule activities for optimal
performance. For example, the completion of a disk read operation involves two interrupts:
o A high-priority interrupt acknowledges the device completion, and issues the next disk request
so that the hardware does not sit idle.
o A lower-priority interrupt transfers the data from the kernel memory space to the user space,
and then transfers the process from the waiting queue to the ready queue.
The Solaris OS uses a multi-threaded kernel and priority threads to assign different threads to different
interrupt handlers. This allows for the "simultaneous" handling of multiple interrupts, and the assurance
that high-priority interrupts will take precedence over low-priority ones and over user processes.
For devices that transfer large quantities of data ( such as disk controllers ), it is wasteful to tie up the
CPU transferring data in and out of registers one byte at a time.
Instead this work can be off-loaded to a special processor, known as the Direct Memory Access, DMA,
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.
While the DMA transfer is going on the CPU does not have access to the PCI bus (including main
memory ), but it does have access to its internal registers and primary and secondary caches.
DMA can be done in terms of either physical addresses or virtual addresses that are mapped to physical
addresses. The latter approach is known as Direct Virtual Memory Access, DVMA, and allows direct
data transfer from one memory-mapped device to another without using the main memory chips.
Direct DMA access by user processes can speed up operations, but is generally forbidden by modern
systems for security and protection reasons. ( i.e. DMA is a kernel-mode operation. )
User application access to a wide variety of different devices is accomplished through layering, and
through encapsulating all of the device-specific code into device drivers, while application layers are
presented with a common interface for all ( or at least large general categories of ) devices.
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 filesystem 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 filesystem access, but which disables
buffering and locking operations.
Character devices 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.
o Get the elapsed time (system or wall clock) since a previous event.
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.
o More timers than actually exist can be simulated by maintaining an ordered list of timer events,
and setting the physical timer to go off when the next scheduled event should occur.
On most systems the system clock is implemented by counting interrupts generated by the PIT.
Unfortunately this is limited in its resolution to the interrupt frequency of the PIT, and may be subject to
some drift over time. An alternate approach is to provide direct access to a high frequency hardware
counter, which provides much higher resolution and accuracy, but which does not support interrupts.
With blocking I/O a process is moved to the wait queue when an I/O request is made, and moved back to
the ready queue when the request completes, allowing other processes to run in the meantime.
With non-blocking I/O the I/O request returns immediately, whether the requested I/O operation has
(completely) occurred or not. This allows the process to check for available data without getting hung
completely if it is not there.
One approach for programmers to implement non-blocking I/O is to have a multi-threaded application, in
which one thread makes blocking I/O calls ( say to read a keyboard or mouse ), while other threads
continue to update the screen or perform other tasks.
A subtle variation of the non-blocking I/O is the asynchronous I/O, in which the I/O request returns
immediately allowing the process to continue on with other tasks, and then the process is notified (via
changing a process variable, or a software interrupt, or a callback function) when the I/O operation has
Scheduling I/O requests can greatly improve overall efficiency. Priorities can also play a part in
request scheduling.
The classic example is the scheduling of disk accesses, as discussed in detail.
Buffering and caching can also help, and can allow for more flexible scheduling options.
On systems with many devices, separate request queues are often kept for each device:
Device-status table.
Speed differences between two devices. (See Figure below.) A slow device may write data into a buffer,
and when the buffer is full, the entire buffer is sent to the fast device all at once. So that the slow device
still has somewhere to write while this is going on, a second buffer is used, and the two buffers alternate
as each becomes full. This is known as double buffering. (Double buffering is often used in (animated)
graphics, so that one screen image can be generated in a buffer while the other (completed) buffer is
displayed on the screen. This prevents the user from ever seeing any half-finished screen images.)
Data transfer size differences. Buffers are used in particular in networking systems to break messages up
into smaller packets for transfer, and then for re-assembly at the receiving side.
To support copy semantics. For example, when an application makes a request for a disk write, the data is
copied from the user's memory area into a kernel buffer. Now the application can change their copy of the
data, but the data which eventually gets written out to disk is the version of the data at the time the write
request was made.
Caching
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
item, whereas a cache is just a duplicate copy of some other data stored elsewhere.
Buffering and caching go hand-in-hand, and often the same storage space may be used for both purposes.
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page 63
For example, after a buffer is written to disk, then the copy in memory can be used as a cached
copy, (until that buffer is needed for other purposes)
A spool ( Simultaneous Peripheral Operations On-Line ) buffers data for ( peripheral ) devices such
as printers that cannot support interleaved data streams.
If multiple processes want to print at the same time, they each send their print data to files stored in
the spool directory. When each file is closed, then the application sees that print job as complete, and
the print scheduler sends each file to the appropriate printer one at a time.
Support is provided for viewing the spool queues, removing jobs from the queues, moving jobs from
one queue to another queue, and in some cases changing the priorities of jobs in the queues.
Spool queues can be general ( any laser printer ) or specific ( printer number 42. )
Error Handling
I/O requests can fail for many reasons, either transient ( buffers overflow ) or permanent ( disk crash ). I/O
requests usually return an error bit ( or more ) indicating the problem. UNIX systems also set the
global variable errno to one of a hundred or so well-defined values to indicate the specific error that
has occurred. ( Seeerrno.h for a complete listing, or man errno. )
Some devices, such as SCSI devices, are capable of providing much more detailed information
about errors, and even keep an on-board error log that can be requested by the host.
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.
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. (Video games and some other applications need
to be able to write directly to video memory for optimal performance for example.) Instead the memory
protection system restricts access so that only one process at a time can access particular parts of
memory, such as the portion of the screen memory corresponding to a particular window.
CHENNAI INSTITUTE OF TECHNOLOGY-2104 Page 64
Use of a system call to perform I/O.
The kernel maintains a number of important data structures pertaining to the I/O system, such as the open
file table. These structures are object-oriented, and flexible to allow access to a wide variety of I/O devices
through a common interface. (See Figure below.)Windows NT carries the object-orientation one step further,
implementing I/O as a message-passing system from the source through various intermediaries to the device.
The streams mechanism in UNIX provides a bi-directional pipeline between a user process and a device
Zero or more stream modules can be pushed onto the stream, using ioctl( ). These modules may filter
Flow control can be optionally supported, in which case each module will buffer data until the adjacent
module is ready to receive it. Without flow control, data is passed along as soon as it is ready.
User processes communicate with the stream head using either read( ) and write( ) ( or putmsg( ) and
getmsg( ) for message passing. )
Streams I/O is asynchronous (non-blocking), except for the interface between the user process and the
stream head.
The device driver must respond to interrupts from its device - If the adjacent module is not prepared to
accept data and the device driver's buffers are all full, and then data is typically dropped.
Streams are widely used in UNIX, and are the preferred approach for device drivers. For example, UNIX
implements sockets using streams.
Performance:
The I/O system is a major factor in overall system performance, and can place heavy loads on other
major components of the system (interrupt handling, process switching, memory access, bus
contention, and CPU load for device drivers just to name a few.)
Interrupt handling can be relatively expensive (slow), which causes programmed I/O to be faster
than interrupt-driven I/O when the time spent busy waiting is not excessive.
Network traffic can also put a heavy load on the system. Consider for example the sequence of events
that occur when a single character is typed in a telnet session, as shown in figure (And the fact that a
similar set of events must happen in reverse to echo back the character that was typed) Sun uses in-
kernel threads for the telnet daemon, increasing the supportable number of simultaneous telnet sessions
from the hundreds to the thousands.
Other systems use front-end processors to off-load some of the work of I/O processing from the CPU.
For example a terminal concentrator can multiplex with hundreds of terminals on a single port on a
large computer.
Several principles can be employed to increase the overall efficiency of I/O processing:
5. Move processing primitives into hardware, allowing their operation to be concurrent with CPU
and bus operations.
6. Balance CPU, memory, bus, and I/O operations, so a bottleneck in one does not idle all the others.
The development of new I/O algorithms often follows a progression from application level code to on-
board hardware implementation, as shown in Figure 13.16. Lower-level implementations are faster and
more efficient, but higher-level ones are more flexible and easier to modify. Hardware-level functionality
may also be harder for higher-level authorities ( e.g. the kernel ) to control.
Virtual Machine abstracts the hardware of our personal computer such as CPU, disk
drives, memory, NIC (Network Interface Card) etc, into many different execution
environments as per our requirements, hence giving us a feel that each execution environment
is a single computer. For example, VirtualBox.
When we run different processes on an operating system, it creates an illusion that
each process is running on a different processor having its own virtual memory, with the help
of CPU scheduling and virtual-memory techniques. There are additional features of a process
that cannot be provided by the hardware alone like system calls and a file system. The virtual
machine approach does not provide these additional functionalities but it only provides an
interface that is same as basic hardware. Each process is provided with a virtual copy of the
underlying computer system.
We can create a virtual machine for several reasons, all of which are fundamentally
related to the ability to share the same basic hardware yet can also support different execution
environments, i.e., different operating systems simultaneously.
The main drawback with the virtual-machine approach involves disk systems. Let us
suppose that the physical machine has only three disk drives but wants to support seven
virtual machines. Obviously, it cannot allocate a disk drive to each virtual machine, because
virtual-machine software itself will need substantial disk space to provide virtual memory
and spooling. The solution is to provide virtual disks.
Users are thus given their own virtual machines. After which they can run any of the
operating systems or software packages that are available on the underlying machine. The
virtual-machine software is concerned with multi-programming multiple virtual machines
onto a physical machine, but it does not need to consider any user-support software. This
arrangement can provide a useful way to divide the problem of designing a multi-user
interactive system, into two smaller pieces.
Advantages:
1. There are no protection problems because each virtual machine is completely isolated
from all other virtual machines.
2. Virtual machine can provide an instruction set architecture that differs from real
computers.
3. Easy maintenance, availability and convenient recovery.
Disadvantages:
1. When multiple virtual machines are simultaneously running on a host computer, one
virtual machine can be affected by other running virtual machines, depending on the
workload.
2. Virtual machines are not as efficient as a real one when accessing the hardware.
HISTORY
Both system virtual machines and process virtual machines date to the 1960s and
continue to be areas of active development.
System virtual machines grew out of time-sharing, as notably implemented in the Compatible
Time-Sharing System (CTSS). Time-sharing allowed multiple users to use a
computer concurrently: each program appeared to have full access to the machine, but only one
program was executed at the time, with the system switching between programs in time slices,
saving and restoring state each time. This evolved into virtual machines, notably via IBM's
research systems: the M44/44X, which used partial virtualization, and the CP-
40 and SIMMON, which used full virtualization, and were early examples of hypervisors. The
first widely available virtual machine architecture was the CP-67/CMS (see History of
CP/CMS for details). An important distinction was between using multiple virtual machines
on one host system for time-sharing, as in M44/44X and CP-40, and using one virtual machine
on a host system for prototyping, as in SIMMON. Emulators, with hardware emulation of
earlier systems for compatibility, date back to the IBM System/360 in 1963,[6][7] while the
software emulation (then-called "simulation") predates it.
Process virtual machines arose originally as abstract platforms for an intermediate
language used as the intermediate representation of a program by a compiler; early examples
date to around 1966. An early 1966 example was the O-code machine, a virtual machine that
executes O-code (object code) emitted by the front end of the BCPL compiler. This abstraction
allowed the compiler to be easily ported to a new architecture by implementing a new back
end that took the existing O-code and compiled it to machine code for the underlying physical
machine. The Euler language used a similar design, with the intermediate language
named P (portable).[8] This was popularized around 1970 by Pascal, notably in the Pascal-
P system (1973) and Pascal-S compiler (1975), in which it was termed p-code and the resulting
machine as a p-code machine.
This has been influential, and virtual machines in this sense have been often generally
called p-code machines. In addition to being an intermediate language, Pascal p-code was also
executed directly by an interpreter implementing the virtual machine, notably in UCSD
Pascal (1978); this influenced later interpreters, notably the Java virtual machine (JVM).
Another early example was SNOBOL4 (1967), which was written in the SNOBOL
Implementation Language (SIL), an assembly language for a virtual machine, which was then
targeted to physical machines by transpiling to their native assembler via a macro
assembler.[9] Macros have since fallen out of favor, however, so this approach has been less
influential. Process virtual machines were a popular approach to implementing early
microcomputer software, including Tiny BASIC and adventure games, from one-off
implementations such as Pyramid 2000 to a general-purpose engine like Infocom's z-machine,
which Graham Nelson argues is "possibly the most portable virtual machine ever created".
Significant advances occurred in the implementation of Smalltalk-80, particularly the
Deutsch/Schiffmann implementation which pushed just-in-time (JIT) compilation forward as
an implementation approach that uses process virtual machine. Later notable Smalltalk VMs
were VisualWorks, the Squeak Virtual Machine, and Strongtalk. A related language that
produced a lot of virtual machine innovation was the Self programming language, which
pioneered adaptive optimization[17] and generational garbage collection. These techniques
proved commercially successful in 1999 in the HotSpot Java virtual machine.[18] Other
innovations include having a register-based virtual machine, to better match the underlying
hardware, rather than a stack-based virtual machine, which is a closer match for the
programming language; in 1995, this was pioneered by the Dis virtual machine for
the Limbo language. OpenJ9 is an alternative for HotSpot JVM in OpenJDK and is an open
source eclipse project claiming better startup and less resource consumption compared to
HotSpot.
FEATURES OF VIRTUAL MACHINES
The features of the virtual machines are as follows −
Multiple OS systems use the same hardware and partition resources between virtual
computers.
Separate Security and configuration identity.
Ability to move the virtual computers between the physical host computers as
holistically integrated files.
The below diagram shows you the difference between the single OS with no VM and Multiple
OS with VM −
BENEFITS
Let us see the major benefits of virtual machines for operating-system designers and users
which are as follows −
The multiple Operating system environments exist simultaneously on the same
machine, which is isolated from each other.
Virtual machine offers an instruction set architecture which differs from real computer.
Using virtual machines, there is easy maintenance, application provisioning, availability
and convenient recovery.
Virtual Machine encourages the users to go beyond the limitations of hardware to achieve their
goals.
The operating system achieves virtualization with the help of a specialized software called a
hypervisor, which emulates the PC client or server CPU, memory, hard disk, network and
other hardware resources completely, enabling virtual machines to share resources.
The hypervisor can emulate multiple virtual hardware platforms that are isolated from each
other allowing virtual machines to run Linux and window server operating machines on the
same underlying physical host.
VIRTUAL BUILDING BLOCKS
Storage Design
This reference architecture uses a shared storage design that is based on vSAN. vCloud NFV
also supports certified third-party shared storage solutions, as listed in the VMware
Compatibility Guide.
vSAN is a software feature built in the ESXi hypervisor that allows locally attached storage to
be pooled and presented as a shared storage pool for all hosts in a vSphere cluster. This
simplifies the storage configuration with a single datastore per cluster for management and
VNF workloads. With vSAN, VM data is stored as objects and components. One object
consists of multiple components, which are distributed across the vSAN cluster based on the
policy that is assigned to the object. The policy for the object ensures a highly available storage
backend for the cluster workload, with no single point of failure.
vSAN is a fully integrated hyperconverged storage software. Creating a cluster of server hard
disk drives (HDDs) and solid-state drives (SSDs), vSAN presents a flash-optimized, highly
resilient, shared storage datastore to ESXi hosts and virtual machines. This allows for the
control of capacity, performance, and availability through storage policies, on a per VM basis.
Network Design
The hosts in each Pod are configured with VMware vSphere ® Distributed Switch™
(VDS) devices that provide consistent network configuration across multiple hosts. One
vSphere Distributed Switch is used for VM networks and the other one maintains the
infrastructure networks. Also, the N-VDS switch is used as the transport for telco workload
traffic.
Infrastructure networks are used by the ESXi hypervisor for vMotion, VMware vSphere
Replication, vSAN traffic, and management and backup. The Virtual Machine networks are
used by VMs to communicate with each other. For each Pod, the separation between
infrastructure and VM networks ensures security and provides network resources where
needed. This separation is implemented by two vSphere Distributed Switches, one for
infrastructure networks and another one for VM networks. Each distributed switch has separate
uplink connectivity to the physical data center network, completely separating its traffic from
other network traffic. The uplinks are mapped to a pair of physical NICs on each ESXi host,
for optimal performance and resiliency.
VMs can be connected to each other over a VLAN or over Geneve-based overlay
tunnels. Both networks are designed according to the requirements of the workloads that are
hosted by a specific Pod. The infrastructure vSphere Distributed Switch and networks remain
the same regardless of the Pod function. However, the VM networks depend on the networks
that the specific Pod requires. The VM networks are created by NSX-T Data Center to provide
enhanced networking services and performance to the Pod workloads. The ESXi host's physical
NICs are used as uplinks to connect the distributed switches to the physical network switches.
All ESXi physical NICs connect to layer 2 or layer 3 managed switches on the physical
network. It is common to use two switches for connecting to the host physical NICs for
redundancy purposes.
Virtual Machine is like fake computer system operating on your hardware. It partially
uses the hardware of your system (like CPU, RAM, disk space, etc.) but its space is
completely separated from your main system. Two virtual machines don’t interrupt in
each other’s working and functioning nor they can access each other’s space which gives
an illusion that we are using totally different hardware system. More detail at Virtual
Machine.
Types of Virtual Machines : Virtual machines are classified into two types:
2. Process Virtual Machine : While process virtual machines, unlike system virtual
machine, does not provide us with the facility to install the virtual operating system
completely. Rather it creates virtual environment of that OS while using some app or program
and this environment will be destroyed as soon as we exit from that app. Like in below image,
there are some apps running on main OS as well some virtual machines are created to run
other apps. This shows that as those programs required different OS, process virtual machine
provided them with that for the time being those programs are running. Example – Wine
software in Linux helps to run Windows applications.
Virtual Machine Language : It’s type of language which can be understood by different
operating systems. It is platform-independent. Just like to run any programming language (C,
python, or java) we need specific compiler that actually converts that code into system
understandable co Types of VMs –Types of VMs – Type 0 Hypervisor0 Hy to
uOld idea, under many names by HW manufacturers
e “partitions”,“domains”
A HW feature implemented by irfmware
OS need to nothing special, VMM is in irfmware
Smaller feature set than other t ypes
Each guest has dedicated HW
I/O a challenge as difficul to have enough devices, controlers to dedicate to each guest
Sometimes VMM implements a control partition running daemons that other guests
communicate with for shared I/O
Can provide virtualization-within-virtualization(guest itself can be a VMM with guests
Other types have difficulty in doing this.s
● CPU scheduling, memory management, I/O, storage, and unique VM migration feature
◗ How do VMM sschedule CPU use when guests believe they have dedicated CPUs?
● Generally VMM has one or more physical CPUs and number of threads to run on
them.
● Guests configured with certain number of VCPUs
◗ Can be adjusted throughout life of VM
When enough CPUs for all guests->VMM can allocate dedicated CPUs, each guest much like
native operating system managing its CPUs
Cycle stealing by VMM and oversubscription of CPUs means guests don’t get CPU cycles
they expect.
1 Establish
The virtual infrastructure design comprises the design of the software components that form
the virtual infrastructure layer. This layer supports running telco workloads and workloads that
maintain the business continuity of services. The virtual infrastructure components include the
virtualization platform hypervisor, virtualization management, storage virtualization, network
virtualization, and backup and disaster recovery components.
This section outlines the building blocks for the virtual infrastructure, their components, and
the networking to tie all the components together.
A mobile operating system is an operating system that helps to run other application software
on mobile devices. It is the same kind of software as the famous computer operating systems
like Linux and Windows, but now they are light and simple to some extent.
The operating systems found on smartphones include Symbian OS, iPhone OS, RIM's
BlackBerry, Windows Mobile, Palm WebOS, Android, and Maemo. Android, WebOS, and
Maemo are all derived from Linux. The iPhone OS originated from BSD and NeXTSTEP,
which are related to Unix.
It combines the beauty of computer and hand use devices. It typically contains a cellular built-
in modem and SIM tray for telephony and internet connections. If you buy a mobile, the
manufacturer company chooses the OS for that specific device.
1. Android OS: The Android operating system is the most popular operating system today. It
is a mobile OS based on the Linux Kernel and open-source software. The android operating
system was developed by Google. The first Android device was launched in 2008.
2. Bada (Samsung Electronics): Bada is a Samsung mobile operating system that was
launched in 2010. The Samsung wave was the first mobile to use the bada operating system.
The bada operating system offers many mobile features, such as 3-D graphics, application
installation, and multipoint-touch.
3. BlackBerry OS: The BlackBerry operating system is a mobile operating system developed
by Research In Motion (RIM). This operating system was designed specifically for
BlackBerry handheld devices. This operating system is beneficial for the corporate users
because it provides synchronization with Microsoft Exchange, Novell GroupWise email, Lotus
Domino, and other business software when used with the BlackBerry Enterprise Server.
4. iPhone OS / iOS: The iOS was developed by the Apple inc for the use on its device. The
iOS operating system is the most popular operating system today. It is a very secure operating
system. The iOS operating system is not available for any other mobiles.
5. Symbian OS: Symbian operating system is a mobile operating system that provides a high-
level of integration with communication. The Symbian operating system is based on the java
language. It combines middleware of wireless communications and personal information
management (PIM) functionality. The Symbian operating system was developed by Symbian
Ltd in 1998 for the use of mobile phones. Nokia was the first company to release Symbian OS
on its mobile phone at that time.
6. Windows Mobile OS: The window mobile OS is a mobile operating system that was
developed by Microsoft. It was designed for the pocket PCs and smart mobiles.
7. Harmony OS: The harmony operating system is the latest mobile operating system that was
developed by Huawei for the use of its devices. It is designed primarily for IoT devices.
8. Palm OS: The palm operating system is a mobile operating system that was developed
by Palm Ltd for use on personal digital assistants (PADs). It was introduced in 1996. Palm OS
is also known as the Garnet OS.
9. WebOS (Palm/HP): The WebOS is a mobile operating system that was developed by Palm.
It based on the Linux Kernel. The HP uses this operating system in its mobile and touchpads.
Apple iOS is a proprietary mobile operating system that runs on mobile devices such
as the iPhone and iPad. Apple iOS stands for iPhone operating system and is designed for use
with Apple's multitouch devices. The mobile OS supports input through direct manipulation
and responds to various user gestures, such as pinching, tapping and swiping. The iOS
developer kit provides tools that allow for iOS app development.
As of 2022, the Apple iOS market share was 18.8% worldwide, making it the second most
popular brand behind Samsung, according to IDC.
As of 2019, the Apple iOS market share was 13.4% worldwide, making it the second most
popular mobile OS behind Google Android, according to IDC.
Integrated search support, which enables simultaneous search through files, media,
applications and email.
Gesture recognition supports -- for example, shaking the device to undo the most recent
action.
Push email.
Direct access to the Apple App Store and the iTunes catalog of music, podcasts, television
shows and movies available to rent or purchase. iOS is also designed to work with Apple
TV.
Siri is Apple's virtual assistant that can set reminders, offer suggestions or interact with
certain third-party apps. Siri's voice has been modified recently to make it sound more
natural.
Support for Apple Watch, runs watchOS 9 but requires iPhone 8 or later running iOS 16 or
later.
Apple Pay, which stores users' credit card data and allows them to pay for goods and
services directly with an iOS device.
CarPlay allows users to interact with an iOS device while driving. CarPlay supports Siri
voice controls, and users can access apps through a connected vehicle's touchscreen.
CarPlay provides access to maps, phone, calendar, messaging, and music apps.
The HomePod feature allows Siri to identify family members by voice, giving everyone a
personalized experience. HomePod's handoff feature allows users to hand off music,
podcasts and phone calls so that they can listen on another device.
HomeKit allows iOS to be used as a tool for controlling home automation. HomeKit
accessories include routers, lights, security cameras and more. The Home app allows you
to control these devices from iOS.
Apple ID support. Users can sign into websites and apps using their existing Apple ID.
Additionally, iOS supports signing in using Face ID or Touch ID, which use biometric
authentication methods. Apple IDs are protected with two-factor authentication.
Privacy and security. iOS supports fine-grained controls that prevent apps from gaining
location information or accepting AirDrop content from unknown senders. Apps can also
be blocked from using Wi-Fi or Bluetooth without users' permission. Additionally, iOS
devices use a secure boot chain to ensure that only trusted (signed) code is executed during
the boot process. This allows iOS devices to verify the integrity of any code running on the
device.
Apple iOS was originally known as iPhone OS. The company released three versions of the
mobile OS under that name before iOS 4 debuted in June 2010. Apple released iOS 2 on July
11, 2008. It premiered alongside Apple's iPhone 3G. This operating system was followed on
June 17, 2009 by iOS 3. The fourth version of iOS was released on June 21, 2010, along with
the iPhone 4.
On Oct. 12, 2011, Apple released iOS 5, which expanded the number of available applications
to over 500,000. This iOS version also added the Notification Center, a camera app, Siri and
more.Unveiled on June 11, 2012, iOS 6 included a Maps application and the Passbook ticket
storage and loyalty program application.
Released on Sept. 18, 2013, iOS 7 featured an entirely redesigned user interface. In September
2014, iOS 8 introduced Continuity, a cross-platform system that allows users of multiple Apple
devices to pick up on one where they left off from another. Other new features included the
Photos app and Apple Music.
Android is a mobile operating system based on a modified version of the Linux kernel and
other open-source software, designed primarily for touchscreen mobile devices such as
smartphones and tablets. Android is developed by a partnership of developers known as the
Open Handset Alliance and commercially sponsored by Google. It was disclosed in November
2007, with the first commercial Android device, the HTC Dream, launched in September 2008.
It is free and open-source software. Its source code is Android Open Source Project (AOSP),
primarily licensed under the Apache License. However, most Android devices dispatch with
additional proprietary software pre-installed, mainly Google Mobile Services (GMS),
including core apps such as Google Chrome, the digital distribution platform Google Play and
the associated Google Play Services development platform.
o About 70% of Android Smartphone runs Google's ecosystem, some with vendor-
customized user interface and some with software suite, such as TouchWizand
later One UI by Samsung, and HTC Sense.
o Competing Android ecosystems and forksinclude Fire OS (developed by Amazon) or
LineageOS. However, the "Android" name and logo are trademarks of Google which
impose standards to restrict "uncertified" devices outside their ecosystem to use android
branding.
Below are the following unique features and characteristics of the android operating
system, such as:
Most Android devices support NFC, which allows electronic devices to interact across short
distances easily. The main goal here is to create a payment option that is simpler than carrying
cash or credit cards, and while the market hasn't exploded as many experts had predicted, there
may be an alternative in the works, in the form of Bluetooth Low Energy (BLE).
2. Infrared Transmission
The Android operating system supports a built-in infrared transmitter that allows you to use
your phone or tablet as a remote control.
3. Automation
The Tasker app allows control of app permissions and also automates them.
You can download apps on your PC by using the Android Market or third-party options
like AppBrain. Then it automatically syncs them to your Droid, and no plugging is required.
Android phones also have unique hardware capabilities. Google's OS makes it possible to
upgrade, replace, and remove your battery that no longer holds a charge. In addition, Android
phones come with SD card slots for expandable storage.
While it's possible to hack certain phones to customize the home screen, Android comes with
this capability from the get-go. Download a third-party launcher like Apex, Nova, and you can
add gestures, new shortcuts, or even performance enhancements for older-model devices.
7. Widgets
Apps are versatile, but sometimes you want information at a glance instead of having to open
an app and wait for it to load. Android widgets let you display just about any feature you choose
on the home screen, including weather apps, music widgets, or productivity tools that helpfully
remind you of upcoming meetings or approaching deadlines.
8. Custom ROMs
Because the Android operating system is open-source, developers can twist the current OS and
build their versions, which users can download and install in place of the stock OS. Some are
filled with features, while others change the look and feel of a device. Chances are, if there's a
feature you want, someone has already built a custom ROM for it.
Architecture of Android OS
The android architecture contains a different number of components to support any android
device needs. Android software contains an open-source Linux Kernel with many C/C++
libraries exposed through application framework services.
Among all the components, Linux Kernel provides the main operating system functions to
Smartphone and Dalvik Virtual Machine (DVM) to provide a platform for running an android
application. An android operating system is a stack of software components roughly divided
into five sections and four main layers, as shown in the below architecture diagram.
o Applications
o Application Framework
o Android Runtime
o Platform Libraries
o Linux Kernel
1. Applications
An application is the top layer of the android architecture. The pre-installed applications like
camera, gallery, home, contacts, etc., and third-party applications downloaded from the play
store like games, chat applications, etc., will be installed on this layer.
It runs within the Android run time with the help of the classes and services provided by the
application framework.
2. Application framework
It includes different types of services, such as activity manager, notification manager, view
system, package manager etc., which are helpful for the development of our application
according to the prerequisite.
The Application Framework layer provides many higher-level services to applications in the
form of Java classes. Application developers are allowed to make use of these services in their
applications. The Android framework includes the following key services:
o Activity Manager: Controls all aspects of the application lifecycle and activity stack.
o Content Providers: Allows applications to publish and share data with other
applications.
o Resource Manager: Provides access to non-code embedded resources such as strings,
colour settings and user interface layouts.
o Notifications Manager: Allows applications to display alerts and notifications to the
user.
o View System: An extensible set of views used to create application user interfaces.
3. Application runtime
Android Runtime environment contains components like core libraries and the Dalvik virtual
machine (DVM). It provides the base for the application framework and powers our application
with the help of the core libraries.
Like Java Virtual Machine (JVM), Dalvik Virtual Machine (DVM) is a register-based virtual
machine designed and optimized for Android to ensure that a device can run multiple instances
efficiently.
It depends on the layer Linux kernel for threading and low-level memory management. The
core libraries enable us to implement android applications using the
standard JAVA or Kotlin programming languages.
4. Platform libraries
The Platform Libraries include various C/C++ core libraries and Java-based libraries such as
Media, Graphics, Surface Manager, OpenGL, etc., to support Android development.
o app: Provides access to the application model and is the cornerstone of all Android
applications.
o content: Facilitates content access, publishing and messaging between applications and
application components.
o database: Used to access data published by content providers and includes SQLite
database, management classes.
o OpenGL: A Java interface to the OpenGL ES 3D graphics rendering API.
o os: Provides applications with access to standard operating system services, including
messages, system services and inter-process communication.
o text: Used to render and manipulate text on a device display.
o view: The fundamental building blocks of application user interfaces.
o widget: A rich collection of pre-built user interface components such as buttons, labels,
list views, layout managers, radio buttons etc.
o WebKit: A set of classes intended to allow web-browsing capabilities to be built into
applications.
o media: Media library provides support to play and record an audio and video format.
o surface manager: It is responsible for managing access to the display subsystem.
o SQLite: It provides database support, and FreeType provides font support.
o SSL: Secure Sockets Layer is a security technology to establish an encrypted link
between a web server and a web browser.
5. Linux Kernel
Linux Kernel is the heart of the android architecture. It manages all the available drivers such
as display, camera, Bluetooth, audio, memory, etc., required during the runtime.
The Linux Kernel will provide an abstraction layer between the device hardware and the other
android architecture components. It is responsible for the management of memory, power,
devices etc. The features of the Linux kernel are:
o Security: The Linux kernel handles the security between the application and the
system.
o Memory Management: It efficiently handles memory management, thereby providing
the freedom to develop our apps.
o Process Management: It manages the process well, allocates resources to processes
whenever they need them.
o Network Stack: It effectively handles network communication.
o Driver Model: It ensures that the application works properly on the device and
hardware manufacturers responsible for building their drivers into the Linux build.
Android Applications
Android applications are usually developed in the Java language using the Android Software
Development Kit. Once developed, Android applications can be packaged easily and sold out
either through a store such as Google Play, SlideME, Opera Mobile Store, Mobango, F-
droid or the Amazon Appstore.
Android powers hundreds of millions of mobile devices in more than 190 countries around the
world. It's the largest installed base of any mobile platform and growing fast. Every day more
than 1 million new Android devices are activated worldwide.
Android Emulator
The Emulator is a new application in the Android operating system. The Emulator is a new
prototype used to develop and test android applications without using any physical device.
The android emulator has all of the hardware and software features like mobile devices except
phone calls. It provides a variety of navigation and control keys. It also provides a screen to
display your application. The emulators utilize the android virtual device configurations. Once
your application is running on it, it can use services of the android platform to help other
applications, access the network, play audio, video, store, and retrieve the data.
We considered every one of the elements on which Android is better as thought about than
different platforms. Below are some important advantages of Android OS, such as:
We know that the Android operating system has a considerable measure of interest for users
nowadays. But at the same time, it most likely has a few weaknesses. Below are the following
disadvantages of the android operating system, such as: