UNIT1
UNIT1
(AUTONOMOUS)
An ISO 9001:2015 and ISO 14001:2015 Certified Institution
Affiliated to Anna University, Chennai, Approved by AICTE, New Delhi &
Recognized by UGC with 2(f) & 12(B), Re-accredited by NAAC with A+
NBA Accredited UG Courses: AERO | CSE | ECE | EEE | MECH | MCT
Nehru Gardens, T. M. Palayam, Coimbatore - 641 105.
UNIT I INTRODUCTION
Computer System – Elements and organization; Operating System Overview – Objectives and
Functions – Evolution of Operating System; Operating System Structures – Operating System
Services – User Operating System Interface – System Calls – System Programs – Design and
Implementation–Structuring methods.
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
Normal DMA Data Transfer
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
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.