0% found this document useful (0 votes)
9 views

M1

OS module 1 VTU BCS302

Uploaded by

abhinavhs3124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

M1

OS module 1 VTU BCS302

Uploaded by

abhinavhs3124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Operating System

OPERATING SYSTEM
UNIT 1: INTRODUCTION
Operating system is an intermediary between the user and hardware.
Eg: Windows, Mac OSx, Linux, Android, Novell Network OS, Sun OS
When I say an operating system, it can be found in microwave, vacuum cleaner, Calculator etc but
each of these have their own feature and a way of operating with/without user interaction.
The goals of an operating system is

 To execute the user programs, to make problem solving much easier.


 Make the computer usage convenient for a user.
 To use computer hardware in an efficient manner.
The computer system can be divided into 4 components:

 Hardware: Provides basic computing resources like CPU, Memory, I/O Devices
 Operating System: controls and co-ordinates the hardware among the applications and
users
 Application Programs: The user programs to do specific tasks like word, video games, photo
editor, web browsers etc
 Users: People, machines and other computers

Fig 1: Abstraction of components of operating system


User View:
Operating System

 A person who uses the personal computer, monopolizes the resources of the single system.
The goal is to maximize the work he is performing, in this case the operating system must
be designed for ease of use for user with some importance given to the performance and no
importance for resource allocation.
 A user who sits at a dummy terminal connected to a mainframe or minicomputer will be
sharing the resources with other users who using the same mainframe via another dummy
terminal. In this case the resource utilization should be properly maximized by the
operating system.
 A user who works on a workstation connected to a networks of other workstations and
servers, these users have dedicated resources at their disposal but still they share some of
the networking and servers- file, compute and print servers. So operating system is
designed to compromise between individual usability and resource utilization.
 Recently, many varieties of handheld devices have come to use which are standalone units
for individual users, some connected to network either wired or wireless. Because of power,
speed and interface limitations, they perform less operations. Here operating system is
designed for individual usability and performance per battery life.
 Some of the embedded computer systems does not have user interaction like automobiles,
microwave oven etc. These operating systems are designed primarily to run without user
intervention.
System View:

 OS also works as a resource allocator:


Suppose phone rings and you pick up a call, at the same time some other important work is
interrupted, you need to decide which work to be done between these 2. Either you attend the call or
you will ask the other person to call you back a moment later. This is nothing but managing of time
where at the same point of time you need to do more than 1 work.
Similarly an operating system must manage the resource of a computer system in a fair and
efficient manner to all the devices in a computer

 OS also works as a control program:


It controls the execution of programs to prevent any errors from occurring and also to avoid
improper use of computer.
There is no universal definition of OS. It is a collection of programs to form a software. But there is 1
thing in common in all OS.
“The one program that runs all the time in a computer is called a KERNEL”. Any other program is
either a system program or application program.

Computer Start Up:


When a computer is switched on, the first program to run is BOOTSTRAP program. It is stored in
ROM or EEPROM, generally called as Firmware.
Operating System
Bootstrap program initializes all the memories, registers, device controllers. When a system is start
up the bootstrap program must be able to locate and load the operating system kernel. When this
kernel is loaded, the process called as ‘init’ is started which inturn starts the operating system.

Operating System

User programs
1
2
3
4
.
.
.
.
.
n
Fig 2: Main memory Usage
As shown in Fig 2, the operating system uses 1/4th of the main memory which is stored during
system start up. The user programs occupy the remaining 3/4th of the main memory for the
program executions. Normally the user program block is equally divided into ‘n’ number of blocks
such that ‘n’ number of user programs can be executed simultaneously.

Computer System Operation:


As shown in the Fig 3, one or more CPU’s, number of device controllers are interconnected by a
common bus to a shared memory. Each device controller is in charge of a specific type of device.
CPU and device controllers execute operations concurrently competing for memory cycles. To
synchronize the access of memory, a memory controller is being used.
Each device controller has a local buffer. The CPU can move the data from/to the main memory
to/from the local buffer. During these operations of moving the data, to inform about the
completion of work, the device controllers sends an interrupt to the CPU.
Operating System

Fig 3: Modern Computer System


