summer 2015 silicon valley university confidential 1 operating systems dr. jerry shiao, silicon...

49
Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

Upload: horatio-owens

Post on 27-Dec-2015

225 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

Summer 2015SILICON VALLEY UNIVERSITY

CONFIDENTIAL 1

Operating Systems

Dr. Jerry Shiao, Silicon Valley University

Page 2: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 2

Course Description Overview Computer System

Computer System Computer hardware ( CPU, Memory, Peripheral I/O Devices ). Single User/Single Proc, Single User/Mult Proc, Mult User/Mult Proc Computer hardware resource need to be controlled and allocated.

Overview Operating System Operating System: Software used for controlling/allocating resources (CPU time,

Memory Space, File-Storage Space, I/O Devices). Operating System Structure: Layered, Modular, MicroKernel.

Process Management. Concept of Process: Unit of Work in a System. Process Scheduling Policy: Concurrent Kernel and User Processes. Inter-Process Communication. Process Synchronization (Semaphores and Mutexes).

Memory Management Management of Main Memory During Process Execution. Memory Management Schemes / Approaches.

Storage Management File Systems (Virtual File Systems). System I/O Control and Designs: Performance Issues I/O Devices

Copyright @ 2009 John Wiley & Sons Inc.

Page 3: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 3

Course Description

Protection and Security of Resources Protection Between Processes. Access Control. Authorization.

Distributed Systems Collection of Operating Systems / Processors. Improve Computational Speed and Data Availability. Mechanisms for Process Synchronization and Communication. Distributed File System.

Special-Purpose Systems Requirements Differ from General-Purpose Computer Systems Real-Time Operating Systems.

Results Within Hard Deadlines. Multimedia Systems.

Quality-Of-Service Guarantees Multimedia Data Delivered to Clients Within Specific Time Frame.

Copyright @ 2009 John Wiley & Sons Inc.

Page 4: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 4

Course Description

Real-World Operating System Environments Window Systems

Windows Vista, Windows 2000, and Windows XP. Win32 API Programming Environment. Managing Processes, Threads, Memory, and Peripheral Devices.

POSIX ( UNIX / Linux ) Portable Operating System Interface Standard. POSIX-compliant Systems: UNIX, Linux, Solaris, and Mac OS X.

Java Virtual Machine ( JVM ) API and Build-In Language Support for Thread Creation and Management. JAVA Programs Run on any Operating System Supporting JVM.

Virtual Machines ( VMWare ) Software Implementation of a Computer System running an Operation

System. Host Machine ( Hypervisor ) and Guest Machine ( Virtual Machine Managed

by Hypervisor ). Cloud Computing Environment.

Copyright @ 2009 John Wiley & Sons Inc.

Page 5: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 5

Copyright @ 2009 John Wiley & Sons Inc.

Course Description

Class Evaluation: 30 %: Midterm. First half material. 30 %: Final. Second half material. 30 %: Homework 10 %: Attendance / Class Participation

Lab Evaluation: 100 %: Lab assignments.

References: Operating Systems Concepts 8th Edition, Silberschatz, Galvin, Gagne,

2009 John Wiley & Sons, Inc. Operating Systems Internals and Design Principles 6th Edition, Stallings,

2009 Pearson Education, Inc. http://class.svuca.edu/~sau/class/CS400/ NOTE: Upper Case “CS400”

Lecture PowerPoint Slides Homework Assignments Lab Assignments

Email: [email protected]

Page 6: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 6

Course Description Computer System.

Goal of Computer System is to execute user programs and solve user programs easier.

Computer System Computer hardware ( CPU, Memory, Peripheral I/O Devices ). Computer hardware resource need to be controlled and allocated. Software used for controlling/allocating resources (CPU time, Memory

Space, File-Storage Space, I/O Devices) is the Operating System. Operating System Consists of Kernel and . . .

System Programs Utilities providing environment for user application development and

execution. System Calls (i.e. File Operations). System programs to manipulate files and directories (i.e. mkdir, cp, rm, ls). System programs for development (i.e. compilers, assemblers, loaders). Communications between processes or other computer systems ( i.e.

sockets, network protocols ). Application Programs

