Transcript File

Operating System Overview
Operating System
Objective and Function
• A program that controls the execution of
application programs
• An interface between applications and
hardware
• Main objectives of an OS:
– Convenience
– Efficiency
– Ability to evolve(An OS should be constructed in such a way as to
permit the effective development, testing, and introduction of new system
functions without interfering with service.)
The Operating System as a User/Computer
Interface
Services/Functions provided by OS
• Program development
– Editors and debuggers.
• Program execution
– OS handles scheduling of numerous tasks required
to execute a program
• Access to 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
• Error detection and response
– Internal and external hardware errors
– Software errors
– Operating system cannot grant request of application
• Accounting
– A good OS will Collect usage statistics
– Monitor performance(response time)
The Operating System as Resource Manager
(The Role of an OS)
• A computer is a set of resources for the
movement, storage, and processing of data.
• The OS is responsible for managing these
resources.
• Operating System as Software:
– The OS functions in the same way as an ordinary
computer software
• It is a program that is executed by the CPU
– Operating system relinquishes control of the
processor
THE EVOLUTION OF OPERATING SYSTEMS
THE EVOLUTION OF OPERATING SYSTEMS
– Serial Processing
– Simple Batch Systems
– Multiprogrammed batch systems
– Time Sharing Systems
Serial Processing
• With the earliest computers (late 1940s to the mid1950s), 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).
• If an error halted the program, the error condition was
indicated by the lights.
• If the program proceeded to a normal completion, the output
appeared on the printer
Two main problems:
Scheduling:
• Most installations used a hardcopy sign-up sheet to reserve computer
time.
• A user might sign up for an hour and finish in 45 minutes; this would result
in wasted computer processing time.
• On the other hand, the user might run into problems, not finish in the
allotted time, and be forced to stop before resolving the problem.
Setup time:
• A single program, called a job, could involve loading ,linking and saving
• Each steps could involve mounting or dismounting tapes or setting up card
decks.
• If an error occurred, the user typically had to go back to the beginning of
the setup sequence.
• Thus, a considerable amount of time was spent just in setting up the
program to run
Simple batch system
• Early computers were extremely expensive
– Important to maximize processor utilization
• To improve utilization, the concept of a batch operating system
(use of a piece of software known as the monitor)was
developed
• With this type of OS, the user no longer has direct access to the
processor.
• Instead, the user submits the job on cards or tape to a
computer operator, who batches the jobs together
sequentially and places the entire batch on an input device,
for use by the monitor.
• Each program is constructed to branch back to the monitor
when it completes processing, at which point the monitor
automatically begins loading the next program.
• To understand this scheme: 2 view
• Monitor point of view
• Processor point of view
Monitor point of view
• The monitor controls the sequence of events.
• Much of the monitor must always be in main memory and available
for execution -> resident monitor.
• The rest of the monitor consists of utilities and common functions
that are loaded as subroutines to the user program at the beginning of
any job that requires them.
• The monitor reads in jobs one at a time from the input device
• As it is read in, the current job is placed in the user program area, and
control is passed to this job.
• When the job is completed, it returns control to the monitor, which
immediately reads in the next job.
• The results of each job are sent to an output device, such as a printer,
for delivery to the user.
Processor point of view:
• At a certain point, the processor is executing instructions from
the portion of main memory containing the monitor.
• These instructions cause the next job to be read into another
portion of main memory.
• Once a job has been read in, the processor will encounter a
branch instruction in the monitor that instructs the processor
to continue execution at the start of the user program.
• The processor will then execute the instructions in the user
program until it encounters an ending or error condition.
Job Control Language(JCL)
• Special type of programming language to
control jobs
• Provides instruction to the monitor
– What compiler to use
– What data to use
• The monitor, or batch operating system, is
simply a computer program.
• It relies on the ability of the processor
Certain other hardware features are also desirable
• Memory protection for monitor
– Jobs cannot overwrite or alter
• Timer
– Prevent a job from monopolizing system
• Privileged instructions
– Only executed by the monitor
– Eg:I/O instructions
• Interrupts
– This feature gives the OS more flexibility in relinquishing
control to and regaining control from user programs.
Modes of Operation
• Considerations of memory protection and privileged
instructions lead to the concept of 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
• computer spends over 96% of its time waiting for I/O
devices to finish transferring data to and from the file
• 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, Or Multitasking
• It is the central theme of modern operating systems.
Time Sharing Systems(Multi tasking)
• Multiprogramming 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
(Both batch processing and time sharing use multiprogramming)
Computer-System Organization
Computer-System Organization
• Computer system operation:
– Execution(load instruction from CPU to Memory)
– Boot or boot up(load operating system to
secondary memory to main memory )
– Interrupt: interrupt normal sequencing of
processor
• Storage devices: (Memory hierarchy)
• I/O interface: (I/O techniques)
Operating system structure
• Multiprogramming (Batch system)
• Timesharing (multitasking)
Operating-System Operations
Operating-System Operations
• Interrupt driven (hardware and software)
– Hardware interrupt by one of the devices
– Software interrupt (exception or trap):
• Software error (e.g., division by zero)
• Request for operating system service
• Other process problems include infinite loop, processes
modifying each other or the operating system
• Dual-mode operation allows OS to protect itself and other
system components
– User mode and kernel mode
– Mode bit provided by hardware(0->kernel ,1->user)
• Provides ability to distinguish when system is running
user code or kernel code
• Some instructions designated as privileged, only
executable in kernel mode
• System call changes mode to kernel, return from call
resets it to user
• Increasingly CPUs support multi-mode operations
– i.e. virtual machine manager (VMM) mode for guest VMs
Transition from User to Kernel Mode
• Timer to prevent infinite loop / process hogging resources
– Timer is set to interrupt the computer after some time
period
– Keep a counter that is decremented by the physical clock.
– Operating system set the counter (privileged instruction)
– When counter zero generate an interrupt
– Set up before scheduling process to regain control or
terminate program that exceeds allotted time