When an interrupt occurs, the instruction which is being executed is paused thereby storing its
registers, program counter in a stack and the interrupt is being handled on the basis of interrupt
vector table. The interrupt vector table will have information about the interrupt and the interrupt
will be executed using Interrupt Service Routine to be used for a particular interrupt. When an
interrupt is already being served, the incoming interrupts are disabled to prevent lost interrupt.
Once the interrupt is handled, the control is returned back to the same instruction and its execution
resumes.

Fig 4: Working of Interrupts


In Fig 4, we have user mode, kernel mode and the hardware. The user mode will send soft
interrupts by using system call to kernel to do some work. The kernel will check for the type of
work to be done and corresponding message is sent to the hardware. The hardware once it finishes
its work, it will send an interrupt to kernel which will passed as a signal to the user mode.

Storage Structure:
The memory is divided into main memory and secondary memory. For a computer program to
execute the program must be in main memory. The main memory is the only large storage area
which a processor can access directly. Recently, main memory is implemented in a semiconductor
technology called dynamic random-access memory (DRAM), which forms an array of memory
words. Each word has a specific address.
Operating System
Interaction between the processor and main memory is achieved through a sequence of load and
store instructions to specific memory addresses.
The load instruction moves a word from main memory to internal register within a CPU, whereas
the store instruction moves the content of register to main memory. Apart from this, the CPU can
automatically load from main memory for execution.
A typical instruction-execution cycle is executed on a system with a von Neumann architecture:

 Fetches the instruction from memory and stores that in instruction register.
 The instruction is decoded and some of the operands may be fetched from memory and
stored in internal register of the CPU.
 After the instructions on the operands has been executed, the result will be stored back in
the memory.
Ideally we want the data and instruction to be stored in main memory permanently. But this is not
possible as:

 Main memory is usually too small to store all the needed programs and data permanently.
 Main memory is volatile, it loses its contents when the power is turned off.
Thus most of the computer systems provide secondary storage as an extension of main memory.
Various secondary storage devices are electronic disk (HDD), magnetic disk, optical disk, magnetic
tapes, flash memory.
Most of the programs are stored on these disks until they are loaded onto the memory.Many
programs use these disks as both source and destination of the information for their processing.
Storage systems provide the basic functionality of storing the data and holding them until it is
retrieved at a later time. But the main differences among the various storage systems lies in speed,
cost, size and volatility.
According to the speed and cost, the higher levels of the hierarchy are expensive but faster in
execution, whereas the access time increases as we move down and also the devices in lower levels
are less expensive.
Operating System

Fig 5: Storage device hierarchy


In addition to differing in terms of speed and cost, storage systems also may be volatile storage or
non-volatile storage.

 Volatile storage loses the memory when the power is turned off.
 Non-volatile storage does not lose the memory even when power is turned off.
 In the hierarchy, electronic disks (HDD) can be either volatile or non-volatile.
o During normal operation, the data is stored in large DRAM array, which is volatile.
o Some electronic disk devices contain a hidden magnetic hard disk and a battery for
backup power.
o If the power is interrupted, the electronic disk controller copies the data from RAM
to the magnetic hard disk.
o When the power comes back the data is copied back to the RAM.

Direct Memory Access:

Fig 6: DMA Structure


Operating System
As shown in the Fig 6, the CPU sends and I/O request for a device controller to start its work, the
device controller stores its data in its buffer, once the required data is fetched from the user it sends
an interrupt to CPU. On receiving an interrupt the CPU copies its data from the device controller
buffer to the main memory by executing instruction execution cycle with the memory and the
instructions are executed with the required data.
This process works fine when the data to be moved is small, but for large amount of data, the CPU
will be overhead as multiple blocks to be copied from device buffer to main memory. To overcome
this the device uses a technique called as Direct memory access where the device directly sends the
data to memory and only the status is being given to CPU for every block of data transferred.
Computer System Architecture:
Computer can be categorized roughly on the basis of number of general purpose processors used;
Single Processor Systems:

 One CPU is used which executes both general purpose instruction set including instructions
from user processes.
 Also consists of special purpose processors in the form of device specific processors such as
disk, keyboard, and graphics controllers or on mainframes in form of general purpose
processors such as I/O processors.
 Special purpose processors run limited set of instructions and do not run user processes.
 Operating systems sends the information about their next task and monitor its status. For
eg, disk controller microprocessor receives a sequence of requests from main CPU and
implements its own disk queue and scheduling algorithm.
 Keyboard microprocessors used to convert keystrokes into codes to be sent to CPU.
Multiprocessor Systems:

 These systems have 2 or more processors working in close communication, sharing


computer bus, memory, clock and peripheral devices.
 Advantages
o Increased Throughput:More number of processors leads to more work done in less
time. If N processors are used then time taken is less than N due to overhead in
keeping all parts working properly.
o Economy of Scale: Costs less than equivalent multiple single processors because they
can share peripherals, mass storage and power supplies.
o Increased Reliability: If functions can be distributed among various processors, then
failure of one processor will not halt the system, only slows it down, the other
processors share and takes control over the work done by the failed processor.
 The ability to provide service proportional to the surviving hardware is called graceful
degradation, some systems go beyond this and are called fault tolerant.
 Fault tolerant requires a mechanism to allow the failure to be detected, diagnosed and
possibly corrected.
o HP Nonstop system consists of multiple pairs of CPU, working in lockstep. Both
processors execute the instruction and compare the result, if different then 1 CPU is
at fault and both are halted. The process is moved another pair and instructions are
restarted.
Operating System

 Multiple processing systems are of 2 types – Asymmetric multiprocessing and Symmetric


multiprocessing
o Asymmetric processing is one where master slave concept is used. Master processor
controls the system; other processors look to master for instruction or execute its
pre-defined tasks. Master processor schedules and allocates work to slave
processor.
o Symmetric processing is one where each processor performs all the tasks within the
operating system.

Fig 7: Symmetric Multiprocessing Architecture


 Fig 7 Consists of N number of processors which registers and local cache but
with shared physical memory. Eg Solaris  many process can run
simultaneously in N processors
 Allows processes and resources to be allocated dynamically among the
processors.
 Recent trend in CPU design is to include multiple computing cores in a single
ship. These are more efficient as on chip communication is faster than
between chip communication and also it uses less power for computation.

Fig 8: Dual core design


 As shown in the Fig 8, each core has its own register and cache; other
designs may use shared cache or combination of local and shared cache.
Clustered Systems:

 Clustered system gathers together multiple CPU’s. However they are composed of 2 or more
individual systems joined together via network.
Operating System

 Clustering provides High availability service; that the service will continue even when one
or more systems in a cluster fail.
 A layer of cluster software runs on the cluster nodes. Each nodes can monitor one or more
nodes over LAN. If the monitored node fails then the monitoring node takes the ownership
and executes the applications that were running on the failed machine.
 Clustering can be structured into Asymmetric clustering and Symmetric clustering
o In asymmetric clustering one node will be in hot standby mode while the other is
running the applications. Hot standby node monitors the active server only, if server
fails then hot standby node becomes active server.
o In symmetric clustering, 2 or more nodes are running applications and are
monitoring each other.
 Cluster provides high performance computing environment which can provide significantly
greater computational power than single processor or SMP because they are capable of
running an application concurrently on all computers in a cluster.
 Applications can use the concept of parallelization. Parallelization is a technique where
program is divided into separate components and are executed parallel on individual
computers in a cluster.
Operating System Structure:
One of the important aspect of operating systems is multiprogramming. A single program cannot
keep the CPU or I/O devices busy all the time. Multiprogramming increases CPU utilization by
organizing jobs so that CPU always has one to execute.

 Operating system keeps several jobson disk in a job pool as main memory is too small to
accommodate all jobs. This pool consists of all processes waiting for allocation on main
memory.
 One job is selected and executed called as job scheduling. Ifa job has to wait for some other
operations to finish its own work then the operating system switches to other jobs by
selecting from job pool.
 Job scheduling is a process of bringing a job from the job pool to main memory.
 A program loaded into memory for execution is called as process.
 Processes is switched if has to wait for I/O operations for its work and I/O is busy in other
process work.
Time sharing is logical extension of multiprogramming which can be used in an interactive
environment where the jobs are being switched so frequently that the users can interact with each
program while it is running.

 Time shared operating system uses CPU scheduling and multiprogramming to provide each
user with a small portion of time shared computer i.e each user will have at least 1 separate
program in memory
 The user gives instruction from the keyboard and waits for immediate results on output
device. The response time should be short i.e less than 1 second.
 Time shared operating system allows many users to share the system simultaneously as it
switches from one process to another at rapid speed.
Operating System

 Each user is given a time share and Time shared operating system switches among them by
providing service without interruption creating an illusion to user that only he is using the
entire system.
 CPU scheduling is a selection of jobs to be executed where several jobs are ready to run at
the same time.
Operating System Operations:
The operating system is interrupt driven. A trap is a software interrupt caused either by an error or
a specific request from the user program for an operating system service to be performed.
If there is an error in user program then that error must cause problem to only one program in
running but not all the other programs. For eg,if a process gets struck in an infinite loop, this loop
can prevent correct operations of many other processes.
To overcome these problems 2 techniques are used. They are Dual mode operation and Timer.
Dual Mode Operation:In order to ensure proper operation of the operating system, we must be able
to distinguish between the execution of operating system code and user defined code.
At least 2 modes are required: user mode and kernel mode. A bit called mode bit is added to
hardware of computer to indicate the current mode: kernel(0) or user(1).

Fig 9: Transition from user mode to kernel mode


At the system boot time, the hardware starts in kernel mode. The operating system is then loaded
and starts user applications in user mode. Whenever a trap occurs, the hardware switches from
user mode to kernel mode. The system always switches to user mode by changing mode bit to 1
before handing control to user program.
Dual mode operation provides a means of protecting the operating system from errant users. Some
of the machine instructions are designated as privileged instructions which can be executed only in
kernel mode otherwise the errant user may cause harm to operating system by these machine
instructions.
Timer: Timer is being used to prevent user program to get stuck in infinite loop or if it fails to call
system services and never return control to operating system.
Operating System
A timer is set to interrupt the computer after some time period which may be fixed or variable. The
operating system sets the counter. Every time the clock ticks, the counter is decremented. When the
clock becomes 0, an interrupt occurs.
Process Management:

 A process uses resources like CPU, memory, files and I/O devices for execution.
 Logical and physical memory is also being used along with data transfer from I/O devices.
 Once the process execution is completed, the operating system takes back the resources
provided earlier to process.
 If a single threaded process is executing, then only 1 program counter is used where next
instruction is stored for execution.
 If multiple threaded processes are used then multiple program counters are used for same
purpose.
 The function of operating system in process management is
o Scheduling processes and threads for execution
o Creating and deleting user and system processes.
o Suspending and resuming processes.
o Providing mechanisms for process synchronization
o Providing mechanisms for process communication

Memory Management:
 CPU reads the instruction from the main memory by using instruction fetch cycle
 CPU reads and writes the data to/from memory by data fetch cycle.
 When a process is loaded into memory it must done along with absolute address.
 When the process is executed, the required data and instructions are fetched from that
absolute address.
 To improve the speed and CPU utilization general purpose computers stores several
programs inside the memory for long time.
 The function of operating system in memory management is
o Keep track of which parts of memory is being accessed and by whom
o Deciding which process and data to move into and out of memory
o Allocating and deallocating memory space when needed.

Storage Management:
File management system:
 A file is collection of information defined by the user. It may be numeric, alphabetic,
alphanumeric or binary. Data files may be in free form (texts) or may be formatted rigidly.
 Directories are created to store these files for easier access.
 Files may be stored on magnetic disk, optical disk and magnetic tapes.
 Each of these media has its own characteristics and physical organization. Each medium is
controlled by device such as disk drive or tape drive.
 The properties include access speed, capacity, data transfer rate and access method
(sequential or random)
Operating System

 Access of files may be controlled and permissions of file access


 The operating systems responsibility towards file management is
o Creating and deleting files
o Creating and deleting directories to organize files
o Supporting primitives for manipulating files and directories
o Mapping files into secondary storage
o Backing up of files on non-volatile storage media

Mass Storage Management:


