Chapter 11 Operating Systems
description
Transcript of Chapter 11 Operating Systems
![Page 1: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/1.jpg)
Chapter 11
Operating Systems
![Page 2: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/2.jpg)
Outline
Functional overview of an operating system Process management Resource allocation
CPU allocation Memory allocation
Interprocess communication
![Page 3: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/3.jpg)
Operating System Overview
Operating System Management Functions Operating System Layers
![Page 4: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/4.jpg)
Operating 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.
![Page 5: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/5.jpg)
Operating System OverviewOperating System Management Functions
The operating system manages: Hardware resources Users and their programs
![Page 6: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/6.jpg)
![Page 7: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/7.jpg)
Operating System OverviewOperating System Layers
Command Layer Service Layer Kernel
![Page 8: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/8.jpg)
Operating System Layers
![Page 9: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/9.jpg)
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.
![Page 10: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/10.jpg)
Outline
Functional overview of an operating system Process management Resource allocation
CPU allocation Memory allocation
Interprocess communication
![Page 11: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/11.jpg)
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.
![Page 12: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/12.jpg)
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.
![Page 13: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/13.jpg)
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
![Page 14: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/14.jpg)
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.
![Page 15: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/15.jpg)
Outline
Functional overview of an operating system Process management Resource allocation
CPU allocation Memory allocation
Interprocess communication
![Page 16: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/16.jpg)
Resource Allocation
Single Process Resource Allocation Multiple Process Resource Allocation Resource Allocation Processes Real and Virtual Resources
![Page 17: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/17.jpg)
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.
![Page 18: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/18.jpg)
Resource Allocation
Single Process Resource Allocation
Most service calls are actually indirect requests for system resources.
MS-DOS is a single-tasking operating system.
![Page 19: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/19.jpg)
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.
![Page 20: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/20.jpg)
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
![Page 21: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/21.jpg)
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.
![Page 22: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/22.jpg)
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.
![Page 23: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/23.jpg)
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.
![Page 24: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/24.jpg)
CPU Allocation
Thread States Interrupt Processing Scheduling
![Page 25: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/25.jpg)
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.
![Page 26: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/26.jpg)
CPU Allocation
![Page 27: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/27.jpg)
CPU Allocation
Thread States
Ready Running Blocked
![Page 28: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/28.jpg)
CPU Allocation
![Page 29: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/29.jpg)
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.
![Page 30: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/30.jpg)
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.
![Page 31: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/31.jpg)
Scheduling
Preemptive Scheduling Priority-based Scheduling Real-time Scheduling
![Page 32: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/32.jpg)
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.
![Page 33: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/33.jpg)
Scheduling
![Page 34: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/34.jpg)
Scheduling
![Page 35: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/35.jpg)
Scheduling
Priority-Based Scheduling Methods:
First come First served Explicit priority Shortest time remaining
![Page 36: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/36.jpg)
Scheduling
Priority-Based: First come first served:
The scheduler always dispatches the ready thread that has been waiting the longest.
![Page 37: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/37.jpg)
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
![Page 38: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/38.jpg)
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.
![Page 39: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/39.jpg)
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.
![Page 40: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/40.jpg)
Technology Focus
Windows 2000 Scheduling
![Page 41: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/41.jpg)
Technology Focus
![Page 42: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/42.jpg)
Memory Allocation
Single-Tasking Memory Allocation Multitasking Memory Allocation Memory Fragmentation Noncontiguous Memory Allocation Virtual Memory Management Memory Protection Memory Management Hardware
![Page 43: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/43.jpg)
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.
![Page 44: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/44.jpg)
Memory Allocation
![Page 45: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/45.jpg)
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.
![Page 46: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/46.jpg)
Memory Allocation
![Page 47: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/47.jpg)
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.
![Page 48: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/48.jpg)
Memory Allocation
![Page 49: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/49.jpg)
Memory Allocation
![Page 50: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/50.jpg)
Memory Allocation
![Page 51: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/51.jpg)
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.
![Page 52: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/52.jpg)
Memory Allocation
![Page 53: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/53.jpg)
Memory Allocation
![Page 54: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/54.jpg)
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.
![Page 55: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/55.jpg)
Memory Allocation
![Page 56: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/56.jpg)
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.
![Page 57: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/57.jpg)
Memory Allocation
![Page 58: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/58.jpg)
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.
![Page 59: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/59.jpg)
Memory Allocation
Memory Management Hardware
Modern CPUs and computer systems incorporate advanced memory allocation and address resolution functions in hardware.
![Page 60: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/60.jpg)
Technology Focus
![Page 61: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/61.jpg)
Technology Focus
![Page 62: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/62.jpg)
Outline
Functional overview of an operating system Process management Resource allocation
CPU allocation Memory allocation
Interprocess communication
![Page 63: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/63.jpg)
Interprocess Communication
Interprocess Signals Interprocess Data Communication
![Page 64: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/64.jpg)
Interprocess CommunicationInterprocess 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.
![Page 65: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/65.jpg)
Interprocess Communication
![Page 66: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/66.jpg)
Interprocess Communication
![Page 67: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/67.jpg)
Interprocess Communication
![Page 68: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/68.jpg)
Interprocess CommunicationInterprocess Data Communication
Operating systems provide a mechanism called a pipe so there can be communication via shared memory between independent processes.
![Page 69: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/69.jpg)
Interprocess Communication
![Page 70: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/70.jpg)
Interprocess Communication
![Page 71: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/71.jpg)
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.
![Page 72: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/72.jpg)
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.
![Page 73: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/73.jpg)
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.
![Page 74: Chapter 11 Operating Systems](https://reader036.fdocuments.in/reader036/viewer/2022062305/56814fa5550346895dbd62d6/html5/thumbnails/74.jpg)
Summary
Processes and threads often need to synchronize their actions or transfer data among themselves using signals and pipes.