40

What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Embed Size (px)

DESCRIPTION

Abstract View of System Components

Citation preview

Page 1: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program
Page 2: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

• What is an Operating System?• Various systems and their pros and cons

– E.g. multi-tasking vs. Batch• OS definitions

– Resource allocator– Control program– Kernel

Page 3: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Abstract View of System Components

Page 4: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Important OS Features/services

• Process Management (CPU scheduling)• Main Memory Management• File Management• I/O System Management• Secondary Management• Networking• Protection System• Command-Interpreter System

Page 5: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

OS Control Structure

MemoryI/O

FileProcesses

Memory Tables

I/O Tables

File Tables

Process 1Process 2

… Process N

Primary Table

Process Image

User dataUser programSystem stack

PCB

Page 6: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Process State Diagram

Ready

BlockedSuspend

New Running

Exit

release

dispatch

time-out

eventactivate

suspend

admit

wait

Page 7: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

• System call vs. System program

Page 8: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Dual mode operation & why ?

Page 9: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

OS structure & Layered Approach

• The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.

• With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers.

Page 10: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

UNIX System Structure

Page 11: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Process Management

• Process vs. Thread creation• Process scheduling• Process Termination• Unix process creation fork() & exec()

– Identify parent vs. child

• How to find out process infomation

Page 12: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Process Control Block (PCB)

Page 13: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Process vs. Thread creation

Page 14: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Multithreading Models

• Many-to-One

• One-to-One

• Many-to-Many----------------------------------------------• Pthread, JAVA thread, Kernel vs. User

thread

Page 15: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

CPU Switch From Process to Process

Page 16: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Process Scheduling Queues• Job queue – set of all processes in the system.• Ready queue – set of all processes residing in main memory,

ready and waiting to execute.• Device queues – set of processes waiting for an I/O device.• Process migration between the various queues.

Page 17: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Representation of Process Scheduling

Page 18: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Schedulers

• Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue.

• Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU.

• Midterm scheduler

Page 19: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Addition of Medium Term Scheduling

Page 20: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Context Switch• When CPU switches to another process, the system must

save the state of the old process and load the saved state for the new process.

• Context-switch time is overhead; the system does no useful work while switching.

• Time dependent on hardware support.

Page 21: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Process scheduling

Page 22: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Process scheduling 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• Pre-emptive and none-preemptive

Page 23: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Scheduling Criteria• CPU utilization – keep the CPU as busy as possible• Throughput – # of processes that complete their execution

per time unit

• Turnaround time – amount of time to execute a particular process (finishing time – arrival time)

• Waiting time – amount of time a process has been waiting in the ready queue

• Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)

Page 24: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Various scheduling algorithms• FCFS• SJF• SRTF• R-R with quantum• Priority• Multi-level Priority • ---------------• Pros and cons, different conditions (q time,

starvation prevention etc.)• Example of process arrival rate

Page 25: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Process Communication

• IPC & Unix IPC• Client-Server

– Raw socket– High-level comm (e.g. RPC, RMI, CORBA

etc)

– Pros & con on various mechanisms

Page 26: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Process Synchronization & deadlocks

• Critical Section• Semaphore & implementation (Unix)• Spin lock and sleep(wait) lock• Deadlock

– Mutex, hold-wait, no-preemption, circular-wait– Identify deadlock from resource allocation

graph or code

Page 27: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Memory Management

• Swapping • Contiguous Allocation• Paging• Segmentation• Segmentation with Paging• --------------------• Pros and cons• Address translation

Page 28: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Pros & cons

• Paging vs Contiguous

• Hierarchical Paging vs. Hashed Page Tables vs. Inverted Page Tables

Page 29: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Example of address translation (segmetation)

Page 30: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Example of address translation

Page 31: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Virtual Memory

Page 32: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Virtual Memory

• Demand paging• Demand segmentation

• Page fault and how to handle• Page replacement

Page 33: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

File Management

• File structure • File Attributes (FCB)• directory• Access method• Access control

Page 34: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

A Typical File Control Block

Page 35: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Virtual File System

Page 36: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Allocation Methods

• An allocation method refers to how disk blocks are allocated for files:

• Contiguous allocation

• Linked allocation

• Indexed allocation

Page 37: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

I/O system

• I/O Hardware• Application I/O Interface• Kernel I/O Subsystem

– Chracter vs. block– Polling vs. interupt

Page 38: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

User program & Kernel interface

Note: This picture is excerpted from Write a Linux Hardware Device Driver, Andrew O’Shauqhnessy, Unix world

Page 39: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

Two I/O Methods

Synchronous Asynchronous

Pooling or interrupt

Page 40: What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program

LKM

• What is it?• Pros & cons (vs. recompile and patches)