Introduction to OS

Download Report

Transcript Introduction to OS

OPERATING SYSTEM(2140702)
1
Prepared by: Dr. Vipul Vekariya
PhD(CSE)
NGI-JUNAGADH
TEACHING SCHEME
Lecture
Lab
Credit
4
2
6
2
SYLLABUS
3
4
5
REFERENCE BOOKS/TEXT BOOK
6
CONTENT OF THE CHAPTER.
What is an operating system
History of operating systems
The operating system zoo
Computer hardware review
Operating system concepts
System calls
 Operating system structure
7
OPERATING SYSTEM




A modern computer system consist of one or more processor,
main memory, disk, keyboard, network interface and other I/P
and O/P Devices.
Writing programs that keep track of all these component and
use them correctly and optimally. For this reason computers
are equipped with a layer of software called operating system.
Whose job is to manage all the devices and provide user
programs with simpler interface to the hardware.
A program that controls the execution of application programs
and act as an interface between applications and hardware
8
MAIN OBJECTIVES OF AN OS:



Convenience: An OS makes a computer more
convenient to use.
Efficiency: An OS allows the computer system
resources to be used in an efficient manner.
Ability to evolve: An Os should be constructed in
such a way as to permit the effective
development , testing and introduction of new
system function.
9
Fig -1. A computer system consists of hardware, system programs ,application programs
10
INTRODUCTION







The lowest level contains physical devices, consisting of
integrated chips, wires, power supplies, cathode ray tube, and
similar physical device.
Next comes micro architecture level, in which physical devices
are group together to form functional units.
This level contains some register internal to the CPU and
data path containing an ALU.
The operation of data path is controlled by software, called
the micro program.
The purpose of this data path is to execute some set of
instruction.
ISA ( Instruction set Architecture) ( Machine Language)
This instruction may use the register or other hardware
11
facilities.












The machine language has between 50 to 300 instruction.
Device register:
To control the I/p & O/P Devices.
Operating system: To hide all this complexity.
It consist of layer of software.
Example : Read the block from Hard disk.
On the top of the OS is the rest of the system software and
application software.
This is not a part of the operating system.
The OS is that the portion of the software that run in
KERNEL mode or supervisor mode.
It is protected by the user tampering by the hardware.
Compilers and editors are run in user mode.
It is very difficult to draw a boundary between kernel mode
and user mode.( Example: Password protection, file system)
12
WHAT IS AN OPERATING SYSTEM

It is an extended machine( as a User/Computer
interface)



•
•
•


Hides the messy details which must be performed
Presents user with a virtual machine, easier to use
The program that hides the truth about hardware from programmer
and present a nice and simple view.
Most basic command is read and write.
Each of which require 13 parameter passed by OS to read and write.
For example address of disk block, the number of sector per track, the
recording mode, the intersector gap spacing etc….
In this view function of operating system is to present the user with
the equivalent of an extended machine or virtual machine.
That is easier to program than underlying hardware.
13
OS AS RESOURCE MANAGER

It is a resource manager
 Each program gets time with the resource
 Orderly and controlled allocation of the various job to
processor, memories, i/p and o/p devices.
 The task of operating system is to keep track of
 who is using which resource
 to grant resource request
 to account for usage
 handling and manage conflicting request



Resource management includes sharing resource in two
ways:
Time sharing
examples: Printer, CPU,
Space sharing
Example: Memory, Hard disk.
15
HARDWARE SOFTWARE
CORRESPONDENCES
16
SERVICES PROVIDED
BY THE OPERATING SYSTEM





Program development
 Editors and debuggers.
Program execution
 OS handles scheduling of numerous tasks required to execute
a program
Access I/O devices
 Each device will have unique interface
 OS presents standard interface to users
Controlled access to files
 Accessing different media but presenting a common interface
to users
 Provides protection in multi-access systems
System access
 Controls access to the system and its resources
17
SERVICES CONT…

Error detection and response
Internal and external hardware errors
 Software errors
 Operating system cannot grant request of application


Accounting
Collect usage statistics
 Monitor performance

18
EVOLUTION OF OPERATING SYSTEMS

Operating systems will evolve over time
Hardware upgrades plus new types of hardware
 New services
 Fixes

EVOLUTION OF
OPERATING SYSTEMS
It may be easier to understand the key
requirements of an OS by considering the
evolution of Operating Systems
 Stages include

Serial Processing
 Simple Batch Systems
 Multiprogrammed batch systems
 Time Sharing Systems

SERIAL PROCESSING

