cs 134 operating systems
play

CS 134: Operating Systems Computer Hardware Synchronization 1 / - PowerPoint PPT Presentation

CS34 2013-05-17 CS 134: Operating Systems Computer Hardware Synchronization CS 134: Operating Systems Computer Hardware Synchronization 1 / 34 Overview CS34 Overview 2013-05-17 Administrivia Hardware Overview I/O Hardware


  1. CS34 2013-05-17 CS 134: Operating Systems Computer Hardware Synchronization CS 134: Operating Systems Computer Hardware Synchronization 1 / 34

  2. Overview CS34 Overview 2013-05-17 Administrivia Hardware Overview I/O Hardware Interrupts Overview Synchronization Critical Sections Hardware Support Higher-Level Mechanisms Administrivia Dining Philosophers Hardware Overview I/O Hardware Interrupts Synchronization Critical Sections Hardware Support Higher-Level Mechanisms Dining Philosophers 2 / 34

  3. Administrivia A Bit on OS/161 & Homeworks CS34 A Bit on OS/161 & Homeworks 2013-05-17 Administrivia Status: I’m working on it; initial setup takes a bit of time ◮ So when I post homework, plan for that time! A Bit on OS/161 & Homeworks First assignment will be “get going” You should have your group formed by now Status: I’m working on it; initial setup takes a bit of time ◮ So when I post homework, plan for that time! First assignment will be “get going” You should have your group formed by now 3 / 34

  4. Administrivia In the Meantime. . . CS34 In the Meantime. . . 2013-05-17 Administrivia Activities to do before Thursday: ◮ Find out about system calls ◮ Read manual pages on getpid , stime , readdir ◮ About how many system calls does Linux have? (Hint: manual In the Meantime. . . pages live in /usr/share/man ◮ Run strace (on Knuth or other Linux) on a simple program such as true , echo , or ls Activities to do before Thursday: ◮ Find out about system calls ◮ Read manual pages on getpid , stime , readdir ◮ About how many system calls does Linux have? (Hint: manual pages live in /usr/share/man ◮ Run strace (on Knuth or other Linux) on a simple program such as true , echo , or ls 4 / 34

  5. Hardware Overview Computer Hardware CS34 Computer Hardware 2013-05-17 disk disk printer tape drives on-line Hardware Overview disk printer tape-drive CPU controller controller controller disk disk printer tape drives Computer Hardware system bus memory controller on-line memory disk printer tape-drive CPU controller controller controller system bus memory controller memory 5 / 34

  6. Hardware Overview Computer Hardware—CPU & Memory CS34 Computer Hardware—CPU & Memory 2013-05-17 Hardware Need to perform computation! Fetch Execute Start Overview Instruction Instruction ◮ Memory contains program instructions and program data Computer Hardware—CPU & Memory ◮ Processor registers maintain processor state. Registers include: ◮ General purpose (address & data) registers ◮ Instruction pointer (aka program counter) ◮ Stack pointer(s) Need to perform computation! ◮ Control and status registers Fetch Execute Start Instruction Instruction ◮ Memory contains program instructions and program data ◮ Processor registers maintain processor state. Registers include: ◮ General purpose (address & data) registers ◮ Instruction pointer (aka program counter) ◮ Stack pointer(s) ◮ Control and status registers 6 / 34

  7. Hardware I/O Hardware Computer Hardware—I/O Devices CS34 Computer Hardware—I/O Devices 2013-05-17 Need to communicate with the world! ◮ I/O devices and CPU execute concurrently Hardware ◮ Devices have hardware controllers ◮ Handles devices of a particular device type ◮ Some level of autonomy I/O Hardware ◮ Local buffer Need to communicate with the world! ◮ I/O is from the device to local buffer of controller disk disk printer tape drives Computer Hardware—I/O Devices on-line disk printer tape-drive CPU controller controller controller ◮ I/O devices and CPU execute concurrently system bus memory controller memory ◮ Devices have hardware controllers ◮ Handles devices of a particular device type ◮ Some level of autonomy ◮ Local buffer ◮ I/O is from the device to local buffer of controller disk disk printer tape drives on-line disk printer tape-drive CPU controller controller controller system bus memory controller memory 7 / 34

  8. Hardware I/O Hardware Programmed I/O CS34 Programmed I/O 2013-05-17 Hardware I/O Hardware After I/O starts, control returns to user program only on I/O completion ◮ CPU waits until I/O completes. ◮ At most one I/O request is outstanding at a time Programmed I/O ◮ No simultaneous I/O processing After I/O starts, control returns to user program only on I/O completion ◮ CPU waits until I/O completes. ◮ At most one I/O request is outstanding at a time ◮ No simultaneous I/O processing 8 / 34

  9. Hardware I/O Hardware Polled I/O CS34 Polled I/O 2013-05-17 Hardware I/O Hardware Polling == Querying the I/O device Separate I/O into two parts: ◮ Initiation Polled I/O ◮ Polling Advantages? Polling == Querying the I/O device Separate I/O into two parts: ◮ Initiation ◮ Polling Advantages? 9 / 34

  10. Hardware I/O Hardware Interrupt-Driven I/O CS34 Interrupt-Driven I/O 2013-05-17 Hardware I/O Hardware Separate I/O into two parts: ◮ Initiation ◮ Asynchronous notification Interrupt-Driven I/O Separate I/O into two parts: ◮ Initiation ◮ Asynchronous notification 10 / 34

  11. Hardware I/O Hardware I/O in User-Level Code CS34 I/O in User-Level Code 2013-05-17 Hardware I/O Hardware User-level code almost always uses “programmed I/O” (e.g. read and write on a file) I/O in User-Level Code Why? User-level code almost always uses “programmed I/O” (e.g. read and write on a file) Why? 11 / 34

  12. Hardware Interrupts Computer Hardware—CPU with Interrupts CS34 Computer Hardware—CPU with Interrupts 2013-05-17 CPU needs another feature. . . Hardware Fetch Execute Start Instruction Instruction Interrupts No Interrupts Enabled? CPU needs another feature. . . Yes Computer Hardware—CPU with Interrupts No Interrupt? Yes Jump to Save State Handler Fetch Execute Start Instruction Instruction No Interrupts Enabled? Yes No Interrupt? Yes Jump to Save State Handler 12 / 34

  13. Hardware Interrupts Handling an Interrupt CS34 Handling an Interrupt 2013-05-17 Hardware What needs to happen: Interrupts ◮ Save state ◮ All registers ◮ Switch stacks? ◮ Find out what interrupt was. . . Handling an Interrupt ◮ Polling ◮ Vectored interrupts What needs to happen: ◮ Save state ◮ All registers ◮ Switch stacks? ◮ Find out what interrupt was. . . ◮ Polling ◮ Vectored interrupts 13 / 34

  14. Hardware Interrupts Types of Interrupts CS34 Types of Interrupts 2013-05-17 Hardware Various types Interrupts ◮ Software exception (also called a trap) ◮ Timer ◮ I/O Types of Interrupts ◮ Hardware failure A modern operating system is interrupt driven Various types ◮ Software exception (also called a trap) ◮ Timer ◮ I/O ◮ Hardware failure A modern operating system is interrupt driven 14 / 34

  15. Hardware Interrupts Other Hardware Features CS34 Other Hardware Features 2013-05-17 Hardware We’ve covered interrupts, but hardware has other cool features, Interrupts including: ◮ Caches ◮ Memory management Other Hardware Features ◮ Protection We’ll come back to hardware as we address these topics. We’ve covered interrupts, but hardware has other cool features, including: ◮ Caches ◮ Memory management ◮ Protection We’ll come back to hardware as we address these topics. 15 / 34

  16. Synchronization Recap CS34 Recap 2013-05-17 Synchronization Solution to I/O waiting was: Recap Solution to I/O waiting was: 16 / 34

  17. Synchronization Recap CS34 Recap 2013-05-17 Synchronization Solution to I/O waiting was: ◮ Do something else during I/O! Recap But doing two (or more) things at once introduces headaches! Solution to I/O waiting was: ◮ Do something else during I/O! But doing two (or more) things at once introduces headaches! 16 / 34

  18. Synchronization Synchronization CS34 Synchronization 2013-05-17 Synchronization Uncontrolled access to shared data ⇒ Race conditions Synchronization Uncontrolled access to shared data ⇒ Race conditions 17 / 34

  19. Synchronization Example: The Bounded-Buffer Problem CS34 Example: The Bounded-Buffer Problem 2013-05-17 Synchronization Two threads: ◮ Producer : Creates data items ◮ Consumer : Uses them up Example: The Bounded-Buffer Problem We’ll look at the problem using a shared array. . . Two threads: ◮ Producer : Creates data items ◮ Consumer : Uses them up We’ll look at the problem using a shared array. . . 18 / 34

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend