Operating System & Memory Hierarchy i206 Fall 2010 John Chuang Some slides adapted from Glenn Brookshear, Brian Hayes, or Marti Hearst.

Slides:



Advertisements
Similar presentations
Interactive lesson about operating system
Advertisements

Processes Management.
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Computer Organization Computer Architecture, Data Representation, Information Theory i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst,
Computer Organization Boolean Logic and the CPU i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst, Brian Hayes, or Glenn Brookshear.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 4: Operating Systems.
Software Design Analysis of Algorithms i206 Fall 2010 John Chuang Some slides adapted from Glenn Brookshear, Marti Hearst, or Goodrich & Tamassia.
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
I206: Distributed Computing Applications & Infrastructure Fall 2010.
Chapter 5: Computer Systems Organization Invitation to Computer Science, C++ Version, Third Edition Added to by S. Steinfadt - Spring 2005 Additional source.
Review for Test 2 i206 Fall 2010 John Chuang. 2 Topics  Operating System and Memory Hierarchy  Algorithm analysis and Big-O Notation  Data structures.
Software Design i206 Fall 2010 John Chuang Some slides adapted from Glenn Brookshear, Brian Hayes, Marti Hearst, or James Landay.
Inter-Process Communication i206 Fall 2010 John Chuang Some slides adapted from Coulouris, Dollimore and Kindberg; Calvert and Donahoo.
Chapter 1 and 2 Computer System and Operating System Overview
1/23/2008CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Chapter 1 Data Storage. 2 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns.
Course Review i206 Fall 2010 John Chuang. 2 Outline  Test 3 topics  Course review  Course evaluation.
Process Concept An operating system executes a variety of programs
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Introduction Operating Systems’ Concepts and Structure Lecture 1 ~ Spring, 2008 ~ Spring, 2008TUCN. Operating Systems. Lecture 1.
Topic 1: Introduction to Computers and Programming
Distributed Systems & Networks i206 Fall 2010 John Chuang Some slides adapted from Coulouris, Dollimore and Kindberg.
Networking and Internetworking i206 Fall 2010 John Chuang.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 1: Introduction.
1. Fundamentals of Computer Systems Define a computer system Computer Systems in the modern world Professional standards for computer systems Ethical,
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
Thanks to Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2 Computer-System Structures n Computer System Operation n I/O Structure.
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
1 i206: Lecture 18: Regular Expressions Marti Hearst Spring 2012.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Operating Systems and Networks AE4B33OSS Introduction.
1 i206: Lecture 2: Computer Architecture, Binary Encodings, and Data Representation Marti Hearst Spring 2012.
1 i206: Lecture 9: Review; Intro to Algorithms Marti Hearst Spring 2012.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do Computer-System.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
11/13/20151 Processes ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
UNIX and Shell Programming
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 4 Computer Systems Review.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Lecture on Central Process Unit (CPU)
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Types of shedulars Process.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Computer Organisation
Processes and threads.
Process Management Presented By Aditya Gupta Assistant Professor
i206: Lecture 20: Memory Management; Operating Systems
Mid Term review CSC345.
Chapter 2: Operating-System Structures
Introduction to Operating Systems
Outline Chapter 2 (cont) Chapter 3: Processes Virtual machines
Chapter 3: Process Concept
Chapter 2: Operating-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Chapter 3: Process Management
Presentation transcript:

Operating System & Memory Hierarchy i206 Fall 2010 John Chuang Some slides adapted from Glenn Brookshear, Brian Hayes, or Marti Hearst

John Chuang2 Summary of Key Concepts  Data Storage: -Bit storage using transistors -Memory hierarchy -Locality of reference and caching  Operating System: -Process management -Context switch -Threads vs. processes -Synchronization and locks

John Chuang3 Memory Hierarchy Bits & Bytes Binary Numbers Number Systems Gates Boolean Logic Circuits CPU Machine Instructions Assembly Instructions Program Algorithms Application Memory Data compression Compiler/ Interpreter Operating System Data Structures Analysis I/O Memory hierarchy Design Methodologies/ Tools Process Truth table Venn Diagram DeMorgan’s Law Numbers, text, audio, video, image, … Decimal, Hexadecimal, Binary AND, OR, NOT, XOR, NAND, NOR, etc. Register, Cache Main Memory, Secondary Storage Context switch Process vs. Thread Locks and deadlocks Op-code, operands Instruction set arch Lossless v. lossy Info entropy & Huffman code Adders, decoders, Memory latches, ALUs, etc. Data Representation Data storage Principles ALUs, Registers, Program Counter, Instruction Register Network Distributed Systems Security Cryptography Standards & Protocols Inter-process Communication Searching, sorting, Encryption, etc. Stacks, queues, maps, trees, graphs, … Big-O UML, CRC TCP/IP, RSA, … Confidentiality Integrity Authentication … C/S, P2P Caching sockets Formal models Finite automata regex

John Chuang4 Storing 1 Bit of Data  Flip-flop (also called a latch) is a circuit built from gates that can store one bit of data -Setting input A to 1 sets output to 1 -Setting input B to 1 sets output to 0 -While both input lines are 0, the most recently stored value is preserved Adapted from Brookshear Fig 1.5 output Input A Input B Example: This 8-bit memory cell can store a byte of data.

John Chuang5 Data Storage  Where and how do we store data? Brookshear Fig 2.13

John Chuang6 Data Storage  In general, we want data to be located in close proximity of their use (the CPU in this case)  Why do we want to store data at so many different locations within a computer?  Considerations of -Storage capacity -Access latency -Cost -… -Patterns of data access

John Chuang7 Memory Hierarchy Image from

John Chuang8 Storage Technologies  Characteristics -Solid State vs. Mechanical -Volatile vs. Nonvolatile -Read only vs. Read-write (RW) -Expense -Speed -Storage capacity (a function of size & expense)  Types: -Registers: Volatile, small, expensive, fast, solid state, RW -DRAM (dynamic random access memory): Volatile, now large, expensive, fast, solid state, RW -ROM (read-only memory): Nonvolatile, Read-only, cheap, fast -Hard Disk: Nonvolatile, mechanical, RW, cheap, slow -Flash Memory (aka SSD): Nonvolatile, solid state, RW, expensive, fast (Versus hard disk: silent, lighter, faster … but more expensive) -Other external storage: CD-ROM, floppy disks, magnetic tape, …

John Chuang9 Levels of a Memory Hierarchy (circa 2000)

John Chuang10 Data Storage  In general, we want data to be located in close proximity of their use (the CPU in this case)  Why do we want to store data at so many different locations within a computer?  Considerations of -Storage capacity -Access latency -Cost -… -Patterns of data access

John Chuang11 Caching  Data access patterns exhibit locality of reference -Recently referenced item more likely to be referenced again  Caches store items that have been used recently for faster access  Caching can be done at various levels of the memory hierarchy Image from ALU Registers R W R W R W L1/L2 Cache Main Memory R W Disk Storage

John Chuang12 Operating System Bits & Bytes Binary Numbers Number Systems Gates Boolean Logic Circuits CPU Machine Instructions Assembly Instructions Program Algorithms Application Memory Data compression Compiler/ Interpreter Operating System Data Structures Analysis I/O Memory hierarchy Design Methodologies/ Tools Process Truth table Venn Diagram DeMorgan’s Law Numbers, text, audio, video, image, … Decimal, Hexadecimal, Binary AND, OR, NOT, XOR, NAND, NOR, etc. Register, Cache Main Memory, Secondary Storage Context switch Process vs. Thread Locks and deadlocks Op-code, operands Instruction set arch Lossless v. lossy Info entropy & Huffman code Adders, decoders, Memory latches, ALUs, etc. Data Representation Data storage Principles ALUs, Registers, Program Counter, Instruction Register Network Distributed Systems Security Cryptography Standards & Protocols Inter-process Communication Searching, sorting, Encryption, etc. Stacks, queues, maps, trees, graphs, … Big-O UML, CRC TCP/IP, RSA, … Confidentiality Integrity Authentication … C/S, P2P Caching sockets Formal models Finite automata regex

John Chuang13 Abstract View of System Components Source: Silberschatz, Galvin, Gagne

John Chuang14 What is an Operating System?  A software program that acts as an intermediary between a user of a computer and the computer hardware  Operating system functions: -Oversee operation of computer -Store and retrieve files -Schedule programs for execution -Execute programs

John Chuang15 OS Components  Shell (command interpreter)  Kernel -Process manager -Memory manager -File manager -I/O systems manager -Networking -Scheduler/dispatcher -Etc. shell user kernel

John Chuang16 Process Management  A process is a program in execution -A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task  The operating system is responsible for the following activities in connection with process management -Process creation and deletion -Process suspension and resumption -Provision of mechanisms for: -process synchronization -process communication

John Chuang17 Process State  As a process executes, it changes state -new: The process is being created. -running: Instructions are being executed. -waiting: The process is waiting for some event to occur. -ready: The process is waiting to be assigned to a process. -terminated: The process has finished execution. Source: Silberschatz, Galvin, Gagne

John Chuang18 Resource Sharing  Many processes share hardware resources -CPU, I/O (mouse, keyboard, monitor, disk, …)  Processes must take turns -Context switch (aka process switch)  Operating system serves as coordinator/ scheduler Brookshear Fig 3.6

John Chuang19 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  Process control block (PCB, on right) contains information associated with each process  Context-switch time is overhead; the system does no useful work while switching -A system is said to be “thrashing” when it spends more time performing context switches than useful work Source: Silberschatz, Galvin, Gagne

John Chuang20 Threads  A thread (or lightweight process) is a basic unit of CPU utilization  Each thread has its own -program counter -stack -register set  The threads share: -text section (program) -data section (global variables) Source: Silberschatz, Galvin, Gagne

John Chuang21 Threads versus Multiple Processes  Threads are cheaper to create than processes (~10-20x)  Switching to a different thread in same process is much cheaper than switching to a different process (~5-50x) since no context switching required  Threads within same process can share data and other resources more conveniently and efficiently (than Inter-Process Communication)  Threads within a process are not protected from one another

John Chuang22 Synchronization  Scenario: two threads want to update count (current value is 4) -Thread 1: count = count + 1 -Thread 2: count = count - 1  What is final value of count ? -(a) 3 -(b) 4 -(c) 5 -(d) any of the above -(e) none of the above

John Chuang23 Synchronization  LOAD R1, XY  LOAD R2, #1  ADD R3, R1, R2  STORE R3, XY  LOAD R4, XY  LOAD R5, #-1  ADD R6, R4, R5  STORE R6, XY

John Chuang24 Synchronization  LOAD R1, XY  LOAD R2, #1  ADD R3, R1, R2  STORE R3, XY  LOAD R4, XY  LOAD R5, #-1  ADD R6, R4, R5  STORE R6, XY  LOAD R1, XY  LOAD R4, XY  LOAD R2, #1  LOAD R5, #-1  ADD R3, R1, R2  ADD R6, R4, R5  STORE R3, XY  STORE R6, XY

John Chuang25 Lesson  Even a seemingly simple operation like count++ is not atomic, and can be subject to race conditions

John Chuang26 Synchronization  Use locks to coordinate actions of competing processes  Also known as mutual exclusion (mutex)  Simplest form of lock is a semaphore -Process must acquire semaphore before entering critical section; release semaphore upon exit initialize_lock()... acquire_lock() try: change_shared_data() finally: release_lock()

John Chuang27 Summary of Key Concepts  Data Storage: -Bit storage using transistors -Memory hierarchy -Locality of reference and caching  Operating System: -Process management -Context switch -Threads vs. processes -Synchronization and locks