With the earliest computers (late 1940s to the
mid-1950s), the programmer interacted directly
with the computer hardware;
There was no OS.
• These computers were run from a console consisting
of display lights, toggle switches, some form of input
device, and a printer.
• Programs in machine code were loaded via the input
device (e.g., a card reader).
•
PROBLEM WITH SERIAL PROCESSING

•
•

•
•
•
Scheduling
Most installations used a hardcopy sign-up sheet to
reserve computer time.
Typically, a user could sign up for a block of time in
multiples of a half hour or so
Setup time
A single program, called a job, could involve loading the
compiler plus the high-level language program (source
program) into memory, saving the compiled program
(object program) and then loading and linking together
the object program and common functions.
Each of these steps could involve mounting or
dismounting tapes or setting up card decks.
If an error occurred, the hapless user typically had to go
back to the beginning of the setup sequence.
22
SIMPLE BATCH SYSTEM

Early computers were extremely expensive
Important to maximize processor utilization
 The central idea behind the simple batch-processing
scheme is the use of a piece of software known as the
monitor.


Monitor
Software that controls the sequence of events
 the user submits the job on cards or tape to a
computer operator
 Batch jobs together sequentially and places the entire
batch on an input device
 Program returns control to monitor when finished

MONITOR’S PERSPECTIVE
Monitor controls the sequence of
events
 Resident Monitor is software always
in memory
 Monitor reads in job and gives control
 Job returns control to monitor

MODES OF OPERATION

User Mode
User program executes in user mode
 Certain areas of memory protected from user access
 Certain instructions may not be executed


Kernel Mode
Monitor executes in kernel mode
 Privileged instructions may be executed, all memory
accessible.

MULTIPROGRAMMED
BATCH SYSTEMS

CPU is often idle
Even with automatic job sequencing.
 I/O devices are slow compared to processor

UNIPROGRAMMING

Processor must wait for I/O instruction to
complete before preceding
MULTIPROGRAMMING

When one job needs to wait for I/O, the processor
can switch to the other job
MULTIPROGRAMMING
EXAMPLE
UTILIZATION HISTOGRAMS
MULTIPROGRAMMING BATCH SYSTEM
Most important features that is useful for
multiprogramming is the hardware supports.
 Interrupt driven I/O and DMA(direct memory
access)

32
TIME SHARING SYSTEMS
Using multiprogramming to handle multiple
interactive jobs
 Processor’s time is shared among multiple users
 Multiple users simultaneously access the system
through terminals

BATCH MULTIPROGRAMMING
VS. TIME SHARING
PROBLEMS AND ISSUES
Multiple jobs in memory must be protected from
each other’s data
 File system must be protected so that only
authorised users can access
 Confliction for resources must be handled


Printers, storage etc
HISTORY OF OPERATING SYSTEMS

First generation 1945 - 1955


Second generation 1955 - 1965


transistors, batch systems
Third generation 1965 – 1980


vacuum tubes, plug boards
ICs and multiprogramming
Fourth generation 1980 – present

personal computers
36
THE OPERATING SYSTEM ZOO
Mainframe operating systems
 Server operating systems
 Multiprocessor operating systems
 Personal computer operating systems
 Real-time operating systems
 Embedded operating systems
 Smart card operating systems

37
MAIN FRAME OPERATING SYSTEM







This operating system used for main frame computers..
Those room sized computers still found in major corporate
data centers.
This OS for mainframe are heavily oriented towards
processing many jobs at once.
This OS used where need of more I/O Operation.
They typically offer three kind of service.
1) Batch
2) Transaction processing
3) Time sharing
it is used for large scale electronic commerce site and
server for B2B transactions.
OS/360, IBM CP/67, IBM/System 360
38
SERVER OPERATING SYSTEM
One level down are the server operating system
 It run on server which are either very large
personal computer.
 They serve multiple users over a network at a
once.
 User share hardware and software resources.
 Example: print service, file service, web service.
 UNIX and windows 2000 are server OS.

39
MULTI PROCESSOR OS
Multi processor in a single system.
 That required Multi processor OS.
 These are variation on server operating system.
 This system are called parallel computers.
 Windows and LINUX run on multiprocessors.

Personal Computer OS:
 Its job is to provide a good interface to a single user.
 They are widely used for word processing, spread
sheets, and internet access.
 Example: WIN 98, XP, VISTA, Macintosh
40
REAL TIME OS
It is a multitasking operating system that aims at
executing real-time applications.
 Time is key parameter.
 The main object of real-time operating systems is their
quick and predictable response to event
 Industrial process control system
