Operating Systems - Cal State LA

Download Report

Transcript Operating Systems - Cal State LA

Operating Systems
Chapter 11
1
Chapter Topics
2
Operating System Overview
Operating System Management
Functions:
 Oversees all hardware resources and
allocates them to user and applications
as needed
 Performs many low-level tasks on behalf
of users and application programs
3
Operating System Overview
4
Operating System Overview
Operating System Layers:
 Command Layer (shell) – 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
5
Operating System Overview
6
Operating System Overview
7
Resource Allocation
Resource Allocation Process:
 Keeps detailed records of available resources
 Knows which resources 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
8
Resource Allocation
Single Process Resource Allocation
(application program and operating
system):
 When an application program begins
executing, the operating system grants it
control of all unused resources
 Most service calls are actually indirect
requests for system resources
9
Resource Allocation
Multiple Process Resource Allocation:
 Multitasking operating systems are the norm for generalpurpose computers
 Multitasking operating systems must be able to handle
multiple programs and users
 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
10
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
11
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
12
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.
13
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
14
CPU Allocation
Concurrent Execution (Interleaved
Execution):


A thread is a portion of a process that can
be scheduled and executed independently.
It controls the CPU for no more than a few
milliseconds before it relinquishes control
and the operating system gives another
thread a turn
15
CPU Allocation
16
CPU Allocation
1.
2.
3.


Ready State – a thread is waiting for
access to a CPU
Block State – the thread is suspended
while an interrupt is being processed
Running State – the thread has control
of the CPU.
The thread or its parent process
terminates normally
An interrupt occurs
17
CPU Allocation
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
18
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
19
CPU Allocation
20
CPU Allocation
21
Technology Focus
22
CPU Allocation
Priority-Based:
 First-come first served:

The scheduler always dispatches the ready
thread that has been waiting the longest.
 Explicit priority:

Uses a set of priority levels and assigns a
level to each process or thread.
23
CPU Allocation
Shortest Remaining Time:
Chooses the next process to be
dispatched based on the expected
amount of CPU time needed to complete
the process.
24
Technology Focus
25
Memory Allocation
 Single-Tasking Memory Allocation
 Multitasking Memory Allocation
 Memory Fragmentation
 Noncontiguous Memory Allocation
 Virtual Memory Management
 Memory Protection
 Memory Management Hardware
26
Memory Allocation
27
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.
28
Memory Allocation
29
Memory Allocation
Multitasking Memory Allocation:
 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.
30
Memory Allocation
31
Memory Allocation
32
Memory Allocation
33
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
34
Memory Allocation
35
Memory Allocation
36
Memory Allocation
37
Memory Allocation
38
Technology Focus
39
Technology Focus
40
Interprocess Communication
41
Interprocess Communication
42
Interprocess Communication
43
Interprocess Communication
44
Interprocess Communication
45