Chapter 1 Computer Technology: Your Need to Know

Download Report

Transcript Chapter 1 Computer Technology: Your Need to Know

Chapter 11
Operating Systems
Outline



Functional overview of an operating system
Process management
Resource allocation



CPU allocation
Memory allocation
Interprocess communication
Operating System Overview


Operating System Management Functions
Operating System Layers
Operating System Overview

The operating system oversees all hardware
resources and allocates them to user and
applications as needed.

The operating system performs many lowlevel tasks on behalf of users and application
programs.
Operating System Overview
Operating System Management Functions
The operating system manages:
 Hardware resources
 Users and their programs
Operating System Overview
Operating System Layers



Command Layer
Service Layer
Kernel
Operating System Layers
Operating System Layers
Operating System Layers
 Command Layer – the user’s interface to the
operating system.

Service Layer – contains a set of functions called by
application programs and the command layer.

Kernel – manages resources and directly interacts
with computer hardware.
Outline



Functional overview of an operating system
Process management
Resource allocation



CPU allocation
Memory allocation
Interprocess communication
Process Management
Process Control Data Structures

A process is a unit of executing software that
is managed independently by the operating
system.

A process can request and receive hardware
resources and operating system services.
Process Management
Process Control Data Structures

Process Control Block (PCB) – keeps track
of each process by creating and updating a
data structure.

The PCB is created when the process is
created, updated when the process changes
and deleted when the process terminates.
Process Management
Data included in a PCB:
 A unique process identification number
 The current state of the process
 Events for which the process is waiting
 Resources allocated exclusively to the
process
 Machine resources consumed
 Process ownership and/or access privileges
 Scheduling priority
Process Management
Threads
 A portion of a process that can be scheduled
and executed independently.


Process light
Thread can execute concurrently on a single
processor or simultaneously on multiple
processors.
Outline



Functional overview of an operating system
Process management
Resource allocation



CPU allocation
Memory allocation
Interprocess communication
Resource Allocation




Single Process Resource Allocation
Multiple Process Resource Allocation
Resource Allocation Processes
Real and Virtual Resources
Resource Allocation
Single Process Resource Allocation

Involves only two executing programs –
application and operating system.

When an application program begins
executing, the operating system grants it
control of all unused resources.
Resource Allocation
Single Process Resource Allocation

Most service calls are actually indirect
requests for system resources.

MS-DOS is a single-tasking operating
system.
Resource Allocation
Multiple Process Resource Allocation

Multitasking operating systems are the norm
for general-purpose computers.

Multitasking operating systems must be able
to handle multiple programs and users.
Resource Allocation
Multiple Process Resource Allocation

A multitasking operating system manages
hardware resources to achieve the following:



Meet the resource needs of processes
Prevent processes from interfering with one
another
Efficiently use hardware and other resources
Resource Allocation
Resource Allocation Processes




Keeps detailed records of available resources.
Knows which resource are used to satisfy which
requests.
Schedules resources based on specific allocation
policies to meet present and anticipated demands.
Updates records to reflect resources commitment
and release by processes and users.
Resource Allocation
Real and Virtual Resources

Real resource – a computer system’s
physical devices and associated system
software.

Virtual resource – the resources that are
apparent to a process or user.
Real and Virtual Resources
Providing virtual resources that meet or
exceed resources is accomplished by:

Rapidly shifting resources unused by one
process to other processes that need them.

Substituting one type of resource for another
when possible and necessary.
CPU Allocation



Thread States
Interrupt Processing
Scheduling
CPU Allocation

A thread controls the CPU for no more than a
few milliseconds before it relinquishes control
and the operating system gives another
thread a turn.

CPU sharing is called concurrent execution
or interleaved execution.
CPU Allocation
CPU Allocation
Thread States



Ready
Running
Blocked
CPU Allocation
CPU Allocation
Ready State – a thread is waiting for access to
a CPU.
Running State – the thread has control of the
CPU.


The thread or its parent process terminates
normally
An interrupt occurs
Block State – the thread is suspended while an
interrupt is being processed.
CPU Allocation
Interrupt Processing


A blocked thread is waiting for an event to
occur.
If the event is the correction of an error and it
can be corrected, the thread remains in the
blocked state until the error condition is
resolved; otherwise, the thread is halted.
Scheduling



Preemptive Scheduling
Priority-based Scheduling
Real-time Scheduling
Scheduling
Preemptive Scheduling



