Title: Chapter 11 Operating Systems
1Chapter 11Operating Systems
2Outline
- Functional overview of an operating system
- Process management
- Resource allocation
- CPU allocation
- Memory allocation
- Interprocess communication
3Operating System Overview
- Operating System Management Functions
- Operating System Layers
4Operating System Overview
- The operating system oversees all hardware
resources and allocates them to user and
applications as needed. - The operating system performs many low-level
tasks on behalf of users and application programs.
5Operating System Overview
- Operating System Management Functions
- The operating system manages
- Hardware resources
- Users and their programs
6(No Transcript)
7Operating System Overview
- Operating System Layers
- Command Layer
- Service Layer
- Kernel
8Operating System Layers
9Operating System Layers
- Operating System Layers
- Command Layer the users 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.
10Outline
- Functional overview of an operating system
- Process management
- Resource allocation
- CPU allocation
- Memory allocation
- Interprocess communication
11Process 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.
12Process 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.
13Process 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
14Process 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.
15Outline
- Functional overview of an operating system
- Process management
- Resource allocation
- CPU allocation
- Memory allocation
- Interprocess communication
16Resource Allocation
- Single Process Resource Allocation
- Multiple Process Resource Allocation
- Resource Allocation Processes
- Real and Virtual Resources
17Resource 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.
18Resource Allocation
- Single Process Resource Allocation
- Most service calls are actually indirect requests
for system resources. - MS-DOS is a single-tasking operating system.
19Resource 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.
20Resource 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
21Resource 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.
22Resource Allocation
- Real and Virtual Resources
- Real resource a computer systems physical
devices and associated system software. - Virtual resource the resources that are
apparent to a process or user.
23Real 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.
24CPU Allocation
- Thread States
- Interrupt Processing
- Scheduling
25CPU 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.
26CPU Allocation
27CPU Allocation
- Thread States
- Ready
- Running
- Blocked
28CPU Allocation
29CPU 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.
30CPU 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.
31Scheduling
- Preemptive Scheduling
- Priority-based Scheduling
- Real-time Scheduling
32Scheduling
- 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.
33Scheduling
34Scheduling
35Scheduling
- Priority-Based Scheduling Methods
-
- First come First served
- Explicit priority
- Shortest time remaining
36Scheduling
- Priority-Based First come first served
- The scheduler always dispatches the ready thread
that has been waiting the longest.
37Scheduling
- 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
38Scheduling
- 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.
39Scheduling
- 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.
40Technology Focus
41Technology Focus
42Memory Allocation
- Single-Tasking Memory Allocation
- Multitasking Memory Allocation
- Memory Fragmentation
- Noncontiguous Memory Allocation
- Virtual Memory Management
- Memory Protection
- Memory Management Hardware
43Memory 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.
44Memory Allocation
45Memory 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.
46Memory Allocation
47Memory 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 processs
memory region(s). - Implement memory allocation and addressing as
efficiently as possible.
48Memory Allocation
49Memory Allocation
50Memory Allocation
51Memory 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.
52Memory Allocation
53Memory Allocation
54Memory Allocation
- Noncontiguous Memory Allocation
- Uses small fixed-size partitions, usually no
larger than 64K. - A process can be loaded into more than one
partition.
55Memory Allocation
56Memory 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.
57Memory Allocation
58Memory 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.
59Memory Allocation
- Memory Management Hardware
- Modern CPUs and computer systems incorporate
advanced memory allocation and address resolution
functions in hardware.
60Technology Focus
61Technology Focus
62Outline
- Functional overview of an operating system
- Process management
- Resource allocation
- CPU allocation
- Memory allocation
- Interprocess communication
63Interprocess Communication
- Interprocess Signals
- Interprocess Data Communication
64Interprocess 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.
65Interprocess Communication
66Interprocess Communication
67Interprocess Communication
68Interprocess Communication
- Interprocess Data Communication
- Operating systems provide a mechanism called a
pipe so there can be communication via shared
memory between independent processes.
69Interprocess Communication
70Interprocess Communication
71Summary
- 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.
72Summary
- 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.
73Summary
- 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.
74Summary
- Processes and threads often need to synchronize
their actions or transfer data among themselves
using signals and pipes.