1 / 52

Operating System Concepts

Operating System Concepts. Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University. Chapter 2 Computer System Structures. General knowledge of the structure of a computer system System startup I/O Storage

blois
Download Presentation

Operating System Concepts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating System Concepts Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University

  2. Chapter 2 Computer System Structures • General knowledge of the structure of a computer system • System startup • I/O • Storage • Hardware protection • Network structure Chapter 2 Computer-System Structures

  3. Computer-System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure Summary Exercises Chapter 2 Computer System Structures Chapter 2 Computer-System Structures

  4. 2.1 Computer-System Operation • General-purpose computer system • Consist of • A CPU • A number of device controllers • Access to shared memory • A common bus • Execute simultaneously • Competing for memory cycles Chapter 2 Computer-System Structures

  5. A modern computer system Chapter 2 Computer-System Structures

  6. Bootstrap program • An initial program to run • Tend to be simple • Stored in ROM (Firmware or EEPROM) • Startup procedure • Locate and load the OS kernel into memory • Start executing the OS kernel • Executing first process, such as “init” • Waiting for some event to occur Chapter 2 Computer-System Structures

  7. Interrupt Driven • An event is signaled by an interrupt from • Hardware • Send a signal to CPU • Software – a special operation • a system call ( a monitor call) • A trap (or an exception) is a software-generated interrupt caused by • An error ( ex. division by zero) • A specific request from a user program Chapter 2 Computer-System Structures

  8. Interrupt Driven • For each type of interrupt, an interrupt service routine is provided to deal with the interrupt. • When the CPU is interrupted, it stops what it is doing and immediately transfers execution to a fixed location. • The fixed location contains the starting address where the service routine for the interrupt is located. • The interrupt service routine executes. • On completion, the CPU resumes the interrupted computation. Chapter 2 Computer-System Structures

  9. Interrupt time line for a single process doing output Chapter 2 Computer-System Structures

  10. Interrupt Vector • Interrupts must be handled quickly • A predefined number of interrupts is possible • A table of pointers to interrupt routines • Interrupt vector • Stored in low memory • Indexed by a unique device number • Save the address of the interrupted instruction • Fixed location • A location indexed by the device number • System stack Chapter 2 Computer-System Structures

  11. Computer-System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure Summary Exercises Chapter 2 Computer System Structures Chapter 2 Computer-System Structures

  12. 2.2.1 I/O Interrupts • Start an I/O operation • The CPU loads the registers within the device controller. • The device controller examines the registers to determine what actions to take. • I/O in progress • The device controller informs the CPU • Triggering an interrupt Chapter 2 Computer-System Structures

  13. Synchronous I/O • After I/O starts, control returns to user program only upon I/O completion. • Wait instruction idles the CPU until the next interrupt • Wait loop (contention for memory access). • At most one I/O request is outstanding at a time, no simultaneous I/O processing. Chapter 2 Computer-System Structures

  14. Asynchronous I/O • After I/O starts, control returns to user program without waiting for I/O completion. • System call – request to the operating system to allow user to wait for I/O completion. • Device-status table contains entry for each I/O device indicating its type, address, and state. • Operating system indexes into I/O device table to determine device status and to modify table entry to include interrupt. Chapter 2 Computer-System Structures

  15. Two I/O methods (a) Synchronous (b) Asynchronous Chapter 2 Computer-System Structures

  16. Device-status table Chapter 2 Computer-System Structures

  17. 2.2.2 DMA Structure • Used for high-speed I/O devices able to transmit information at close to memory speeds. • Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention. • Only one interrupt is generated per block, rather than the one interrupt per byte. • Cycle stealing • DMA controller “steals” memory cycles from the CPU. Chapter 2 Computer-System Structures

  18. Computer-System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure Summary Exercises Chapter 2 Computer System Structures Chapter 2 Computer-System Structures

  19. 2.3 Storage Structure • Main memory • Also called random-access memory or RAM • Computer programs must reside in • The only large area the CPU can access directly • An array of memory words • load and store • Specific memory addresses • Von Neumann architecture • Instruction register • Other internal registers Chapter 2 Computer-System Structures

  20. 2.3 Storage Structure • Ideally, programs and data reside in main memory permanently. • Not possible, because • Main memory is too small • Main memory is a volatile storage • Second storage • An extension of main memory • The most common device is a magnetic disk Chapter 2 Computer-System Structures

  21. 2.3.1 Main Memory • CPU can access directly • Main memory • Registers built in the processor • Cache • Fast memory between the CPU and main memory • Memory-mapped I/O • Ranges of memory addresses are mapped to the device registers. • Devices have fast response times, such as video controllers. Chapter 2 Computer-System Structures

  22. 2.3.2 Magnetic Disks • The bulk of secondary storage for modern computer system. • Disk platter • A flat circular shape like a CD • Covered with a magnetic material • Consists of • Tracks • Sectors • Cylinders • Disk arm Chapter 2 Computer-System Structures

  23. Moving-head disk mechanism Chapter 2 Computer-System Structures

  24. 2.3.3 Magnetic Tapes • Early secondary-storage medium • Features • Relatively permanent • Hold large quantities of data • Access time is slow • Purposes • Backup • Storage of infrequently used information • Transferring system information Chapter 2 Computer-System Structures

  25. Computer-System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure Summary Exercises Chapter 2 Computer System Structures Chapter 2 Computer-System Structures

  26. 2.4 Storage Hierarchy • Wide variety of storage systems can be organized in a hierarchy according to • Speed • Cost • Volatility • Volatile storage • Lose contents when the power is removed • Ex. register, cache, main memory • Non-volatile storage • Keep contents all the time • Ex. magnetic disk, optical disk, magnetic tapes Chapter 2 Computer-System Structures

  27. Storage-device hierarchy Chapter 2 Computer-System Structures

  28. 2.4.1 Caching • Use of high-speed memory to hold recently-accessed data. • Requires a cache management policy. • Caching introduces another level in storage hierarchy. • This requires data that is simultaneously stored in more than one level to be consistent. Chapter 2 Computer-System Structures

  29. Migration of integer A from disk to register 2.4.2 Coherency and Consistency • The same data may appear in different levels of the storage system. Chapter 2 Computer-System Structures

  30. 2.4.2 Coherency and Consistency • Only one process at a time • The highest level of the hierarchy • Multitasking • Extreme care must be taken • Multiprocessor • Cache coherency (hardware problem) • A copy of A may exist in several caches • Distributed environment • Consistency • Several copies (replicas) on different computers Chapter 2 Computer-System Structures

  31. Computer-System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure Summary Exercises Chapter 2 Computer System Structures Chapter 2 Computer-System Structures

  32. 2.5 Hardware Protection • Early computer systems • Single-user programmer-operated systems • Operating systems were called resident monitors • Sharing system resources • Improve utilization • Increase problems • Many processes could be affected by a bug in one program. • All output must be suspect • Many programming errors • Detected by the hardware • Handled by the operating system Chapter 2 Computer-System Structures

  33. 2.5 Hardware Protection • Dual-Mode Operation • I/O Protection • Memory Protection • CPU Protection Chapter 2 Computer-System Structures

  34. 2.5.1 Dual-Mode Operation • Sharing system resources • OS ensures that an incorrect program cannot cause other programs to execute incorrectly. • Provide hardware support to differentiate between at least two modes of operations. 1. User mode– execution done on behalf of the user. 2.Monitor mode (also kernel mode, system mode, or privileged mode) – execution done on behalf of the operating system. Chapter 2 Computer-System Structures

  35. 2.5.1 Dual-Mode Operation • Mode bit - A bit added to the hardware to indicate the current mode: • Monitor (0) • User (1) • Whenever a trap or interrupt occurs, the hardware switches from user mode to monitor mode. • At boot time, the hardware starts in monitor mode. • OS runs in monitor mode. • User programs run in user mode. Chapter 2 Computer-System Structures

  36. 2.5.1 Dual-Mode Operation Trap/Interrupt • Privileged instructions • May cause harm • Executed only in the monitor mode • By the OS • Known as a system call ( also a monitor call or an OS function call) monitor user set user mode Chapter 2 Computer-System Structures

  37. 2.5.2 I/O Protection • All I/O instructions are defined to be privileged instructions. • The user program executes a system call to request an I/O. • OS can check if the I/O request is valid or not • If valid, OS does the I/O request, and returns to the user. • Must ensure that a user program could never gain control of the computer in monitor mode (i.e., a user program that, as part of its execution, stores a new address in the interrupt vector). Chapter 2 Computer-System Structures

  38. Use of a system call to perform I/O Chapter 2 Computer-System Structures

  39. 2.5.3 Memory Protection • Must provide memory protection at least for • Interrupt vector • Interrupt-service routines • Such protection must be provided by the hardware. • One possible implementation • Base register • The smallest legal physical memory address • Limit register • The size of the range Chapter 2 Computer-System Structures

  40. Use of a base and limit register Chapter 2 Computer-System Structures

  41. Hardware address protectionwith base and limit registers Chapter 2 Computer-System Structures

  42. 2.5.4 CPU Protection • A timer • interrupts computer after specified period to ensure operating system maintains control. • The OS sets the counter. • Be decremented every clock tick. • When the counter reaches the value 0, an interrupt occurs. • Timer instructions are privileged. Chapter 2 Computer-System Structures

  43. 2.5.4 CPU Protection • Functionality • Prevent a user program from running too long • Implement time sharing. • The time slice • Compute the current time. Chapter 2 Computer-System Structures

  44. Computer-System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure Summary Exercises Chapter 2 Computer System Structures Chapter 2 Computer-System Structures

  45. 2.6 Network Structure • Two basic types of networks • LAN: local-area network • Small geographical areas • Higher speed and lower error rate • 10BaseT Ethernet: 10 megabits per second • 100BaseT Ethernet: 100 megabits per second • Gigabit Ethernet: 1 gigabits per second • WAN: wide-area network • Large geographical areas • Slow and unreliable • T1: 1.544 megabits per second • T3 (28 T1 connections) : 45 megabits per second Chapter 2 Computer-System Structures

  46. Local-area network Chapter 2 Computer-System Structures

  47. Communication processorsin a wide-area network Chapter 2 Computer-System Structures

  48. Computer-System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure Summary Exercises Chapter 2 Computer System Structures Chapter 2 Computer-System Structures

  49. Summary • P.51 – P.52 Chapter 2 Computer-System Structures

  50. Computer-System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure Summary Exercises Chapter 2 Computer System Structures Chapter 2 Computer-System Structures

More Related