A thread can be removed involuntarily from
the running state.
A running process controls the CPU by
controlling the content of the instruction
pointer.
CPU control is lost whenever an interrupt is
received.
Scheduling
Scheduling
Scheduling
Priority-Based Scheduling Methods:



First come First served
Explicit priority
Shortest time remaining
Scheduling
Priority-Based: First come first served:

The scheduler always dispatches the ready
thread that has been waiting the longest.
Scheduling
Priority-Based: Explicit priority:

Uses a set of priority levels and assigns a
level to each process or thread.

The scheduling method can use priority levels
in two ways:


Always dispatch the highest priority ready thread
Assign larger time slices to high priority threads
Scheduling
Priority-Based: Shortest time remaining:

Chooses the next process to be dispatched
based on the expected amount of CPU time
needed to complete the process.
Scheduling
Real-Time Scheduling:

Guarantees a minimum amount of CPU time
to a thread if the thread makes an explicit
request when it is created.

Used when a thread must have enough
resources to complete its function within a
specified time.
Technology Focus
Windows 2000 Scheduling
Technology Focus
Memory Allocation







Single-Tasking Memory Allocation
Multitasking Memory Allocation
Memory Fragmentation
Noncontiguous Memory Allocation
Virtual Memory Management
Memory Protection
Memory Management Hardware
Memory Allocation
Single-Tasking Memory Allocation –
Contiguous Memory Allocation



The bulk of the operating system occupies
lower memory addresses.
The application program is loaded above the
operating system.
The remaining space is available for user
programs and data.
Memory Allocation
Memory Allocation
Single-Tasking Memory Allocation –
Noncontiguous Memory Allocation


To conserve physical memory, some
operating system components are loaded into
memory only when needed.
When loaded, they usually are placed in
upper memory.
Memory Allocation
Memory Allocation
Multitasking Memory Allocation
The goals of multitasking memory allocation are:
 Allow as many active processes as possible.
 Respond quickly to changing memory demands of
processes.
 Prevent unauthorized changes to a process’s
memory region(s).
 Implement memory allocation and addressing as
efficiently as possible.
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
Memory Fragmentation

As processes are created, executed, and
terminated, memory allocation changes
accordingly.

Memory partition allocation and deallocation
leads to an increasing number of small free
partitions separated by allocated partitions.
Memory Allocation
Memory Allocation
Memory Allocation
Noncontiguous Memory Allocation


Uses small fixed-size partitions, usually no
larger than 64K.
A process can be loaded into more than one
partition.
Memory Allocation
Memory Allocation
Virtual Memory Management
 Divides a program into partitions called
pages.
 Memory is divided into pages called a page
frame.
 During program execution, one or more
program pages are stored in a page frame,
the remaining are stored on a secondary
storage device.
Memory Allocation
Memory Allocation
Memory Protection
 Refers to the protection of memory allocated
to one program from unauthorized access by
another program.

The operating system checks each write to a
memory location to ensure that the address
being written is allocated to the program
performing the write operation.
Memory Allocation
Memory Management Hardware

Modern CPUs and computer systems
incorporate advanced memory allocation and
address resolution functions in hardware.
Technology Focus
Technology Focus
Outline



Functional overview of an operating system
Process management
Resource allocation



CPU allocation
Memory allocation
Interprocess communication
Interprocess Communication


Interprocess Signals
Interprocess Data Communication
Interprocess Communication
Interprocess Signals

A signal is a message used to synchronize
the actions of two processes or threads.

Signals can be sent between threads of the
same process, between independent
processes, or between the operating system
and a process or thread.
Interprocess Communication
Interprocess Communication
Interprocess Communication
Interprocess Communication
Interprocess Data Communication
Operating systems provide a mechanism
called a pipe so there can be communication
via shared memory between independent
processes.
Interprocess Communication
Interprocess Communication
Summary

An operating system is the most complex
component of system software.

The operating system allocates hardware
resources to individual user processes on
demand.

The operating system stores information
about each process in a PCB.
Summary

Application software is simper to develop if
programs are unaware of resource allocation
functions.

An active thread is always in one of three
states – ready, running, or blocked.
Summary

Memory is divided into fixed-size partitions
and processes are allocated one or more
memory partitions to store instructions and
data.

Modern operating systems implement a form
of memory allocation and management called
virtual memory management.
Summary

Processes and threads often need to
synchronize their actions or transfer data
among themselves using signals and pipes.