Most computers use principal storage systems as disk for both programs and data. Most programs
like compiler, assemblers, word processors, editors and formatters are stored in disk.
The responsibilities of operating systems over mass storage is

 Free space management


 Storage allocation
 Disk scheduling
Tertiary storage is also used which are either WORM (Write Once Read Many times) or RW (Read
Write) formats.
Caching:
 Information is usually stored in main memory, when it is used, a copy of it is stored in a
cache. Next time initially the cache memory is checked, if the required information is stored
there, then it is used or else the information is fetched from source and stored.
 Other than cache, internal registers are used like index register, instruction registers.
 The programmers use register allocation and register replacement algorithms to decide
which information to keep in registers and which in memory.

Fig 10: Migration of integer A from disk to register


 The Fig 10 shows movement of information from disk to register. Integer A which resides in
file B, is manipulated, then by using I/O operation, it is fetched from disk to main memory to
cache and to register. Here the data is manipulated. Now A is having different values
compared to registers and in all other storage systems. It becomes same only when it is
copied in all levels.
 This is fine in a computing environment having only 1 process, but the situation becomes
more complex in case of multiprocessor environment.
 In multiprocessor environment, each CPU has local cache, change made in 1 local cache
must be updated immediately at all levels where A resides. This situation is called as cache
coherency.

Protection and Security:


 Protection is given over the access control of processes or users to the resources defined by
operating system.
Operating System

 Security is defense mechanism against internal and external attacks like denial-of-service,
worms, viruses, identity theftand theft of service.
 Systems generally first distinguish among users, to determine who can do what
o User identities (user IDs, security IDs) include name and associated number, one
per user
o User ID then associated with all files, processes of that user to determine access
control
o Group identifier (group ID) allows set of users to be defined and controls managed,
then also associated with each process, file
o Privilege escalation allows user to change to effective ID with more rights

Distributed Systems:

 Collection of separate, possibly heterogeneous systems that are networked together


 Network is a communication path between computer systems, TCP/IP is most common
model used.
o LAN (Local Area Network) is a network within a floors or rooms or building.
o WAN (Wide Area Network) is a network within buildings or cities or countries.
o MAN (Metropolitan Area Network) is a network within buildings within a city.
o Small Area Network like Bluetooth covers a small distance of few meters.
 Some systems use network operating systems which provides features such as file sharing
across a network, and communication between different processes in different computers
to exchange messages.
Computing Environments
Client Server Computing:
Some of terminals connected to centralized systems are replaced by PC’s which acts as server
systems to satisfy requests from client systems as shown in Fig 11
Server systems are classified into Compute Server system and File server system

 Computer Server System: Interface to which client can send a request to perform an action,
the server responds by executing the action and sends the result back.
 File server System: File system interface where the client can create, read, update, delete
files.

Fig 11 Client Server Model


Operating System
Peer to Peer Computing:
Client and server are not distinguished from each other. Instead each node acts as both client and
server depending on whether it is requesting something or providing service to any request as
shown in Fig 12.
In client server, server is bottleneck but in P2P model each node can provide service in a network.
To participate in peer to peer system, a node must join the network.

 When a node joins, it must register its service with centralized lookup service on the
network. Any node desiring the service first it will check centralized look up.
 A discovery protocol is provided to that allows peers to discover services provided by other
peers in the network.

Fig 12: Peer to peer model


Operating System Services:
An operating system provides environment for user programs to be executed and it also provides
certain services to system and the users of the system. The Fig 13 shows how various operating
system services are inter related.

Fig 13. View of operating system services


One set of operating system provides services which are helpful to user:
Operating System

 User Interface: Almost all the operating systems provide user interface. A command line
interface uses text commands and executes them. A batch interface is one where the
commands and the directives for those commands are stored in a files and those files are
executed. Most of the operating systems uses Graphical User Interface where a command is
given with the help of mouse buttons by clicking on icons.
 Program Execution: The system must be able to load the program into the memory and run
them. The program must be able to terminate itself either normally or abnormally.
 I/O Operations: During the execution of programs, the I/O may be required which may be a
file or I/O device. For efficiency and performance the control of these I/O will not be given
to users, instead the operating system must provide a means for I/O.
 File System manipulation: The programs may need to read, write files and directories. They