Utilities not associated with operation of the Operating System, but used for problem solving.

Web Browsers, Word Processor, Spreadsheets, Database Systems, Games.

Copyright @ 2009 John Wiley & Sons Inc.

Page 7: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 7

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Abstract View Of Computer System

User 1

User 3

User 2

User n

Compiler Assembler Text Editor Database System System and Application Programs

Operating System

Computer Hardware

. . .

Page 8: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 8

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction General Structure of Computer System Organization

CPUUSB Controller

Disk Controller

Graphics Adapter

. . .

Memory

MonitorMouse

KeyboardDisks

BUS

Memory Controller

CPU(s) and device controllers connected through a common bus that provides access to shared memory.

Device controllers is in charge of a specific device. CPU and device controllers execute concurrently, memory controller synchronize access to memory.

Page 9: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 9

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Computer System Organization Computer System Operation Steps Firmware (Bootstrap Program)

Computer Initialization – Bootstrap Program on ROM or Flash Diagnostic Tests of Peripherals, Hardware, and Memory Devices. Initializes CPU Registers, Device Controllers, Memory Contents. Loads First Process (i.e. init process) into Memory and executes the process.

Operating System Runs (Waits for Events) Schedules Processes

Events Interrupt Request Line (IRQ) CPU Interrupted: IRQ Indexes into Interrupt Vector. Interrupt Service Routines Process Interrupt.

User Processes Executing

I/O Device Transferring

I/O Device Transferring

I/O RequestI/O Request

I/O DoneI/O Done

Interrupt Handler Processing

Page 10: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 10

Copyright @ 2009 Pearson Education, Inc.

Course Description Computer System Organization Program Flow With Interrupts

Solid Line: Segments of code in a program.Dashed Line: Path of execution by the processor.

Page 11: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

Magnetic Tape

Magnetic Disk

Electronic Disk

Main Memory

Registers

SILICON VALLEY UNIVERSITY CONFIDENTIAL 11

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Computer System Organization CPU load instructions from main memory: Programs stored there. Storage Structure: Organized into Hierarchy by Speed and Expense. Registers

Holds instructions for execution (instruction register). Holds data temporarily for instruction register, stored back into memory.

Main Memory ( Random-Access Memory or RAM) Hold programs and data for Execution. Volatile Storage Device – Loses contents when Power Off or System Restarted,

Secondary Storage Extension of Main Memory: Main memory

too small to hold all programs and data. Holds programs and data permanently. Magnetic Disks. NVRAM ( Flash ).

Hierarchical Storage Structure:

Speed (Access Time) and Expense.

Cache

Vol

atile

Page 12: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 12

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Computer System Organization Memory Hierarchy

Going down the Hierarchy:a) Decreasing cost per bit.b) Increasing Capacity.c) Increasing Access Time.d) Decreasing frequency of access to the memory by processor.

Strategy is to decrease frequencyof access at lower levels.

Locality of Reference: Two levels of access,

High Speed Cache and Slower Speed Main Memory. Memory references, instructions and data, tend to cluster.

Programs have iterative loops and subroutines.Tables and arrays involve access to clustered set of data bytes.

Short period of time, processor using fixed clusters of memory references. Cache stages movement of data between main memory and registers to

improve performance.

Page 13: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 13

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Computer System Organization Cache Memory Instruction Cycle:

Processor access memory to fetch instruction, and one or more times to fetch operands and/or store restults.

Rate processor can execute instruction limited by memory cycle time. Process speed has been increasing more rapidly than memory access speed. Main memory should be built with same technology as processor registers,

giving memory cycle times comparable to processor cycle times. Cache provides a small, fast memory between processor and Main

Memory.

Block of data is fetched into the cache to satisfy a single memory reference. Likely many of the future memory references will be to other bytes in the block.

Page 14: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 14

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Computer System Organization Cache Memory

Memory is number of fixed length blocks of K words.Cache consists of slots of K words: Number of slots are less than number of blocks in Main Memory.

Subset of the blocks in Main Memory reside in the slots of the cache.If a word in a block of Main Memory is NOT in the cache is read, that block is transferred to a slot of the cache.

Block: 6 Bit AddressTag = 01 (high order bits of address)Block = 010000, 010001, 010010, 010011, 010100, 010101, 010110, 010111, 011000, 011001, 011010, 011011, 011100, 011101, 011110, 011111

Page 15: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 15

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Computer System Organization Cache Design

Cache Size: Reasonably small caches can have impact.

Block Size: As block size increasehit ratio will increase. If block sizegets too large, hit ratio decreasebecause block is larger than theprinciple of locality.

Mapping Function: ReplacementAlgorithm determines which blockwill be replaced (Least RecentlyUsed replaces the block in thecache the longest).

Write Policy: Contents of the cacheare altered, when does the memorywrite take place. Writing can occurevery time the block is updated, or only when the block is replaced.

Page 16: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 16

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Computer System Organization Instruction-Execution Cycle

Program Counter Register holds address of next instruction. Processor fetches instruction from memory. Instruction loaded into Instruction Register. Process interprets instruction and performs required action. Instruction may involve one or combination of actions:

Data may be transferred to or from processor and memory module. Data may be transferred to or from processor and an I/O module. Processor may perform some arithmetic or logic operation on data. Instruction alters the sequence of instructions (next fetch from non-

sequential address).

Program Counter Register Instruction Register

Page 17: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 17

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Computer System Organization Instruction-Execution Cycle Interrupt Stage

Process interprets instruction and performs required action. Processor checks to see if interrupt signal has been raised. Interrupt Pending: Suspends execution of current program and executes

interrupt-handler routine. Interrupt-handler performs action requested by event. Interrupt-handler completes, process resume execution at the point of

interruption.

Page 18: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 18

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Computer System Organization I/O Communication Process executing I/O instruction uses:

Programmed I/O Interrupt-Driven I/O Direct Memory Access ( DMA )

Programmed I/O Processor issues command to I/O Module. I/O Module completes the request and sets

I/O Status Register. Processor must periodically check I/O

Module for completion. I/O Module Instruction Set:

Control: Activate and commands to I/O Module.

Status: Test I/O Module status. Transfer: Read/Write data between

processor register and I/O Module. Disadvantage: Time consuming and keeps

processor busy.

Issue Read command to I/O Module

CPU -> I/O

Read status of I/O Module

Read word from I/O Module

Write word into memory

I/O -> CPU

Check status

CPU -> Memory

I/O -> CPU

Done?

Not Ready

No

Yes

Error Condition

Page 19: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 19

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Computer System Organization Interrupt-Driven I/O

Processor issues command to I/O Module. Processor continue other work: Does NOT

check I/O Module repeatedly. I/O Module will interrupt the processor to

request service. At end of each instruction cycle, processor

checks for interrupts. Processor saves context of executing program. Processor executes Interrupt Handler. Processor executes the data transfer. Processor restores context of the programs

that issued I/O command. Eliminates needless waiting. Consumes processor time: Data from

memory to I/O Module and vice versa.

Issue Read command to I/O Module

CPU -> I/O

Read status of I/O Module

Read word from I/O Module

Write word into memory

I/O -> CPU

Check status

CPU -> Memory

I/O -> CPU

Done?

Ready

No

Yes

Processor continues

Interrupt

Error Condition

Page 20: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 20

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Computer System Organization Direct Memory Access (DMA) I/O

Processor issues command to I/O Module. DMA function in I/O Module handles data

transfer. Processor sends DMA Module:

Read or Write Request. Address of I/O Device. Memory address to Read from or Write to. Number of words to Read or Write.

DMA Module takes control of Bus to transfer data to and from memory.

DMA Transfer Modes: Cycle Steal: Processor must wait one Bus cycle when Bus conflict with

DMA Module. Burst Mode: Entire block of data transferred in one contiguous sequece.

Processor must wait for DMA to complete.

Issue Block Read command to I/O Module

CPU -> DMA

Processor continues

Read status of DMA Module DMA -> CPU

Interrupt

Page 21: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 21

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Computer System Organization Storage Structure I/O Structure

Large portion of Operating System responsible for managing I/O. Device Driver connected to Device Controller. Device Controller supports multiple devices (i.e. SCSI Controller). Direct Memory Access ( DMA ).

Transfers block of data directly to or from its own buffer storage to memory. Does not involve CPU during transfer,

Thread of Execution

CPU

Device (*M)

Data

Interrupt

I/O R

equest

Instructions and Data

MemoryDMA

Instruction Execution Cycle

Data Movement

Computer System with DMA

Page 22: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 22

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Operating System Organization Movement of data between levels of Storage Hierachy Cache

Temporary faster storage system. Storage Hierarchy:

Data may appear in different levels of the storage system. Cache Coherency in multiprocessor environment: Multiple CPUs and caches

must update cached value concurrently. I / O Systems

Hides pecularities of I/O Devices Memory-Management component including buffering, caching, and spooling. General Device-Driver Interface. Drivers for specific hardware devices .

Magnetic Disk

Integer “A”

Hardware Register

Integer “A”

Cache

Integer “A”

Main Memory

Integer “A”

Operating System Control Hardware Control

Page 23: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 23

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Computer System Architecture Single Processor Systems One General-Purpose CPU

One main CPU executing general-purpose instruction set. System can have multiple special-purpose processors embedded in

hardware (i.e. keyboard) or in controllers. Special-purpose processors has limited instruction set.

Disk controller has disk queue and scheduling algorithmn. Keyboard processor converts keystrokes into codes.

Controlled by main CPU. Multiprocessor Systems

Less cost than multiple single-processor systems. Share peripherals, mass storage, memory, power supplies.

Increased throughput. Incur overhead keep processing synchronized. Incur contention shared resources.

Increased Reliability. Built-in redundancy in core. Graceful Degradation: Failure of one processor will not crash Computer

System.

Page 24: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 24

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Computer System Architecture Multiprocessor Systems

Asymmetric Multiprocessing Master-Slave Processor Relationship: Each processor assigned task. Master Processor schedules and allocates work to the Slave Processor. CPU can have specific actions: One CPU executes Operating System code,

another CPU executes only I/O operations. Symmetric Multiprocessing (SMP)

Peer-Peer Processor Relationship. Each processor performs all tasks within the Operating System Each processor can run separate process. Sun Solaris, Windows, Windows XP, MAC OS X, Linux.

Cache Memory speed-up Main Memory access. Multi-core System

Single chip contains multiple computing cores. Less cost than multiple single-processor systems.

Share peripherals, mass storage, memory, power supplies. On-Chip communication faster. Less power Server Systems (Web Servers).

Page 25: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 25

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Computer System Architecture Multiprocessor Systems

CPU 1

Registers

Cache

CPU 0

Registers

Cache

Memory

CPU 1

Registers

Cache

CPU 0

Registers

Cache

Memory

Dual-Core ( Single Chip )Single Core ( Two Chips )

Page 26: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 26

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Computer System Architecture Clustered Systems

Individual Computer Systems share storage and linked through LAN. Cluster Computer Systems (Nodes) running layer of Cluster Software

linking nodes together. High-Availability Service: Failure on one system causes service to

restart on the redundant system. Asymmetric Clustering

One system active, one system in Hot-Standby System. Symmetric Clustering

Both systems active executing applications, but monitoring each other. Parallel Cluster over WAN.

Multiple hosts accessing same data on shared storage. Require special applications: Oracle Real Application Cluster database.

Access Control using Distributed Lock Manager ( DLM ). Beowulf Clusters

High Performance Computation sharing computing power of multiple computers.

Computers linked through software libraries. Open Source Linux Systems.

Page 27: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 27

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Computer System Architecture Clustered Systems Storage Area Networks ( SANS ) Database Cluster

Application and Data are stored on the SAN. Cluster software assigns application to run on any hosts attached to the

SAN. Host fails, another host takes over the application.

Increase Performance and Reliability

Storage Area Network

Computer System Computer System Computer System

Page 28: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 28

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Operating System Structure Operating System Provides Multi-Programming Environment Increases CPU Utilization (CPU always busy): Single program

cannot keep CPU or I/O Devices busy System Resources ( i.e. CPU, Memory, and Peripheral Devices )

are Utilized Effectively Time-Sharing Systems

CPU switches between multiple users. User interacts with Operating System with keyboard, mouse, monitor. Operating System switches between users rapidly, giving impression of

system dedicated to one user. Scheduler decides which processor to run. Scheduler Policy : Set of rules determining when and how a process is

to run. Scheduler Time Sharing principle based on timer interrupts. Scheduler selects process based on priority.

Process priority based on how often the CPU is being used . Interactive Process Batch Process

Page 29: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 29

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Operating System Operations Interrupt Driven Interrupt Event Alters the Sequence of Instructions Executed by a

Processor Synchronous interrupts ( Trap or Exceptions ) produced by CPU.

Software Interrupts. Programming errors, divide by zero, illegal memory reference. Conditions handled by kernel, page fault. System calls.

Asynchronous interrupts generated by hardware devices. Hardware Interrupts. Keyboard keystrokes. Data received. Timer: Ensure Operating System maintains control over the CPU. Event

used to schedule programs for execution. Interrupt and exception handlers are not processes, they execute in the

system control path.

Page 30: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 30Fall 2012

Operating System Introduction

Hardware Interrupts

Ethernet

Controller

I/O Controller

SCSI Disk

Real-Time Clock

I/O

Advanced

Programmable

Interrupt

Controller

(APIC)

Interrupt ReQuest Lines

(IRQ)

Local APIC

Local APIC CPU 1

CPU 0

Inte

rrup

t C

ontr

olle

r C

omm

unic

atio

n (I

CC

) B

usI/O devices: Unique or shared Interrupt ReQuest Lines (IRQs).

I/O APIC: 24 IRQ lines. Send/Receive APIC Messages over ICC BUS to Local APICs.

IRQ signals delived to available CPUs (Static or Dynamic Distribution)

Local APIC: Mapped to interrupt vectors.

Signals processor with INTR (issues an interrupt).

INTR

INTR

Page 31: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 31

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Interrupt Handling

1) User program interrupted after instruction at location N.

2) Contents of all registers plus address of next instruction (N+1), total M words are pushed onto Kernel Stack.

3) Stack Pointer updated to point to new Top-Of-Stack.

4) Program Counter updated to point to the Interrupt Service Routine.

1) Interrupt processing is complete, saved registers retrieved from Kernel Stack.

2) Program Counter restored from Kernel Stack.

Page 32: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 32

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction

Interrupt Handling

1) Disabled Interrupts handled in strict sequential order.

2) Does not consider time-critical needs or priority of interrupts.

1) Priorities considered for interrupts.2) Interrupt priority determined by the

IRQ.

Page 33: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 33

Copyright @ 2009 Pearson Education, Inc.

Operating System Introduction Interrupt Handling Priority Time Sequenced

1) Printer low priority.2) Disk with medium priority.3) Comm line high priority.

At t=20, a disk interrupt occurs, but because the interrupt is lower priority, it is held, and the comm ISR runs to completion.

Page 34: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 34

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Operating System Operations Dual-Mode Operation: Distinguish between User and Kernel Mode. User Mode: Computer system executing on behalf of an user

application. Kernel ( System ) Mode: Operating System execution.

Trap or interrupt, switch to Kernel Mode. System call is a trap ( software interrupt ) caused by user program requesting

Operating System to perform task reserved for the operating system. I/O Control, Timer Management, Interrupt Management.

Privileged Instructions.

User Mode(Mode Bit = 1)

Kernel Mode(Mode Bit = 0)

User Process Executing Calls System Call

Execute System Call

Return From System Call

Trap Mode Bit = 0 Return Mode Bit = 1

Page 35: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 35

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Operating System Process Management CPU executes Instructions of a Process (User or System) What is a Process? - A Unit of Work in a Computer System -

Computer System consists of Operating System processes ( executes system code ) and user processes ( executes user code ).

Process needs resources – CPU, memory, files, I/O devices. Process might need initialization data ( input ). Process termination, Operating System reclaims resources.

Multi-threaded: Parent process creates multiple process threads Shares memory address space and resources (i.e. open files).

Multi-process: Parent process creates multiple child processes Separate memory address space and resources.

Operating System Provides: Scheduling processes and threads on the CPUs. Creating and deleting both User and System processes. Suspending and resuming processes. Providing mechanisms for process synchronization. Providing mechanisms for process communication.

Page 36: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 36

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction

Operating System Memory Management How does CPU executes User Process? User Process User Programs loaded to Main Memory before

execution. User Process has own address space (User Space), separate from

Operating System space (Kernel Space). Main Memory central to operation of Computer System

CPU executes instructions from Main Memory Data transferred to Main Memory for processing

Multiple user programs kept in Main Memory User programs in its own address space. Operating System Scheduler selects the user program to execute.

Memory Management Required to: Keep track of which parts of memory are currently being used and by

which user program. Decide processes ( or parts thereof ) and data to move into and out of

memory. Allocating and deallocating memory space as needed.

Page 37: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 37

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Operating System Storage Management User Programs stored in File System before loaded into Main

Memory. File System Management:

File: Abstraction of the physical properties of a storage device (i.e. disk). Multiple access controlled by access permissions (i.e. read, write). Operating System Provides File Management:

Creating and Deleting files. Creating and Deleting Directories to organize files. Supporting primitives for manipulating files and directories. Mapping files onto secondary storage. Backing up files on stable ( nonvolatile ) storage media.

Mass Storage Management Main Memory programs and data backed up to secondary storage. Most programs stored on mass storage device until loaded into Main

Memory. Operating System Provides Mass Storage Management:

Free-space Management. Storage Allocation. Disk Scheduling.

Page 38: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 38

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Operating System Protection and Security Regulate Multiple Users and Concurrent Processes execution. Protection: Mechanism for controlling access of processes or users

to Operating System resources. Operating System Physical User Protection

Providing private address space for User Processes. Separation of User Space and Kernel Space.

Mechanism for controlling access to Computer System Resources. Process must have proper authorization from Operating System. Files (File Management), Memory Segments, CPU.

Security: Defend system from external and internal attacks. Stolen username and passwords. Viruses, Worms, Denial-of-Service.

Protection and Security require means to distinguish among users. User Identifiers ( User Names + User Identifier ) unique for each user.

Identify Individual User access. Group Identifiers ( User Names + Identifier + Group Identifier ) unique

for each user in a group. Identify sets of user in a group access.

Page 39: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 39

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Computer System Networks Operating System provides Users Access to Distributed Systems

Distributed Systems Collection of physically separate Computer Systems connected by

Computer Network. Provides access to shared resources at different Computer

Systems. Increases computation speed, functionality, data availability,

and reliability. Abstracted through software (i.e. Cluster Layer supporting Distributed

Database). Access through Network Utilities (i.e. FTP, ssh).

Category of Computer Networks: LANs: Local Area Network connects hosts room, building, or campus

(up to 1 kilometers). MAN: Metropolitan Area Network connects hosts within city or between

cities (1 to 20 kilometers). WAN: Wide Area Network connects hosts within state or country (10+

kilometers to 1,000+ kilometers). Internetworking: Network of networks through routers or gateways.

Page 40: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 40

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Special-Purpose Computer Systems Computer Systems with limited computation domain: Not General-

Purpose Computer Systems Real-Time Embedded Systems

Specialized embedded Computer Systems. Monitoring (sensor data)and managing hardware devices. Must process in fixed time constraints or the system will fail. Automobile engine and controls (ABS Brakes, fuel injection), airplane

controls, robotics, industrial control systems, home appliances, and military weapons.

Multimedia Systems Multimedia data systems (audio files, DVD movies, video, video

conferencing, live webcast ). Requirement on delivery, streaming video at 30 frames per second.

Handheld Computer Systems Memory Management issues, low power or slow processors, small

“consoles”. Uses embedded Computer Systems where the Operating System and

application have to work with slow processors. I/O limitations due to small keyboards and small “console” window.

Page 41: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 41

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Computing Environments Computer Systems Usage in Different Computing Environments Shift from Centralized System Architecture with Terminal / Console

Connectivity More functional and powerful PCs replaces the Terminal and act in a

Client–Server Configuration. Client-Server Computing

User-Interface functionality handled by centralized systems handled by PCs. Server Systems are categorized as Compute Servers and File Servers. Compute Servers: Client sends request for action (i.e. search database). File Servers: Client can create/update/read/delete files (i.e. Web browser

access the server running Web server). Peer-Peer Computing

No client-server distinction, all nodes are peers requesting or providing service.

P2P file sharing software allowing each peer to act as a server (providing file) or client (requesting file).

Web-Based Computing Web-enabled connectivity accessing resources using Web browser. Cloud Computing: Connectivity to computers and servers through the internet.

Page 42: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 42

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Summary Operating System manages computer resources and provides an

environment for user applications to run. Main Memory is crucial to operation of the Computer System.

Hierarchial Storage Structure containing Main Memory and Secondary Storage. Secondary Storage is an extension of Main Memory. Operating System manages memory: Keep track of what parts of

memory are being used and by whom, and dynamically allocating and freeing memory space.

Protection of memory Different CPU strategies for designing a Computer System:

Uniprocessor, multiprocessor systems that share physical memory and I/O devices, and Cluster Systems that utilizes Cluster software layer using a LAN.

Page 43: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 43

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Summary ( Cont. ) Operating System best utilizes the CPU using multiprogramming.

Process or program is the fundamental unit of work in an Operating System.

Time-sharing Computer Systems utilizing CPU scheduling algorithms to switch between processes.

Operating System protects and secures the system and User Processes with kernel mode and user mode of operations.

Operating System facilities (dual mode, privilieged instructions, memory protection, and timer interrupts) are basic building blocks

Distributed Systems consisting of physically separate Computer Systems connected by Computer Network. Shares resources (increases computation speed, functionality, data

availability, and reliability). Distributed System services provided through client-server model or

peer-to-peer model.

Page 44: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 44

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Summary ( Cont. ) Special Purpose Computer Systems.

Real-Time Operating Systems designed for Embedded Environment. Multimedia Systems for delivery of synchronized audio and video

streams. Internet and World Wide Web influencing Operating Systems with Web

Browsers, networking software and communication software as integrated features.

Page 45: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 45Summer 2015

Operating System Introduction Lab 1 http://www.putty.org

Binaries

The latest release version (beta 0.63). This will generally be a version I think is reasonably likely to work well. If you have a problem with the release version, it might be worth trying out the latest development snapshot (below) to see if I've already fixed the bug, before reporting it to me.

For Windows on Intel x86

PuTTY: putty.exe (or by FTP) (RSA sig) (DSA sig)

. . .

Download PuTTY

PuTTY is an SSH and telnet client, developed originally by Simon Tatham for the Windows platform. PuTTY is open source software that is available with source code and is developed and supported by a group of volunteers.

You can download PuTTY here.

Page 46: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 46Summer 2015

Operating System Introduction Lab 1

10.0.1.10

Page 47: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 47Summer 2015

Operating System Introduction Lab 1 MAC OS X:

In the “Applications/Utilities” folder, open “Terminal”.

ssh <User Name>@<Server IP Address>

ssh [email protected]

In the upper-right corner of the MAC main window, there is also a “Search” area. Type in “Terminal”.

Page 48: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 48Summer 2015

Operating System Introduction Lab 1 WIFI Access Point changed to SVU-LAN (No Internet).

SVU-LAB (No Internet)SSID = svuca.edu

Page 49: Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Operating Systems Dr. Jerry Shiao, Silicon Valley University

SILICON VALLEY UNIVERSITY CONFIDENTIAL 49

Copyright @ 2009 John Wiley & Sons Inc.

Operating System Introduction Lab 1 “top” command: CPU activity in Real-Time. Status of first 15 of most

CPU-intensive tasks. Q. What are the priorities of the processes are seen most frequently at

the top line? Q. What is the xorg process? Q. What is the init process?

“top” command: When top process is running, it has the keyboard. Type “u” to have top process prompt for the “user”. Type your user name. Q. What shows up as your processes?

“top” command: Use <ctrl> <C> to terminate top process.

“ps f” command: Provides a tree of the process at the local terminal. Q. What is the parent process of the command “ps f”?

“ps fa” command: Provides a tree of all processes with terminal. Q. What other processes are shown?