Transcript Chapter02x
Operating Systems:
Internals and Design Principles, 6/E
William Stallings
Chapter 2
Operating System Overview
Operating System
• A program that controls the execution of
application programs
• An interface between applications and
hardware
Evolution of Operating
Systems
• Serial processing
– No operating system
– Machines run from a console with display
lights, toggle switches, input device, and
printer
Evolution of Operating
Systems
• Serial processing
– Setup included loading the compiler, source
program, saving compiled program, and
loading and linking: mounting/dismounting
tapes or setting up card decks
– Schedule time
– Problems with this type of machine sharing?
Evolution of Operating
Systems
• Simple batch system
– Monitor
• Software that controls the sequence of events
• Batch jobs together
• Program returns control to monitor when finished
Job Control Language
• Special type of programming language
• Provides instruction to the monitor
– What compiler to use
– What data to use
Hardware Features
• Memory protection
– Do not allow the memory area containing the
monitor to be altered
• Timer
– Prevents a job from monopolizing the system
Hardware Features
• Privileged instructions
– Certain machine level instructions can only be
executed by the monitor
• Interrupts
– Early computer models did not have this
capability
• User mode vs. Kernel mode?
Memory Protection
• User program executes in user mode
– Certain instructions may not be executed
– Certain memory areas are protected from
user’s use and may not be accessed
Memory Protection
• Monitor executes in system mode
– Kernel mode
– Privileged instructions are executed
– Protected areas of memory may be accessed
Limitations?
• Simple batch system
– Monitor
• Software that controls the sequence of events
• Batch jobs together
• Program returns control to monitor when finished
• What are the limitations?
System Utilization Example
Uniprogramming
• Processor must wait for (blocked) I/O
instruction to complete before preceding
Program Flow of Control
Program Flow of Control
Multiprogramming
• When one job needs to wait for I/O, the
processor can switch to the other job
Multiprogramming
Example
Utilization Histograms
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
• How would Time Sharing Systems differ
from Batch Multiprogramming Systems?
Batch Multiprogramming versus
Time Sharing
• How would you schedule the following jobs: J1(0,
100), J2(1, 10), J3(2, 3), J4(3, 5), J5(4, 2)
• in a batch system
• in a time-sharing system
CTSS Operation
OS Design Challenges
• Time sharing and multiprogramming lead
to challenges in
– Process management (multiple programs
time share the system, mutual exclusion,
synchronization, resource contention etc)
– Memory management (OS, multiple programs
are in the memory)
– Scheduling of processor(s) and I/O device
Operating System Objectives
• Convenience
• Efficiency
• Ability to evolve
Four Interfaces
• Figure 3-6. Various interfaces offered by computer
systems.
Four Interfaces (1)
• An interface between the hardware and
software consisting of machine instructions
– that can be invoked by any program
Four Interfaces (2)
• An interface between the hardware and
software, consisting of machine instructions
– that can be invoked only by privileged
programs, such as an operating system
Four Interfaces (3)
• An interface consisting of system calls as
offered by an operating system
Four Interfaces (4)
• An interface consisting of library calls
– Generally forming what is known as an
application programming interface (API)
– In many cases, the aforementioned system
calls are hidden by an API
Layers and Views
Services Provided by the OS
• Program development
– Editors and debuggers
• e.g., emacs, vi, gdb
• Program execution
– Load instructions & data, control scheduling
• Access I/O devices
– Hide the peculiar I/O instructions or control
signals required for each device, access it by
simple read and write function calls
Services Provided by the OS
• Controlled access to files
– Control who can access which files
• System access
– Protect resources and data from unauthorized
users
– Resolve conflicts for resource contention
Services Provided by the OS
• Error detection and response
– Internal and external hardware errors
– Software errors
– Operating system cannot grant request of
application
Services Provided by the OS
• Accounting
– Collect usage statistics
– Monitor performance
– Used to anticipate future enhancements
– Used for billing purposes
Operating System
• Responsible for managing resources
– Memory, processor, I/O devices
• Functions same way as ordinary computer
software
– It is a program that is executed
• Operating system relinquishes control of
the processor, but directs the processor so
that the processor will allow it to regain
control
OS as Resource Manager
Kernel
• Portion of operating system that is in main
memory
• Contains most frequently used functions
• Also called the nucleus
Evolution of Operating
Systems
• Hardware upgrades plus new types of
hardware (for instance, paging hardware)/
New services / Fixes