also need to create or delete a file or other operations can be performed like permissions
management on file ownership.
 Communications: There may occur circumstances where one process will communicate
with other process residing either in same computer or in different computer. This is done
using either shared memory or through message passing over the network.
 Error Detection: Operating system must constantly be aware of errors that may occur in
CPU, memory hardware, I/O devices and in the user program. For each type of error
operating system must be able to take appropriate actions to ensure correct and consistent
computing.
Another set of operations provides services to system which have multiple users. The efficiency can
be gained by sharing the computer resources among the users.

 Resource Allocation: When there are multiple users or multiple programs running at same
time, resources must be allocated to each one of them. For efficient use of CPU, CPU
scheduling is done. To allocate I/O devices, special routines are run for printers, modems,
USB storage devices etc.
 Accounting: Usage statistics of a user can be monitored and can be used for reconfiguring
the system to improve computing services.
 Protection and Security: Protection involves all access to system resources are controlled.
Security from outsiders is also provided against attacks on system by also checking for
authentication of users.
User Operating system Interface:
Major interface between user and Operating system are of 2 types, namely command
interpreter and GUI

 Command interpreter usually allows direct command entry, which is executed


accordingly.
 These are implemented in the kernel. On the systems which have multiple command
interpreters, it is called as shell
 Example of shell interpreters are Bourne shell, C shell, Bourne Again shell, Korn shell
etc. Most of these provide same functionality but the choice of shell depends on user.
 The commands can be implemented in 2 ways
o In one approach, the command interpreter itself contains the code of the
command, when the command is given the command interpreter jumps to the
Operating System
section of code that sets up the parameters and makes the appropriate system
call.
o In another approach, the operating system implements most commands through
system programs. The commands are stored in a file, the command interpreter
just loads that file with the parameter. Here the commands can be added easily
without making any changes to shell.
 GUI uses mouse based window and menu system. Based on the location of mouse,
clicking a button on mouse can invoke a program which is executed accordingly.
System Calls:
System is a programming interface to the services provided by the operating system. It is
written as a routine in C / C++. These system calls are mostly accessed by programs via
Application Programming Interface (API). API is a set of functions which are available for the
application programmer including parameters to function and the return values that
programmer can expect. Most commonly available API’s are Win32 API  Windows system
POSIX API  Unix, Linux and Mac OSx system
JAVA API  Java Virtual machines

 One of the benefit of using API’s over direct use of system call is that programming using
API concerns program portability. Application programmer can expect his program to
compile and run on any system which supports that API.
 Actual system calls can be more detailed and difficult to work with than the API
available to any application programmer.

Fig 14: System call sequence to copy from one file to another file
The Fig 14 shows system call sequence to copy from one file to another file.
The run time support system provides a system call interface that serves as the link to system
calls made available by the operating system.
Operating System

Fig 15: Handling of user application invoking a open( ) system call


The system call interface intercepts the function call in the API and invokes the system call
within the operating system. Each system call is associated with a number. The system call
interface maintains a table indexed according to these numbers. The interface invokes the
intended system call in the operating system kernel and returns the status of the system call
and any return values.
For a system call, parameters are also being sent by using 3 techniques.
1. The parameters are passed via registers.
2. In some cases there may be more number of parameters than registers then the
parameters are stored in a block or table in memory and the address of memory is
passed to register
3. Another technique is to push the parameters into stack and operating system popping it.
This technique does not limit the number or length of parameters being passed.
Types of System Calls:
System calls can be roughly grouped into

 Process Control
 File Manipulation
 Device Manipulation
 Information Maintenance
 Communication
Process Control:

 end, abort
 load, execute Save the memory or run parallel program
 create process, terminate process
 get process attributes, set process attributes control the attributes of job(priority, exec
time)
Operating System

 wait for time Set a time for process to run


 wait event, signal event wait for an event to occur. process must signal when event occurs
 allocate and free memory

Fig 16: MS DOS execution a) system start up b) Running a program


Only 1 process runs in MS DOS operating system overwriting all but kernel. Once process
completed, shell is reloaded.

Fig 17: Free BSD process running parallel


In free BSD, fork( ) system call is used in multi tasking system to create processes, exec( ) system
call to load into memory. Process will either be running in background or in foreground. When
process is done exit( ) system call is used.

File manipulation:

 create file, delete file


 open, close file
 read, write, reposition
 get and set file attributes
Device Manipulation:
Operating System

 request device, release device


 read, write, reposition
 get device attributes, set device attributes
 logically attach or detach devices
Information maintenance

 get time or date, set time or date


 get system data, set system data
 get and set process, file, or device attributes
Communication:

 create, delete communication connection


 send, receive messages
 transfer status information
 attach and detach remote devices

Operating System Design and Implementation:

 The design of an operating system must be started by defining goals and specifications. At
the highest level, the design of the system will be affected by hardware and the type of
system used like batch interface, single user, multi user, time shared, distributed, real time
or general purpose.
 The requirements can be divided into user goals and system goals.
 The user wants the system to be convenient to use, easy to learn and to use, reliable, safe
and fast.
 The specifications required by the people who design, create, maintain and operate the
system will want the system to be easy to design, implement and maintain the system. And
it should be flexible, reliable, error free and efficient.
Implementation:

 Once an operating system is designed, it should be implemented. Operating systems have


been written by assembly language. Now however they are most commonly written in C or
C++.
 The first system to be written in high level language is Master Control Program (MCP) for
Burroughs system which is a variant of ALGOL, MULTICS in MIT is written by using PL/1.
 Linux and Windows operating system is written in C but some of the codes for device
drivers and for saving and storing values in registers are written in assembly language.
Advantages of high level language over assembly level language:

 It is faster to write, easier to understand and is more compact.


 Change in compiler technology will improve the generated code for entire operating system
is done by simple recompilation.
 Easier to port
Operating System
MS-DOS operating system is written in Intel 8088 assembly language. This would run only in Intel
X86 family of CPU’s. Emulators of x86 instruction set allow operating system to run non natively
slower with more resource use.
The Linux operating system is written mostly in C and can run in different CPU’s like Intel x86, Sun
SPARC and IBMPowerPC.
Only disadvantage is the C language is slower and uses increased storage requirements.
Operating System Structure:
A system as large and complex as an operating system must be engineered carefully if it is to
function properly and be modified easily. A common approach is to partition the task into small
components rather than have a single monolithic system. Each of these modules should be well
defined with required inputs, outputs and functions.

Fig 18: MS-DOS layer structure


In Fig 18 MS-DOS, the interfaces and levels of functionality are not well separated. Here the
application programs directly use basic I/O routines to write directly into disk drives and display.
Such freedom will lead into problem created by errant user which will halt the entire system.

Fig 19: Unix system structure


Operating System
In Fig 19, the Unix system structure is shown where 2 separate parts are given as the kernel and the
system programs. The kernel is further separated into interfaces and device drivers. Everything
below a system call and below the physical hardware is kernel. This monolithic structure was
difficult to implement and maintain.
With proper hardware support, operating system can be broken into pieces that are smaller and
more appropriate than those allowed by original MS-DOS and Unix systems.
Under a top down approach, the overall functionality and features are determined and are
separated into components. A system can be made modular in many ways one of them is layered
approach.
As shown in Fig 20 the operating system is broken into number of layers. The bottom layer is
hardware layer and topmost layer is user interface.

Fig 20: Layered Operating system


Each layer is implemented by only those operations provided by the low level layers. These low
level layers hide the data structures, operations and hardware from high level layers and just
provides functionalities.
Disadvantages:

 Layered approach must be appropriately defined into various layers since the higher layers
gets the service from low level layers, careful planning is necessary.
 Layered implementations are less efficient than other types. For eg, a user program
executes I/O operation, it executes a system call that traps I/O layer which inturn calls
memory management layer which inturn calls CPU scheduling which inturn calls hardware.
In every level the parameters are modified and data may be passed and so on. Each layer
adds overhead to system call.
Microkernels:
This method structures the operating system by removing non-essential components from the
kernel and implementing them in system and user level programs. The result is smaller kernel.
Operating System
Microkernels provides minimal process and memory management in addition to communication
facility.
Communication is provided by message passing.
Advantage:

 The operating system can be extended easily as the new programs can be added in the user
space and no modification is required in kernel for that purpose.
 The operating system is easier to port to some other hardware.
 The microkernels provide more security and reliability as error in 1 program in user space
does not affect the kernel in any way
Disadvantage:
Microkernels suffer from performance decrease due to increased system function overhead.
Modules:
Currently the design of an operating system involves using object oriented programming
techniques to create a modular kernel. Here the kernel has set of components and links in
additional services during run time. These dynamically loaded modules can be found in Unix
operating systems.

Fig 21: Solaris loadable modules


As shown in Fig 21, the design allows kernel to provide core services yet allows certain features to
be added dynamically. Even though it works in same manner as a layered model, there are some
differences like the modules can call any other module. In this approach, the primary has only core
functions and knowledge of how to load and communicate with other modules but it is efficient as
the modules do not need to invoke message passing in order to communicate.
Virtual Machines:
The fundamental idea behind a virtual machine is to abstract the hardware of a computer into
several different execution environment thereby creating the illusion that each separate execution
environment is a private computer. This is being done with help of CPU scheduling and virtual
memory techniques.
Advantages:
Operating System

 Host system is protected from the virtual machines. If a virus attacks happens in any of the
virtual machines, it does not affects the host operating system.
 There is no direct sharing of resources, 2 approaches have been used: To share a file system
volume to share files. Or to define a network of virtual machines, each of which can send
information over the virtual communication network.
 Virtual machines can be used for research and development. Operating system runs and
controls the entire machine. The current system in use is to be stopped and taken out for a
while changes are being made or tested. This period is commonly called as system
development time. System Programmers use virtual machines to eliminate this problem.
 Multiple operating systems can be run on virtual machines by the developers which helps
them in rapid porting and testing of programs in varying environments.
 System Consolidation is done in data center where 2 or more separate systems are running
in 1 virtual system. This results in resource optimization.
 Emulators can also be used in case an old system is replaced by new system and the
programs running in old system have to be implemented in new system.
Virtual machine implementation:
Usually machines have 2 modes: user mode and kernel mode. The virtual machines also has these
modes: virtual user mode and virtual kernel mode which is executed in physical user mode. Those
transfer that cause from user mode to kernel mode must also cause the transfer from virtual user
mode to virtual kernel mode.
When a system call is made in virtual user mode by a program running in virtual machine, it will
cause the transfer to virtual machine monitor in real machine. When the virtual machine monitor
gains the control, it can change the values in registers and program counter for the virtual machine
to simulate the effect of system call.
The more the hardware support available within a system, the more feature rich, stable and well
performing virtual machines can be.
Example Virtual machines:
VMWare:
VMWare is a virtualization software which will run the user mode of host operating system.
Operating System

Fig 22: VMWare Workstation architecture


Fig 22 shows the VMWare architecture where linux is running as host operating system and
FreeBSD, Windows NT and Windows XP are running as guest operating systems. The virtualization
layer is heart of virtual machines which abstract the physical hardware into isolated virtual
machines. Each virtual machine has its own virtual CPU, virtual memory and virtual device drivers.
The physical disks the guest owns is just a file that is stored in a file system of host operating
system.
Java Virtual Machine:
JVM is software that may be run on top of host operating system or as part of web browser or can
be mounted on a hardware as a chip. In case JVM is implemented as a software, the java interpreter
inside JVM interprets the bytecode operations one at a time. For faster execution Just In time
compilers are used which will have cache of bytecode instruction that is converted into native
machine instructions.

Fig 23: Java Virtual Machine


Fig 23 shows a JVM which consists of class loader and java interpreter. Each program that is written
in java is stored as class construct.

 The compiler produces an architecture neutral bytecode output (.class file) that will run on
any JVM.
Operating System

 The class loader loads the compiled .class file from both java program and java API for
execution by java interpreter.
 After the class is loaded, the verifier checks the .class file is valid java bytecode and does not
overflow or underflow and also it checks whether it performs pointer arithmetic which
leads to erroneous results.
 JVM also automatically manages memory by performing garbage collection.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy