Operating Systems Lecture 3 Computer Systems Review

Slides:



Advertisements
Similar presentations
Computer-System Structures Er.Harsimran Singh
Advertisements

Interactive lesson about operating system
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
1/21/2008CSCI 315 Operating Systems Design1 Operating System Structures Notice: The slides for this lecture have been largely based on those accompanying.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
ICS Principles of Operating Systems
Abhinav Kamra Computer Science, Columbia University 2.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 2: Computer-System Structures.
1/26/2004CSCI 315 Operating Systems Design1 Operating System Structures Notice: The slides for this lecture have been largely based on those accompanying.
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
Computer-System Structures
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures 1/31/03 Computer System Operation I/O Structure.
A. Frank - P. Weisberg Operating Systems Functional View of Operating System.
Silberschatz, Galvin and Gagne  Operating System Concepts Common System Components Process Management Main Memory Management File Management.
1/21/2010CSCI 315 Operating Systems Design1 Computer System Structures Notice: The slides for this lecture have been largely based on those accompanying.
Chapter 2: Computer-System Structures
What do operating systems do? manage processes manage memory and computer resources provide security features execute user programs make solving user.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts What is an Operating System? A program that acts as an intermediary.
Abhinav Kamra Computer Science, Columbia University 3.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 3: Operating-System Structures.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
CHAPTER 2 OPERATING SYSTEM OVERVIEW 1. Operating System Operating System Definition A program that controls the execution of application programs and.
Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System.
2.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 2: Computer-System Structures Computer System Operation I/O Structure.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 2: Computer-System Structures Computer System Operation I/O Structure.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures
Thanks to Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2 Computer-System Structures n Computer System Operation n I/O Structure.
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
2: Computer-System Structures
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.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do (previous.
Chapter 2: Computer-System Structures 2.1 Computer System Operation 2.5 Hardware Protection 2.6 Network Structure.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Silberschatz and Galvin  Operating System Concepts Module 3: Operating-System Structures System Components Operating System Services System Calls.
Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure.
2.1 Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation Storage Structure Storage Hierarchy Hardware Protection General.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 4 Computer Systems Review.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
BIT213,CISY Operating Systems 1
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.
Review of Computer System Organization. Computer Startup For a computer to start running when it is first powered up, it needs to execute an initial program.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures(Hardware) or Architecture or Organization Computer System Operation I/O Structure Storage Structure Storage Hierarchy.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 3: Operating-System Structures System Components Operating System Services.
Chapter 2. Computer-System Structure Device controllers: synchronize and manage access to devices.
System Components Operating System Services System Calls.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives To provide a grand tour of the major operating.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures(Hardware)
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Computer-System Architecture
Module 2: Computer-System Structures
Chapter 2: Operating-System Structures
Introduction to Operating Systems
Module 2: Computer-System Structures
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Chapter 2: Operating-System Structures
Module 2: Computer-System Structures
Presentation transcript:

Operating Systems Lecture 3 Computer Systems Review Operating System Concepts

Computer System Components CPU I/O controllers (e.g. disk controller) Memory Controller The CPU and device controllers can operate concurrently. The Memory controller ensures orderly access to shared memory. Operating System Concepts

Computer-System Architecture Computer-system operation One or more CPUs, device controllers connect through common bus providing access to shared memory. Concurrent execution of CPUs and devices competing for memory cycles. Operating System Concepts

Interrupt Driven O.S. Most modern operating systems are interrupt driven. Start-up: 1) Bootstrap: Load O.S. (kernel) and start it running. 2) O.S. waits for an event (an interrupt). Definition of interrupt: An interrupt is a method to ensure that the CPU takes note of an event. Types of interrupt: Hardware interrupts (e.g. from an I/O device) Software interrupt (from an executing process. System Call) Also called a trap or an exception Generated to signal error (e.g. divide by zero) or to request service from OS (e.g. I/O). Operating System Concepts

Interrupt Handling The operating system preserves the state of the CPU by storing registers and the program counter. The O.S. determines which type of interrupt has occurred by one of two methods: polling each device ("Did you interrupt me?") vectored interrupt system (Table of addresses) Separate segments of code determine what action should be taken for each type of interrupt. The OS executes the sequence of commands associated with the given interrupt. The OS recovers the stored information from the original process and continues execution. Operating System Concepts

Interrupt Time Line For a Single Process Doing Output Operating System Concepts

Synchronous I/O Synchronous I/O: After I/O starts, control returns to user program only upon I/O completion. Process requests I/O CPU sends I/O request to device controller CPU waits for I/O to finish (signalled by interrupt) Continue executing original process (after handling interrupt) At most one I/O request is outstanding at a time, no simultaneous I/O processing. Problem: I/O is slow. CPU is idle while waiting for I/O to finish. Operating System Concepts

Asynchronous I/O Asynchronous I/O After I/O starts, control returns to user program without waiting for I/O completion. Process requests I/O CPU sends request to device controller CPU continues to process instructions (either previous process or another one). Interrupt signals I/O completion CPU processes interrupt Less time is used to process I/O requests using asynchronous I/O than with synchronous I/O. Operating System Concepts

Two I/O Methods Synchronous Asynchronous Operating System Concepts

Other Considerations When using asynchronous I/O, there may be multiple I/O requests at the same time. Requests for multiple devices Multiple requests for a single device. A device-status table keeps track of the requests. It stores: Device type Device address Device State (not-functioning, idle, busy) Wait queues list multiple requests for a single device. Operating System Concepts

Device-Status Table Operating System Concepts

Direct Memory Access Structure If only 1 character is transferred per I/O request, then an interrupt is generated after each character is transferred. Slow I/O device (e.g. modem): ~1 ms/char = 1000 ms/char Time needed to process interrupt: ~2 ms This leaves 998 ms for processing other things. Fast I/O device (e.g. hard disk): ~4 ms/char Only leaves 2 ms to process other things. Solution: Direct Memory Access (DMA) Used for high speed I/O devices. 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. Operating System Concepts

Storage Structure The Fetch-Execute Cycle: Computer programs must be in main memory to be executed. The CPU fetches the next instruction (from the address stored in the instruction counter) The CPU executes the instruction: This may involve fetching operands from main memory. It may also involve storing the result in main memory. Ideally, we would want all programs stored in main memory. This is impractical because: Main memory is too small to store all needed programs and data. Main memory is volatile. It loses its contents when the power goes off. Operating System Concepts

Secondary Storage Main memory – only large storage media that the CPU can access directly. Secondary storage – extension of main memory that provides large nonvolatile storage capacity. Most common type of secondary storage: Magnetic disks – rigid metal or glass platters covered with magnetic recording material Disk surface is logically divided into tracks, which are subdivided into sectors. The disk controller determines the logical interaction between the device and the computer. Other types of storage: Cache, CD_ROM, Magnetic tape. Operating System Concepts

Moving-Head Disk Mechanism Operating System Concepts

Storage Hierarchy Storage systems organized in hierarchy. Speed Cost Volatility The fastest memory is the most expensive and most volatile. Used for CPU registers. As move down the hierarchy, memory gets slower and cheaper. Non-volatile memory is the slowest. Operating System Concepts

Storage-Device Hierarchy Operating System Concepts

Caching Accessing main memory can be slow compared to the time it takes to execute instructions. Caching is the use of high-speed memory to hold recently-accessed data. Blocks of instructions or data from main memory are transferred to a smaller, faster memory: the cache. Locality of reference ensures efficient use of the cache: As a process executes, it references memory in clustered areas. Nearby memory locations are likely to be accessed in the near future. Therefore, when one item is requested from main memory, an entire block is transferred to the cache. Use of a cache 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. Operating System Concepts

Maintaining Consistency An operating system needs to maintain consistency at different levels of the storage system. Example: Suppose an integer, A, is stored in a file, B, on the disk. Suppose we want to increment A by 1. A is copied from disk to main memory. A is copied from main memory to cache A is copied from the cache to a register. We now have 4 copies of A. A is incremented in the register. Now A has different values in different locations. The OS must ensure that any process wanting to access A gets the most recently updated version. Operating System Concepts

Migration of A From Disk to Register Operating System Concepts

Dual-Mode Operation Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly. E.g. Writing over memory used by another program Writing to the same output device at the same time Many O.S.'s provide hardware support to differentiate between at least two modes of operations. 1. User mode – execution done on behalf of a user. 2. Monitor mode (also kernel mode or system mode) – execution done on behalf of operating system. Operating System Concepts

Dual-Mode Operation (Cont.) Mode bit added to computer hardware to indicate the current mode: monitor (or kernel) (0) or user (1). When an interrupt or fault occurs hardware switches to monitor mode. Interrupt/fault monitor user set user mode Privileged instructions can be issued only in monitor mode. Operating System Concepts

System Calls When a user program needs O.S. service, it makes a system call. The system call is treated as a software interrupt. The mode switches to monitor mode. The O.S. makes sure all the parameters are legal. After processing the interrupt, the O.S. switches to user mode and returns to the user process. If a process tries to execute privileged instructions while in user mode, the hardware generates a trap (exception). The O.S. will usually terminate the user program (and may generate a core dump). Operating System Concepts

I/O Protection A user program can disrupt the operation of a system by: Issuing illegal I/O instructions Accessing memory locations within the O.S. Refusing to relinquish the CPU I/O Protection: All I/O instructions are privileged instructions. 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). All I/O is performed through system calls. Operating System Concepts

Use of A System Call to Perform I/O Operating System Concepts

Memory Protection Must provide memory protection at least for the interrupt vector and the interrupt service routines. In order to have memory protection, add two registers that determine the range of legal addresses a program may access: Base register – holds the smallest legal physical memory address. Limit register – contains the size of the range Memory outside the defined range is protected. Note: The O.S. in monitor mode has unrestricted access to all memory. The load instructions for the base and limit registers are privileged instructions. Operating System Concepts

Use of A Base and Limit Register Operating System Concepts

Hardware Address Protection Operating System Concepts

CPU Protection The Operating System must protect the CPU from being taken over by a user program (e.g. in an infinite loop). Timer – interrupts computer after specified period to ensure operating system maintains control. Timer is decremented every clock tick. When timer reaches the value 0, an interrupt occurs. Timer commonly used to implement time sharing. Timer also sometimes used to compute the current time. Load-timer is a privileged instruction. Operating System Concepts

Common System Components An operating system is a large, complex program. It must be subdivided into smaller pieces to manage it. Common components of an operating system include: Process Management Main Memory Management File Management I/O System Management Secondary Management Networking Protection System Command-Interpreter System Operating System Concepts

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 handling deadlocks Operating System Concepts

Main Memory Management Programs must be mapped to absolute addresses and loaded into memory. The executing program must have access to instructions and data from main memory by generating absolute addresses. The operating system is responsible for the following activities in connections with memory management: Keep track of which parts of memory are currently being used and by whom. Decide which processes to load when memory space becomes available. Allocate and deallocate memory space as needed. Operating System Concepts

File Management A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data. The operating system is responsible for the following activities in connections with file management: File creation and deletion. Directory creation and deletion. Support of primitives for manipulating files and directories. Mapping files onto secondary storage. File backup on stable (nonvolatile) storage media. Operating System Concepts

I/O System and Secondary Storage Management I/O Management The I/O system consists of: Memory management: A buffer-caching system A general device-driver interface Drivers for specific hardware devices Secondary Storage Management The operating system is responsible for the following activities in connection with disk management: Free space management Storage allocation Disk scheduling Operating System Concepts

Networking The O.S. handles communication between computers on a network through protocols: ftp: File transfer protocol http: Hypertext transfer protocol The O.S. Must manage communication and access to shared resources. Operating System Concepts

Protection System Protection refers to a mechanism for controlling access by programs, processes, or users to both system and user resources. Security – defense of the system against internal and external attacks Huge range, including denial-of-service, worms, viruses, identity theft, theft of service The protection mechanism must: distinguish between authorized and unauthorized usage. specify the controls to be imposed. provide a means of enforcement. Operating System Concepts

The Command-Interpreter System The Command-interpreter is the interface between the user and the system. In UNIX, it is the shell. Its function is to get and execute the next instruction. Many commands are given to the operating system by control statements which deal with: process creation and management I/O handling secondary-storage management main-memory management file-system access protection networking Operating System Concepts

Operating System Services Program execution – system capability to load a program into memory and to run it. I/O operations – since user programs cannot execute I/O operations directly, the operating system must provide some means to perform I/O. File-system manipulation – program capability to read, write, create, and delete files. Communications – exchange of information between processes executing either on the same computer or on different systems tied together by a network. Implemented via shared memory or message passing. Error detection – ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs. Operating System Concepts

Additional O.S. functions Additional functions exist not for helping the user, but rather for ensuring efficient system operations. Resource allocation – allocating resources to multiple users or multiple jobs running at the same time. Accounting – keep track of and record which users use how much and what kinds of computer resources for account billing or for accumulating usage statistics. Protection – ensuring that all access to system resources is controlled. Operating System Concepts