61
CISC 3595/5595 Operating Systems Introduction

CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Embed Size (px)

Citation preview

Page 1: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

CISC 3595/5595 Operating SystemsIntroduction

Page 2: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Content of this lectureCourse information (organization, assessment, overview)!Why learning OS?!What is an OS? What does it do?!Computer Hardware: an overview!Summary

2

Page 3: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Why learning OS?Fulfill requirement?!Operating System knowledge is important!! http://www.youtube.com/watch?v=-3Rt2_9d7Jg!

! Which course is this?!! http://matt-welsh.blogspot.ca/2010/10/in-defense-of-mark-zuckerberg.html!

! Software companies love OS students!! Most big software companies have system positions

3

Page 4: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Goals of this courseUnderstand operating system concepts!How OS works, and more importantly, why?!! What are the reasons motivated each design?!Basis for future learning!Get hands dirty!! Implement parts of OS!! System programming

4

Page 5: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

PrerequisiteData Structure, CISC 2200 !And, Computer organizations (CISC 3593) preferred !! What is an Instruction (e.g., load, store)?!! What is CPU? Memory? Registers?!! What is Stack? Stack pointer? !! What is Program Counter (PC)?!We will review the above hardware concepts today…

5

Page 6: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Course ContentsOverview of computer hardware !Threads and processes!Synchronization and concurrency!Scheduling!Memory Management, Virtual Memory!Disk Management and File Systems!Advanced topics

6

Page 7: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

CommunicationsClass web site: http://storm.cis.fordham.edu/zhang/cs3595!! Provides slides, agenda, grading policy, etc.!! All information regarding assignments!

Email me anytime, please include CISC3595 in the subject !Office hour: LC LL812 (lab) for one hour before class!

7

Page 8: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

ExamMidterm!! Covers first half of class !Final!! Covers second half of class + selected material from first part!Project-related knowledge may be included in the exams

8

Page 9: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Cheating policyAcademic integrity!Your work in this class must be your own – we have zero tolerance policy towards cheating of any kind and any student who cheats will get a failing grade in the course!Both the cheater and the student who aided the cheater will be held responsible for the cheating!We have tools to detect software plagiarism

9

Page 10: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

How NotTo pass?Do not come to lecture!! It’s nice out, the slides are online, and material in the book

anyway!! TRUTH: Lecture material is the basis for exams!! It is much more efficient to learn through discussion!Copy other people’s project!! It is cheating!!! How can you answer the questions in midterm or final

exams?

10

Page 11: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

How NotTo pass? (2)Do not ask questions in lecture, office hours, or piazza!! It’s scary, I don’t want to embarrass myself!! TRUTH: asking questions is the best way to clarify lecture

material at the time it is being presented!! “There is no such things as stupid question…”!

Wait until the last couple of days to start a project!! The project cannot be done in the last few days!! Repeat: the project cannot be done in the last few days!

11

Page 12: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

What is an OS?Anyone?!!Give a few names of an OS?!! Desktops?!! Smart phones?

12

Page 13: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

What is an OS?“Code” that:!! Sits between programs & hardware!! Sits between different programs!! Sits between different users!But what does it do?!! Managing the hardware resource!! Provide a clean set of interface to programs!A good OS is a piece of software that normally you shouldn’t notice of its existence!! But you feel the pain if it goes wrong!Real life analogy?!! Government

13

Page 14: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

What is an Operating System?

4

• 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!– Provide abstractions to application programs: make

computer system convenient to use!– Provide orderly, controlled, efficient allocation of

resources

14

Page 15: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

OS is…Software layer between hardware and applications !!!!!!!The OS is “all the code that you didn’t have to write” to implement your application

15

Page 16: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Four Components of a Computer System

163

People, machines, other computers

CPU, memory, I/O devices

Page 17: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

An example comparing life Life with an OS!file = open (“test.txt”, O_WRONLY);!

write (file, “test”, 4);!

close (file);

Life without an OS

• Blocks, platter, track, and sector

• Where is this file on disk? Which platter, track, and sectors?

• Code needs to change on a different system

!

17

Page 18: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

OS and hardwareThe OS abstracts/controls/mediates access to hardware resources (what resources?) ! Computation (CPUs)!! Volatile storage (memory) and persistent storage (disk, etc.)!! Communication (network, modem, etc.)!! Input/output devices (keyboard, display, printer, etc.)

18

Page 19: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Benefits to ApplicationsSimpler!! no tweaking device registers!Device independent!! all disks look the same!Portable!! same program runs on Windows95/98/ME/NT/2000/XP/Vista/

Windows 7/Windows 8!Worry less about interference from other applications

19

Page 20: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

What does an OS do?Resources!! Allocation!! Protection!! Reclamation!! Virtualization

20

Page 21: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

What does an OS do?Resources!! Allocation!! Protection!! Reclamation!! Virtualization

• Finite resources • Competing demands !• Examples:

• CPU • Memory • Disk • Network

Government: Limited budget,

Land, Natural resources

21

Page 22: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

What does an OS do?Resources!! Allocation!! Protection!! Reclamation!! Virtualization

• You can’t hurt me, I can’t hurt you. !!• Some degrees of safety and security

Government: Law and order

22

Page 23: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

What does an OS do?Resources!! Allocation!! Protection!! Reclamation!! Virtualization

• The OS gives, The OS takes away !!• Some times involun- tarily

Government: Income Tax

23

Page 24: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

What does an OS do?Resources!! Allocation!! Protection!! Reclamation!! Virtualization

• Illusion of infinite, private resources

• Memory vs. disk • Time-shared CPU

Government: Social welfare and

insurance

24

Page 25: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Why you want to learn OS?Foundation to other software!! Databases, Browsers, Computational software, … …!OS is one of the hardest software piece to write & debug!! Directly talks to hardware (very ugly interfaces)!! Abstract into clean interfaces!! They are BIG!! Lines of code:!

! Windows Vista (2006): 50M (XP + 10M)!! Linux 3.6: 15.9 M!! Android 4.0: > 1M

25

Page 26: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Why you want to learn OS?Many OS concepts (e.g., protection, resource management) is needed in other places!! E.g., browser!OS is used everywhere!! Your car is running on Linux/Windows

26

Page 27: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Content of this lectureCourse information (organization, assessment, overview)!Why learning OS?!What is an OS? What does it do?!History of OS!Computer Hardware: an overview!! Basic Elements!! Processor: Instruction Execution!! Memory Hierarchy!

! Cache Memory!! I/O Communication Techniques !

! Summary27

Page 28: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

History of Operating Systems! First generation (1945–55): vacuum tubes, bugs, no

operating systems, programming in machine code or plugboard !

! Second generation (1955–65): transistors, batch systems, programming in assembly, FORTRAN!

! Third generation (1965–1980): ICs, multiprogramming OS (to increase utilization of CPU), timesharing!

! Fourth generation (1980–present) personal computers, (CP/M, DOS, Windows), GUI!

! The fifth generation (1990–present) mobile computers

28

Page 29: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

296

Glen Beck and Betty Snyder program ENIAC. (U.S. Army photo)

ENIAC (Electronic Numerical Integrator And Computer) ! was the first electronic general-purpose computer. It wasTuring-complete, digital, and can be reprogrammed to solve "a large class of !numerical problems"

Page 30: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

307IBM/360 (2 million, 5 billion to built (budget 2 million)),! jewel of the office, Batch system

Page 31: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

318 1970s, Unix System, PDF-7 (mini-computer)

Page 33: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Current Generation OS ! Mobile devices (Smartphone, wearable

computers…) !! Limited power!! Different I/O: touch screen, cecullar communicaiton,

sensors, …!!  Android, iOS, Windows !

! Android's kernel is based on one of the Linux kernel's long-term support (LTS) branches!

! iOS (based upon Mac OS) !! iPhone, iPod, iPad, … !

! …

3310

Page 34: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Content of this lectureCourse information (organization, assessment, overview)!Why learning OS?!What is an OS? What does it do?!History of OS!Computer Hardware: an overview!! Basic Elements!! Processor: Instruction Execution!! Memory Hierarchy!

! Cache Memory!! I/O Communication Techniques !

! Summary34

Page 35: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Computer System Organization

12

! One or more CPUs, device controllers connected through common bus providing access to shared memory

35

Page 36: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Basic Hardware Elements! Processor or Central Processing Unit (CPU)!

! Controls operation, performs data processing!! Memory (main/primary memory)!

! Volatile, i.e., data is typically lost when power is removed!! Used to store data and instructions!

! I/O Modules: disk controller, USB controller, ...!! Moves data between computer and external device such

as storage (e.g. hard drive), communication equipment, terminals!!

! System Bus!! Wires or backplane connecting CPUs, I/O modules and

main memory3613

Page 37: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Processor (CPU)! CPU: the physical heart of entire computer system!

! Execute instructions!! Instruction set: the set of machine instructions that a

processor can execute, main categories: !! Processor-memory: move data between memory and

processor!! processor-I/O: move data between peripheral device and

CPU!! Data processing: arithmetic or logic operation on data!! Control: alter execution sequence (jump, if and loop

structure)!! Some instructions are privilege instructions (can only

be executed by os kernel).3714

Page 38: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Stored Program Computer! A program: a sequence of instructions stored in

memory (main memory or disk)!! when running a program, it is loaded (from disk) into main

memory !! Basic Instruction Execution cycle:!

! Processor reads (fetches) instruction from main memory!! Processor executes the instruction

38Stored program computer (due to John von Neumann (1903-1957))

15

Page 39: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Top-Level Logic View

3916

Main memory:!a large array of words or bytes. Each words has its own address.

CPU registers: in-CPU memory,!faster and smaller than main memory!

Page 40: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

CPU Registers: data and address registers! Data/Address registers: store data or memory

address !! Store frequently used variable in register: !! for (register int i = 0; i < bufsize; i++) * p++ =

assigned_val; !! Usually compiler decides what variables to store in

register

4017

Page 41: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

CPU: Control and Status Registers! Control CPU operation, and stores CPU status !

! Program counter (PC): holds address of the instruction to be fetched next!

! Instruction register (IR): store the instruction to be executed!

! Program status word (PSW): contain bits set by processor hardware as a result of operations!! Condition code bits (set by comparison instructions)!! CPU priority!! Mode (user, or kernel mode): OS kernel runs in kernel supervisor

mode, other programs run in user mode!! Other …

4118

Page 42: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Machine code and Assembly Language! CPU only understands binary => machine

instructions are coded in binary strings!! e.g., 10110000 01100001 (Hexadecimal: B0 61)!

! Assembly language: mnemonic language (helping to remember)!! MOV AL, #61h!! Move the value 61h (or 97 decimal; the h-suffix means

hexadecimal; the pound sign means move the immediate value, not location) into the processor register named "AL".

4219

Page 43: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Considering a Hypothetical Machine

4320

Page 44: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

4421

Page 45: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Singleprocessor & Multiprocessor

22

! Most systems use a single general-purpose processor!

! Multiprocessors systems growing in use and importance!! parallel systems, tightly-coupled systems!! Advantages include!1. Increased throughput!2. Economy of scale!3. Increased reliability – graceful degradation or fault

tolerance

45

Page 46: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Outline

23

• What is operating system? !• Necessary background: computer hardware

organization!! Basic Elements!! Processor: Instruction Execution!! Memory Hierarchy!

! Cache Memory!! I/O Communication Techniques

46

Page 47: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Memory Hierarchy

24

! CPU register!! CPU L1 cache!! Main memory, RAM – volatile storage media that

CPU can access directly!! Random access: take same amount of time to access

any part of the memory!! Hard disk: Large nonvolatile storage capacity!

! disk controller: determines logical interaction between the device and the computer !

! Magnetic tape: !! sequential access: recall that you have to rewind

VCR?47

Page 48: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

4825

Performance measure: maximum transfer rate; spindle Rotation Speed: decides the reading/writing rate; seek time: avg time to locate the data

Page 49: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Why so many different memory/storage! Major constraints in memory!

! Amount, Speed, Expense!! Generally:!

! Faster access time, greater cost per bit

4926 ns: nanosecond (10-9 seconds), 1 billionth second

Page 50: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Memory Hierarchy! Goal: to obtain good trade-off between cost and

performance!! Going down hierarchy!

! Decreasing cost per bit!! Increasing capacity!! Increasing access time!! Decreasing frequency of access

5027

Page 51: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Memory Hierarchy and Caching

28

! Caching: information in use is copied from slower and larger storage to faster and smaller storage (cache) temporarily!! Faster storage (cache) checked first to determine if information

is there!! If it is, information used directly from the cache (fast)!! If not, data copied to cache and used there!

! Exploit temporal locality and spatial locality!! Data which is required soon is often close in memory to the current

data!! Caching is performed at many levels in a computer!

! Hardware: L1 cache!! Operating system: disk cache in memory!! Software/application level caching

51

Page 52: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Primary Cache (L1 cache)! Processor must access memory at least once per

instruction cycle!! Processor speed faster than memory access speed!

! Solution: L1 Cache, storage on CPU for temporary storage of instructions and data

5229

• Cache contains copy of a portion of main memory!• CPU first checks cache!

•If not found, block of memory read into cache!• Because of locality of reference, likely future memory references are in that block!

Page 53: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Content of this lectureCourse information (organization, assessment, overview)!Why learning OS?!What is an OS? What does it do?!History of OS!Computer Hardware: an overview!! Basic Elements!! Processor: Instruction Execution!! Memory Hierarchy!

! Cache Memory!! I/O Communication Techniques !

! Summary53

Page 54: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Input/Output Device Controller

31

• Device Controller:!• A chip or sets of chip that control I/O device to perform I/O!• Special purpose processor: execute concurrently with

CPU!• Basic functionalities: moving data between device and

controller’s local buffer!• Has local buffer (registers): CPU communicates with

device controller through these, e.g., command, status, input/output data!

• Device driver: software that talks to device controller

54

Page 55: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

I/O operation modes! Coordination between CPU and Device Controller!! Programmed I/O: I will wait here until you are done with

this, “busy waiting”!! Problem: most I/O devices are slower than CPU => inefficient for

CPU to wait for I/O to complete!!

! Interrupt-driven I/O: let me know as soon as you are done... !

! Direct memory access (DMA): Work on the reports and when you are done, put them in my mail box, and let me know... !!

! Needs a mechanism to change the sequential instruction execution of CPU5533

Page 56: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Interrupts! A mechanism to interrupt normal execution sequence

of CPU! !! Recall CPU follows the fetch/execution cycle

5634

Interrupt Handler:!Predefined routines !to be called when!a certain interrupt !occurs.

Page 57: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Different Types of Interrupts ! Program generated: arithmetic overflow, division by

zero, illegal machine instruction, reference outside of user’s allowed memory space, also called exception, trap or software interrupt!

! Timer: generated by a timer with CPU !! I/O: generated by I/O controller to signal completion

of operation or error condition!! Delivered to CPU via bus, together with device number!

! Hardware failure: triggered by power failure, memory parity error…

5736

An operating system is interrupt driven.

Page 58: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Interrupt-driven I/O

37

! When CPU encounters an I/O related instruction!! it executes that instruction by issuing a command to

appropriate I/O module, and ask I/O module to give an interrupt when done!

! CPU continues to do its work without waiting for I/O completion (maybe running other programs if it’s a blocking call, such as cin, scanf…)… !

! After I/O device controller finish I/O operation, it generate an interrupt to inform CPU!

! CPU, in interrupt handler, read data from device controller or write next block of data to device controller, and wake up processes waiting for the interrupt...

58

Page 59: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Direct Memory Access (DMA) I/O

38

! DMA: allow device to access memory for reading and/or writing independently of CPU. !! Used in high-speed I/O devices: disk controllers, graphics

cards, network cards and sound cards!! DMA module (DMA device controller)!

! Transfers blocks of data from buffer storage directly to main memory!

! Only one interrupt is generated per block!! CPU only involved at beginning and ending transfer.!

! Less CPU intervention => much more efficient in terms of processing times

59

Page 60: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Multiprogramming

43

! Multiple programs are kept in memory, i.e., process (a program in execution)!! One process is selected and run via CPU

scheduling!! When it has to wait (e.g., for I/O), OS

switches to another process!! After saving status of pending process

(PC, stack, …) !! After an interrupt handler completes,

control may not return to the program that was executing at the time of the interrupt!

! Timesharing: allocate CPU to different processes in small quota, and round-robin manner60

Page 61: CISC 3595/5595 Operating Systems Introductionstorm.cis.fordham.edu/zhang/cs3595_f15/slides/...3 Ding Yuan, ECE344 Operating System Goals of this course 䡦Understand operating system

Ding Yuan, ECE344 Operating System

Before the next classBrowse the course web!Start thinking about partners for project groups!Read chapter 1 !See me up front if you have any questions!Let the fun (or grind) begin!

61