Chap 2
Chap 2
2
Convenience
• The OS provide a user/computer interface to make it more
convenient for users to use the system.
• Application programmers and end users need a way to
interact with the system hardware but usually don’t need to
know details of the computer’s hardware.
• The OS acts to insulate the user or programmer from
hardware details, making it easier to access and use the
system.
• The OS provides services like file management and control
of I/O devices that an end user or an application
programmer needs but would not want to write each time a
new program is written.
3
Convenience
Services the OS may provide include:
• Program development: editors and debuggers to assist in
program creation.
• Program execution: details of program execution are
handled by the OS (initialization, obtaining resources, etc.)
• I/O device access: provides generic interface to diverse set
of I/O devices.
• File access: protection mechanisms.
• System access: system access is controlled by the OS.
• Error detection: if a program has an error, the OS takes
action to minimize impact and correct or report the error.
• Accounting: usage statistics can be collected and used for
system optimization or billings.
4
5
Interfaces
• Instruction Set Architecture (ISA)
– Defines the set of machine language instructions that a computer
can follow. This is the interface between the hardware and the
software. Applications and utilities can only utilize a subset of the
instructions. The OS can use the additional instructions.
• Application Binary Interface (ABI)
– Defines a standard for binary portability across programs. The
ABI defines the system call interface to the OS and the hardware
resources and services available in a system through the user ISA.
• Application Programming Interface (API)
– Gives a program access to the hardware resources and services
available in a system through the user ISA supplemented with
high-level language library calls. Any system calls are usually
performed through libraries. A program can run on another system
with the same API after recompilation on the new system.
6
Efficiency
• A computer can be viewed as a set of resources.
• If applications had ownership of system resources then
sharing resources would be difficult.
• It is better to let the OS own the resources, so the OS
decides which programs get which resources.
7
Efficiency
• The OS is therefore in control of the system.
• This situation is a bit unusual—we normally think of a
controller as external to what is controlled, for example, a
thermostat controls a heating unit.
• However, the OS is itself just software, which controls
other software.
• The OS must relinquish the processor to an application and
depends on the processor to regain control.
• Yet, the processor is itself just a resource managed by the
OS.
8
9
Ability to Evolve
• OS’s evolve for many reasons:
– Hardware upgrades plus new kinds of hardware.
Examples in the past include memory paging
mechanisms and graphics display terminals.
– New services. This can be in the form of new
capabilities the OS needs to provide (for a new
application, for example).
– Fixes. OS’s have bugs, too.
10
History and Evolution of OS’s
1940’s – 50’s
• No operating system, users and applications interacted
directly with the hardware.
11
Serial Processing
• Because users had access to the system one at a time, this
could be called serial processing.
• Over time, various system software was developed to
make serial processing more efficient.
• Machine utilization was also important because machines
were very expensive.
12
Batch Operating System
1950’s – 60’s.
• A “monitor” program accepts a batch of jobs from the
operator and runs each one in turn.
• The user no longer has direct access to the machine, but
instead submits the job to the computer operator to run.
• The operator batches the jobs together and submits them
for execution by the monitor.
• The monitor (or most of it) remains in memory, called the
“resident monitor”.
• The monitor increases efficiency by scheduling each job in
turn automatically, and by reducing setup time through a
JCL (job control language), which specifies setup steps for
the monitor.
13
14
Early JCL Example
$JOB new job
$FTN load and run FORTRAN compiler
•
• FORTRAN instructions
•
$LOAD load resulting object file
$RUN run the program
•
• Data
•
$END
15
On punched cards or tape
Early Examples
• General Motors developed perhaps the first batch OS for
the IBM 701.
• The concept was refined by other IBM customers and
implemented on the IBM 704.
• IBSYS was an IBM OS for the 7090/7094 computers,
particularly notable due to its influence on other systems.
16
Batch Operating System
Desirable hardware features to support a batch OS are:
• Memory protection: don’t overwrite the monitor!
• Timer: prevents a job from monopolizing the system (job
ends when timer expires).
• Privileged Instructions: only the monitor can do certain
things, such as I/O commands. If an application wants to
do an I/O, it asks the monitor to do it.
• Interrupts: provides better way to handle transfer of
control from the monitor to user programs.
17
Modes
• Memory protection and privileged instructions lead to the
concept of modes of operation.
• The processor usually supports two modes of operation:
– user mode: for user programs, has limitations
– kernel mode: for the OS, has no limitations
18
Batch Operating System
• Notice that some of the main memory has been given to
the monitor, and some of the processor execution time has
been given to the monitor.
• These are both overhead costs.
• Even so, the batch system improves utilization of the
system.
19
Multiprogrammed Batch Systems
• Even with automatic job sequencing, the processor is often
idle.
• The problem is that I/O devices are slow compared to the
processor.
• As the example on the next slide shows, utilization of the
processor can be very low.
20
21
Multiprogrammed Batch Systems
• Uniprogramming means running one program at a time.
• Multiprogramming (or multitasking) means running more
than one program at a time.
• Multiprogramming is an extension of uniprogramming.
• With a monitor, there are already two programs (the
monitor and the program).
• Why not have the monitor and two programs? That way,
when one program must wait for an I/O, the other can run.
• Why not three or more programs?
22
Multiprogrammed Batch Systems
23
Multiprogramming
24
Multiprogramming
25
Sample Jobs:
27
28
Multiprogramming
• Note that hardware features of I/O interrupts or DMA
make multiprogramming effective (interrupts so that the
CPU can proceed with another program after starting an
I/O, or DMA so that the I/O can take place while the
processor runs another program).
• Memory management is also more important for
multiprogramming since several different jobs may be in
memory.
• Scheduling is also important to determine which of the
jobs to run next.
29
Time-Sharing Systems
• Batch systems run programs in the “background” and
generally don’t have direct user interaction.
• For some jobs, an interactive mode of processing is
required.
• Today, most users interact with programs on a PC, but in
the 1960’s this was not an option.
• Instead, a different kind of system known as a time-sharing
system was developed.
• In a time-sharing systems, multiple users interact with the
computer system through computer terminals.
• Processor time is split among the set of users.
• This works well because users are slow compared to the
CPU.
30
CTSS
• An example of an early time-sharing system was the CTSS
system.
• It was developed at MIT in 1961 as part of Project MAC
(Multiple Access Computers), first for the IBM 7090 and
later ported to the IBM 7094.
• It was very influential, leading to Multics which was also
part of Project MAC, and inspired the development of
Unix.
• The project leader, Dr. Corbato, was awarded the Turing
award in 1990.
31
CTSS
• CTSS’s implementation was primitive.
• A clock interrupt occurred every 0.2 seconds and the OS
could decide to give control to another user.
• The preempted user’s program would be written to disk
before reading the next user’s program in.
• To minimize disk I/O, memory was only written out where
the incoming program would overlay it.
• If the new program did not fully overlay the previous
program, then a portion of it might still be present when it
is time to reload it, thus minimizing the loading effort.
• This is shown on the next slide:
32
33
Batch Multiprogramming versus Time-Sharing
34
Major OS Achievements
Major advances in the development of OS’s:
• Processes
• Memory management
• Information protection and security
• Scheduling and resource management
35
Major OS Achievements
Processes
• A process can be defined many ways:
– A program in execution
– An instance of a program running on a computer
– The entity that can be assigned to and executed on a
processor
– A unit of activity characterized by a single sequential
thread of execution, a current state, and an associated
set of system resources.
36
Process Development
• Three major lines of development created problems in
timing and synchronization that led to the development of
a process:
1. Multiprogrammed batch systems
Processor is kept busy by switching between programs
in response to events such as I/O activity
2. Time-sharing systems
Processor time is shared among a number of active
users by giving each user a slice of time.
3. Real-time transaction systems
Supports applications written to perform a query or
update against a database by a user, such as an airline
reservation system. 37
System Problems
• Running multiple programs at the same time presents a
variety of problems, such as:
• Improper synchronization
– Need a reliable way for one program to wait on another.
• Failed mutual exclusion
– Need to prevent multiple programs from accessing a
resource such as a file at the same time.
• Nondeterminate program operation
– Need program results to be independent of other
programs running at the same time.
• Deadlocks
– Need to avoid situations in which programs are waiting
38
on each other.
Processes
• The demands of these systems required a systematic way
to monitor and control the various programs executing on
the processor.
• The concept of a process provides the foundation.
• A process can be thought of as having three parts:
– An executable program
– The data the program is using
– The execution context
• The execution context includes the information required
by the OS to control the process.
39
Processes
• A process list may be used to keep track of processes.
• The process list contains an entry for each process.
• Each entry contains a pointer to the process in memory and
perhaps process context information as well.
• Other context information may be stored with the process
in memory.
40
41
Major OS Achievements
Memory Management
• Requirements for multiple processes in memory:
• Isolation
– Keep process from accessing or overwriting the
memory of another.
• Automatic allocation and management
– Programmer should not worry about memory mgmt.
• Support of modular programming
– Create, destroy, alter size of modules dynamically
• Protection and access control
– Restrict or grant access as needed
• Long-term storage
– Persist after computer is off. 42
Virtual Memory
• Virtual memory allows a program to have a logical view of
memory.
• This gives the program a view of memory that may be
much larger than physical memory.
• Multiple programs may reside in main memory at the same
time, yet appear to have all of memory to themselves.
• This is accomplished by swapping pieces in and out of
main memory (to the disk drive) as needed.
• A paging system swaps pieces of programs, called pages,
that are the same size. This makes it easy to replace one
piece with another.
43
Virtual Memory
• A program runs in virtual memory as if it had all of
memory to itself.
• It references a memory address which is actually a
“virtual” (or logical) address rather than a physical
address.
• This address consists of a page number and offset.
• The paging system maps the logical page to the physical
page.
• Pages are swapped from disk to main memory as the
program runs.
44
45
46
Major OS Achievements
Information Protection and Security
• Security has become a concern especially with the
accessibility provided by computer networks.
• It is important that data only be accessed by those
authorized to do so.
• The OS should attempt to control access to the system
itself and the information it stores.
• Examples:
– Availability: protecting the system against interruption
– Confidentiality: protecting against unauthorized access
to data
– Data integrity: protecting against unauthorized
modification
– Authenticity: protecting against false identities
47
Major OS Achievements
Scheduling and resource management
Three factors to consider in scheduling:
• Fairness: processes should get equal treatment (if same
class and priority).
• Differential responsiveness: may need to discriminate
among different classes of jobs with different needs. OS
should meet total set of requirements. For example, if a
process is waiting to use an I/O device that is free, may
wish to schedule it.
• Efficiency: maximize throughput and minimize response
time.
48
Process Queues
• Scheduling may be implemented by using queues of
processes.
• A “short-term” queue contains processes currently in main
memory. Any of these processes could be run next.
Running each process in turn is called a “round-robin”
technique.
• A “long-term” queue contains processes waiting to run (by
being moved to the short-term queue).
• There may also be a series of I/O queues for processes
awaiting an I/O device.
49
50
Modern OS Characteristics
Five categories of modern Operating System design:
• Microkernel architecture
• Multithreading
• Symmetric multiprocessing
• Distributed operating systems
• Object-oriented design
51
Modern OS Characteristics
Microkernel Architecture
• The kernel is the core piece, or nucleus, of the OS.
• It contains the most frequently used functions.
• Main memory contains the OS kernel and any other OS
routines currently in use, as well as programs and their
data.
• Older designs were “monolithic”, which means all one
piece.
• A “microkernel architecture” assigns only a few essential
functions to the kernel, and other OS services are provided
by processes that run like any other process.
• This approach simplifies the implementation, provides
flexibility, and lends itself well to distributed computing
by treating remote and local processes the same way.
52
Modern OS Characteristics
Multithreading
• Process: one or more threads plus associated system
resources.
• Thread: a dispatchable unit of work.
• A process may have multiple threads of execution, where
each thread belongs to the process and shares its resources,
but executes independently and concurrently with other
threads of the process.
• This is useful for applications that need to perform
independent parallel tasks.
• This is more efficient than creating separate processes.
53
Modern OS Characteristics
Symmetric Multiprocessing (SMP)
• Modern machines may have more than one processor.
• One way to manage multiple processors is known as SMP.
55
56
Modern OS Characteristics
Distributed OS
• Multiple machines may be managed together with a
distributed operating system.
• This provides the illusion of a single main memory and
single secondary memory space for a cluster of separate
computers.
• Increasingly common, but still lags behind uniprocessor
and SMP systems.
57
Modern OS Characteristics
Object-Oriented Design
• Object-oriented design techniques can be applied to the
operating system.
• Enables adding modular extensions to a small kernel.
• Enables programmers to customize an operating system
without disrupting system integrity.
• Gives the OS many of the benefits of object-orientation.
58
Faults
• MTTF - Mean time to failure
• MTTR – Mean time to repair
• Availability – fraction of time the system is available to
service user requests.
• Downtime – the time the system is not available.
• Uptime – the time the system is available.
59
60
Faults
• A fault could be due to hardware or software.
• A fault could be permanent, meaning it persists until it is
fixed, or temporary, meaning it may appear and go away.
• Temporary faults could be transient, such as a power
supply disturbance, or intermittent, such as a loose wire.
62
End of Slides