Download No Slide Title - ECE Users Pages

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

RSTS/E wikipedia , lookup

Plan 9 from Bell Labs wikipedia , lookup

Security-focused operating system wikipedia , lookup

DNIX wikipedia , lookup

Copland (operating system) wikipedia , lookup

Spring (operating system) wikipedia , lookup

Unix security wikipedia , lookup

CP/M wikipedia , lookup

Burroughs MCP wikipedia , lookup

VS/9 wikipedia , lookup

Distributed operating system wikipedia , lookup

Process management (computing) wikipedia , lookup

Thread (computing) wikipedia , lookup

Transcript
Review for Quiz-2
Applied Operating System Concepts
Chap.s 1,2,6,7
ECE3055b, Spring 2005
•
•
•
•
•
•
•
•
What is an operating system?
Simple Batch Systems
Multiprogramming Batched Systems
Time-Sharing Systems
Personal-Computer Systems
Parallel Systems
Distributed Systems
Real -Time Systems
2
What is an Operating System?
• A program that acts as an intermediary between a
user of a computer and the computer hardware.
• Operating system goals:
– Execute user programs and make solving user
problems easier.
– Make the computer system convenient to use.
• Use the computer hardware in an efficient manner.
• Make it easy to write programs by handling common
tasks like text editing and file-selection dialog boxes.
3
Computer System Components
1. Hardware – provides basic computing resources
(CPU, memory, I/O devices).
2. Operating system – controls and coordinates the use
of the hardware among the various application
programs for the various users.
3. Applications programs – define the ways in which
the system resources are used to solve the computing
problems of the users (compilers, database systems,
video games, business programs).
4. Users (people, machines, other computers).
4
OS Features Needed for
Multiprogramming
• I/O routine supplied by the system.
• Memory management – the system must
allocate the memory to several jobs.
• CPU scheduling – the system must choose
among several jobs ready to run.
• Allocation of devices.
Types:
Batch, Parallel, Real Time, Interactive (special features)
5
Module 2: Computer-System
Structures
•
•
•
•
•
•
Computer System Operation
I/O Structure
Storage Structure
Storage Hierarchy
Hardware Protection
General System Architecture
6
Interrupts
•
•
•
•
•
•
•
•
•
•
•
I/O devices and the CPU can execute concurrently.
Each device controller is in charge of a particular device type.
Each device controller has a local buffer.
CPU moves data from/to main memory to/from local buffers
I/O is from the device to local buffer of controller.
Device controller informs CPU that it has finished its operation
by causing an interrupt.
Interrupt transfers control to the interrupt service routine generally,
through the interrupt vector, which contains the addresses of all the
service routines.
Interrupt architecture must save the address of the interrupted
instruction.
Incoming interrupts are disabled while another interrupt is being
processed to prevent a lost interrupt.
A trap is a software-generated interrupt caused either by an error or a
user request.
An operating system is interrupt driven.
7
Module 5: Threads
• Thread Management Done
by User-Level Threads
Library
• Examples
- POSIX Pthreads
- Mach C-threads
- Solaris threads
• Supported by the Kernel
• Examples
- Windows 95/98/NT
- Solaris
- Digital UNIX
8
Solaris 2 Threads
9
Java Thread Management
• suspend() – suspends execution of the currently running
thread.
• sleep() – puts the currently running thread to sleep for a
specified amount of time.
• resume() – resumes execution of a suspended thread.
• stop() – stops execution of a thread.
10
UNIX (POSIX) THREAD
MANAGEMENT
MAIN() thread
ptread_create()
I/O block
I/O block
pthread_join()
pthread_exit()
thread-1 terminates
11
Classical Problems
Producer-Consumer (Bounded-Buffer)
Readers-Writers
Dining Philosophers
Resource Allocation
Mutual Exclusion
Critical Sections
12
Module 6: CPU Scheduling
• Basic Concepts
• Maximum CPU utilization obtained with multiprogramming
• CPU–I/O Burst Cycle – Process execution consists of a cycle of
CPU execution and I/O wait.
• CPU burst distribution
•
•
•
•
•
Scheduling Criteria
Scheduling Algorithms
Multiple-Processor Scheduling
Real-Time Scheduling
Algorithm Evaluation
13
Histogram of CPU-burst Times
14
CPU Scheduler
• Selects from among the processes in memory that
are ready to execute, and allocates the CPU to one of
them.
• CPU scheduling decisions may take place when a
process:
1. Switches from running to waiting state.
2. Switches from running to ready state.
3. Switches from waiting to ready.
4. Terminates.
• Scheduling under 1 and 4 is nonpreemptive.
• All other scheduling is preemptive.
15
Find the order of processing and the run times for
P1 (3 ticks), P2 (5 ticks), P3 (4 ticks), and P4 (1 tick)
using (delta = 2 ticks, *where applicable)
First-Come, First-Served (FCFS) Scheduling
Shortest-Job-First (SJR) Scheduling
Preemptive*
Non-preemptive
Round Robin*
=========================================
Find the exponential average T of the last 5 burst lengths
(67, 89, 13, 56, 45) using a factor a =0.8 (67 is most recent)
T = a*67 + a^2*89 + a^3*13 + a^4 * 56 + a^5 * 45
= a * ( 67 + a*( 89 + a*( 13 + a*(56 + a*(45 + ...)))))
Find the next value if t=76 using one * and one + operation.
T = a * ( 76 + <old value>)
16
Thread Scheduling
• Local Scheduling – How the threads library decides
which thread to put onto an available LWP.
• Global Scheduling – How the kernel decides which
kernel thread to run next.
• JAVA
– JVM Uses a Preemptive, Priority-Based Scheduling Algorithm
– FIFO Queue is Used if There Are Multiple Threads With the Same
Priority.
JVM Schedules a Thread to Run When:
– The Currently Running Thread Exits the Runnable State.
– A Higher Priority Thread Enters the Runnable State
JVM Does Not Specify Whether Threads are Time-Sliced or Not.
17
Module 8: Deadlocks
System Model
Deadlock Characterization
Methods for Handling Deadlocks
Deadlock Prevention
Deadlock Avoidance
Deadlock Detection
Recovery from Deadlock
Combined Approach to Deadlock Handling
18
Deadlock can arise if four conditions hold simultaneously.
Mutual exclusion: only one process at a time can use a
resource.
Hold and wait: a process holding at least one resource is
waiting to acquire additional resources held by other
processes.
No preemption: a resource can be released only voluntarily
by the process holding it, after that process has completed its
task.
Circular wait: there exists a set {P0,P1, ...,Pn} of waiting
processes such that P0 is waiting for a resource that is held by
P1, P1 is waiting for a resource that is held by P2, ...
19
Resource Allocation Graph
20
Example of a Graph With Cycle
21
Methods for Handling Deadlocks
Ensure that the system will never enter a deadlock state.
Allow the system to enter a deadlock state and then recover.
Ignore the problem and pretend that deadlocks never occur in
the system; used by most operating systems, including UNIX.
22
Deadlock Avoidance
Requires that the system has some additional a priori information
available.
Simplest and most useful model requires that each process
declare the maximum number of resources of each type that it
may need.
The deadlock-avoidance algorithm dynamically examines the
resource-allocation state to ensure that there can never be a
circular-wait condition.
Resource-allocation state is defined by the number of available
and allocated resources, and the maximum demands of the
processes.
23
Example of Banker’s Algorithm
Which Order can P’s Run? (P1, P3, P4, P2, P0)
What resources are available after P3 runs? ( 7 4 3)
24
Deadlock Detection
Allow system to enter deadlock state
Detection algorithm
Recovery scheme
Security
Must be considered in:
•Computer Hardware design
•Operating System Design
•Application Software Design
•All of the Above
25