EMBEDDED OS
 The operating systems designed for being used in
embedded computer systems are known as embedded
operating systems..
 They are designed to operate on small machines like PDAs
with less autonomy.
 They are very compact and extremely efficient by design.
 Windows CE, FreeBSD and Minix 3 are some examples of
embedded operating systems.

41
SMART CARD OS

The smallest OS run on smart card.

Which are credit card sized devices containing a CPU chip.

ROM is on the smart card chip and JVM ( java virtual
machine) is installed.
42
A COMPUTER’S BASIC ELEMENTS




Processor: control the operation of computer and perform
its data processing function.
Main Memory: Stores data and program
I/O Modules: move data between the computer and its
external environment.(secondary storage, Communication
equipments)
System Bus: Provides for communication among processor,
main memory and I/O modules.
43
PROCESSOR






It is brain of the computer system.
It fetch the instruction from memory and execute it.
Each CPU contains the some register inside to hold a key
variables and temporary results.
Four internal registers
 Memory address resister (MAR): it contains the address
of memory for data read or write.
 Memory buffer register (MBR): it contains the data to be
written or read from memory.
I/O address register: Specify particular I/O device
I/O buffer register: exchange data between and I/O module
and processor
44
TOP-LEVEL VIEW
PROCESSOR(CONTI.)

1)
1)
Processor contains two types of register.
User visible register : user can access or see the data of
this register using assembly language
Control and status register: used by the processor to
control the operation of the processor.
46
USER VISIBLE REGISTER




Data register: contains the data of program
Address register: contains the main memory address of
data or instruction.
Index register: to find the effective address of program.
Stack pointer: point to the top of the stack contains in
memory
47
CONTROL AND STATUS REGISTER



Program counter(PC): contains the address of the next
instruction to be fetched.
Instruction register(IR): contains the instruction most
recently fetched.
PSW( Program status word): it contain the condition code
bits, which are set by comparison instruction, the CPU
priority, the mode( user or kernel) and various other
control bits.
48
INSTRUCTION EXECUTION
A program consists of a set of instructions stored
in memory
 Two steps

Processor reads (fetches) instructions from memory
 Processor executes each instruction

49
BASIC INSTRUCTION CYCLE
INSTRUCTION FETCH
AND EXECUTE








The processor fetches the instruction from memory
Program counter (PC) holds address of the instruction to be
fetched next
 PC is incremented after each fetch
Fetched instruction loaded into instruction register
Categories
Processor-memory: Data may be transferred from
processor to memory or from memory to processor.
Processor-I/O: Data may be transferred to or from a
peripheral device by transferring between the processor
and an I/O module.
Data processing: The processor may perform some
arithmetic or logic operation on data.
Control: An instruction may specify that the sequence of
execution be altered.
51
EXAMPLE OF
PROGRAM EXECUTION
INTERRUPTS



Interrupt the normal sequencing of the processor
Provided to improve processor utilization
 Most I/O devices are slower than the processor
 Processor must pause to wait for device
The length of this pause may be on the order of many
thousands or even millions of instruction cycles.
• Clearly, this is a very wasteful use of the processor.
53
FLOW OF CONTROL
WITHOUT INTERRUPTS
INTERRUPTS AND THE
INSTRUCTION CYCLE
TRANSFER OF CONTROL
VIA INTERRUPTS
INSTRUCTION CYCLE
WITH INTERRUPTS
SIMPLE
INTERRUPT PROCESSING
INTERRUPT PROCESSING









1.The device issues an interrupt signal to the processor.
2. The processor finishes execution of the current instruction before
responding to the interrupt.
3. The processor tests for a pending interrupt request, determines that
there is one, and sends an acknowledgment signal to the device that
issued the interrupt.
• The acknowledgment allows the device to remove its interrupt signal.
4.The processor next needs to prepare to transfer control to the interrupt
routine.
5. The processor then loads the program counter with the entry location of
the interrupt-handling routine that will respond to this interrupt.
6. At this point, the program counter and PSW relating to the interrupted
program have been saved on the control stack.
7. The interrupt handler may now proceed to process the interrupt.
8. The saved register values are retrieved from the stack and restored to
the registers
9. The final act is to restore the PSW and program counter values from
the stack.
59
MEMORY HIERARCHY

Major constraints in memory
Amount (capacity)
 Speed (access time)
 Expense(cost)

Faster access time, greater cost per bit
 Greater capacity, smaller cost per bit
 Greater capacity, slower access speed

THE MEMORY HIERARCHY

Going down the hierarchy
Decreasing cost per bit
 Increasing capacity
 Increasing access time
 Decreasing frequency of access
to the memory by the processor


Thus, smaller, more expensive,
faster memories are
supplemented by larger,
cheaper, slower memories.
COMPUTER HARDWARE REVIEW
Typical memory hierarchy
62
BUSES









The system has eight buses
Cache
Local
Memory
ISA ( industry standard architecture)(16.67 MB/sec)
PCI ( peripheral component interconnect)( 528 MB/sec)
SCSI ( small computer system interface)
USB ( universal serial buses)
IDE(Integrated Drive Electronics )
63
COMPUTER HARDWARE REVIEW
64
Structure of a large Pentium system
HOW OPERATING SYSTEM BOOT?










BIOS (Basic input output system)
It contains the low level I/O Software.
When computer is turn on , BIOS are booted.
It first check to see how much RAM is installed
And whether keyboard and other basic device are installed
and responding correctly.
The BIOS determines the boot devices by trying a list of
devices stored in the BIOS memory.
The user can change the list of BOOTING devices by
entering a BIOS programming just after booting.
If System booted from Hard disk.
The first sector of boot device read in to memory and
executed.
This sector contains partition information and active
partition.
65
CONT.






Then secondary boot loader is read from partition.
The loader reads in the OS from the active partition and
start it.
The OS then queries the BIOS to get the configuration
information.
For each device it check to see if it has device driver, if not,
it ask to user to insert CD for driver.
Then OS load driver in to kernel.
It initialize tables, create what ever back ground process
are needed.
66
SYSTEM CALL




The interface between the operating system and the user
program is defined by the set of services provided by the
OS.
Such as a reading a data from keyboard or file.
It has execute a trap or system call instruction to transfer
control to the OS.
Count = read(fd,buffer,nbytes),
67
STEPS IN MAKING A SYSTEM CALL
There are 11 steps in making the system call
count = read (fd, buffer, nbytes)
68
SOME SYSTEM CALLS FOR PROCESS
MANAGEMENT
69
SOME SYSTEM CALLS FOR FILE
MANAGEMENT
70
SOME SYSTEM CALLS FOR DIRECTORY
MANAGEMENT
71
SOME SYSTEM CALLS FOR MISCELLANEOUS
TASKS
72
SYSTEM CALLS
Some Win32 API calls
73
OPERATING SYSTEM STRUCTURE

1)
2)
3)
Monolithic System:
A main program that invokes the requested service procedure.
A set of service procedures that carry out system calls.
A set of utility procedure that help the service procedure.
74
OPERATING SYSTEM STRUCTURE
Simple structuring model for a monolithic system
75
LAYERED SYSTEM
Structure of the THE operating system
76
MICROKERNEL
A microkernel is a small OS core that provides
the foundation for modular extensions.
 only absolutely essential core OS functions
should be in the kernel.



IPC, Address Space Management, Basic
Scheduling.
Less essential services and applications are built
on the microkernel and execute in user mode.

File management, Device Driver, Virtual
Management, Process Management.
Memory
KERNEL ARCHITECTURE
MICROKERNEL FUNCTION
The microkernel functions as a message exchange:
• It validates messages,
• passes them between components,
• and grants access to hardware.
79
CLIENT SERVER MODEL










Moving large part of the operating system in to higher
level.
Minimize the kernel code. This is called a microkernel.
Implement most of the OS part in user process.
Implement client and server for communication.
Client send the request to server using message and kernel
handle the communication.
Such as file server, process server, Memory server etc…..
Each part become small and manageable.
Advantage:
Prepare a distributed system
Not whole machine down if any one server crash.
80
OPERATING SYSTEM STRUCTURE
The client-server model
81
VIRTUAL MACHINE






The first version, released in 1972 by IBM, was VM/370, or
officially Virtual Machine Facility/370.The heart of the
system is virtual machine monitor.
VMi370 has two main components-(CP/CMS)the control
program (CP) and the Conversational Monitor System
(CMS).
It runs on the bare hardware and does the
multiprogramming.
This providing not one, but several virtual machine on next
layer up.
This VM are exact copy of the bare hardware, including
kernel/user mode, I/O, interrupts and everything else the
real machine has.
Each VM can run any process.
82
VIRTUAL MACHINE
Structure of VM/370 with CMS
83
VIRTUAL MACHINES (CONT.)
Non-virtual Machine
Virtual Machine
(a) Nonvirtual machine (b) virtual machine
OPERATING SYSTEM STRUCTURE (
The client-server model in a distributed system
85