A. Frank - P. Weisberg Operating Systems Functional View of Operating System.

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
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
1/23/2004CSCI 315 Operating Systems Design1 Computer System Structures Notice: The slides for this lecture have been largely based on those accompanying.
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
1 Lecture 2: Review of Computer Organization Operating System Spring 2007.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
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.
Abhinav Kamra Computer Science, Columbia University 2.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 2: Computer-System Structures.
Modified from Silberschatz, Galvin and Gagne ©2009 CS 446/646 Principles of Operating Systems Lecture 1 Chapter 1: Introduction.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
Computer-System Structures
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures 1/31/03 Computer System Operation I/O Structure.
1.1 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Instructor:
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.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 1: Introduction.
Operating System Concepts Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Objectives To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization.
Operating Systems Lecture 3 Computer Systems Review
Chapter 1. Introduction What is an Operating System? Mainframe Systems
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
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.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do Computer-System.
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.
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
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.
Chapter 2. Computer-System Structure Device controllers: synchronize and manage access to devices.
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
Lecturer Bilal Alqudah, PhD
Module 2: Computer-System Structures
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Module 2: Computer-System Structures
Presentation transcript:

A. Frank - P. Weisberg Operating Systems Functional View of Operating System

2 A. Frank - P. Weisberg Contents Computer System Organization Main Memory Management Memory Protection I/O Protection CPU Protection Types of Interrupts: 1.Traps 2.External interrupts 3.System calls

3 A. Frank - P. Weisberg Computer System Organization 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

4 A. Frank - P. Weisberg Storage Structure Main memory – only large storage media that the CPU can access directly. Secondary storage – extension of main memory that provides large nonvolatile storage capacity. Hard 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.

5 A. Frank - P. Weisberg Storage Hierarchy

6 A. Frank - P. Weisberg Performance of Various Levels of Storage

7 A. Frank - P. Weisberg Caching Important principle, performed at many levels in a computer (in hardware, operating system, software). Information in use is copied from slower to faster storage 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. Cache smaller than storage being cached: –Cache management is an important design problem. –Cache size and replacement policy matter.

8 A. Frank - P. Weisberg Main Memory Management Initial memory management techniques: 1.Minimal management – one program that manages memory for itself. No memory protection problems here. 2.Memory split – Resident Monitor and User Job/Program split the memory between them. 3.Memory Division – The operating system and a few user jobs divide the available memory between them.

9 A. Frank - P. Weisberg MS-DOS Memory Split

10 A. Frank - P. Weisberg Memory Management Dynamics Sharing system resources requires the operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly. Resident Monitor is a “Trusted Program” but how to protect it from damage by the user program? Solution: Fence Register (a dedicated register) and addressing access logic.

11 A. Frank - P. Weisberg Memory Split Resident Monitor User Program Fence Register 0K 64K 16K

12 A. Frank - P. Weisberg Fence Register The Fence Register is loaded with the base of the user program (which is also the limit of the Resident Monitor). The user program can read any address but addressing access logic assures that it can write only to addresses that are larger than the Fence Register value. The instruction to load the Fence Register has to be privileged (i.e., can be executed only by the Resident Monitor) – but how to ensure that?

13 A. Frank - P. Weisberg Dual-Mode Operation (1) Provide hardware support to differentiate between at least two modes of operations: –User mode: execution done on behalf of a user. –kernel mode: execution done on behalf of OS. Must ensure that a user program could never gain control of the computer in kernel mode. Privileged Instructions can be executed only in kernel mode. Solution: Mode bit (in Status Register).

14 A. Frank - P. Weisberg Dual-Mode Operation (2) Mode bit was added to computer hardware (in Status Register) to indicate the current mode: kernel/system (0) or user (1). When any type of interrupt occurs, interrupt hardware switches to kernel mode, at the correct service routine in the kernel address space – safe method! kerneluser Interrupt hardware set user mode instruction set kernel mode instruction? Should be privileged? No, there should be no such instruction!

15 A. Frank - P. Weisberg UNIX Memory Division

16 A. Frank - P. Weisberg Memory Division In order to have memory division protection, add two registers that determine the range of legal addresses a program may access: –base register – holds the smallest legal physical memory address of the program. –limit register – contains the size of the range. Base/Limit Registers are also called Lower/Upper Fence Registers. Memory outside the defined range is protected.

17 A. Frank - P. Weisberg Example of base and limit Registers

18 A. Frank - P. Weisberg Protection Hardware When executing in kernel mode, the operating system has unrestricted access to both system and user’s memory. The load instructions for the base and limit registers are privileged instructions (the read instructions for these registers need not be privileged). Privileged instructions can be issued only in kernel mode.

19 A. Frank - P. Weisberg Logic of Protection Hardware

20 A. Frank - P. Weisberg Traps A trap/exception is a software-generated interrupt caused by an error of the program, for example: –arithmetic overflow/underflow –division by zero –execute illegal instruction –reference outside user’s memory space. A trap can be initiated also by an explicit trap instruction in the program. The trap uses the interrupt hardware to switch to kernel mode.

21 A. Frank - P. Weisberg Memory Protection Summary We need to achieve memory protection!? 1.How to protect jobs in memory space? –use fence registers and addressing access logic. 2.But how to protect fence registers? –use privileged fence load instruction. 3.But how to ensure privileged execution? –use mode bit. 4.But how to protect mode bit? –change to kernel mode only by interrupt hardware!

22 A. Frank - P. Weisberg Computer Dynamics

23 A. Frank - P. Weisberg Instruction Cycle with Interrupts CPU checks for interrupts after each instruction. If no interrupts, then fetch next instruction of current program. If an interrupt is pending, then suspend execution of the current program, and execute the interrupt handler.

24 Transfer of control via interrupt A. Frank - P. Weisberg

25 Processing Sample Interrupt A. Frank - P. Weisberg

26 A. Frank - P. Weisberg Interrupt Handler A program that determines nature of the interrupt and performs whatever actions are needed. Interrupt transfers control to the interrupt handler, generally through the interrupt vector, which contains the addresses of all interrupt service routines, which determine how to handle. Interrupt architecture must save the state of the program (content of PC + registers +...). Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt. Later, control must be transferred back to the interrupted program so that it can be resumed from point of interruption.

27 A. Frank - P. Weisberg External Interrupts An external interrupt is a temporal suspension of a process caused by an event external to that process and performed in such a way that the process can be resumed. External Interrupts are caused by events external to that process: –I/O –Timer –Hardware failure

28 A. Frank - P. Weisberg Common Functions of External Interrupts Interrupt hardware transfers control to the interrupt service routine IH (Interrupt Handler), generally through the interrupt vector, which contains the addresses of all the service routines. Interrupt architecture must save the address of the interrupted instruction. Incoming interrupts are usually disabled while another interrupt is being processed to prevent a lost interrupt.

29 A. Frank - P. Weisberg Interrupt Driven I/O (1) I/O devices and the CPU can execute concurrently. Each device controller is in charge of a particular device type. Each device controller has a local buffer. CPU moves data from/to main memory to/from local buffers. I/O is from the device to local buffer of controller. Device controller informs CPU that it has finished its operation by causing an external interrupt.

30 A. Frank - P. Weisberg Interrupt Driven I/O (2)

31 A. Frank - P. Weisberg Interrupt-Driven I/O Cycle

32 A. Frank - P. Weisberg Interrupt Timeline of CPU and I/O Device

33 A. Frank - P. Weisberg Two I/O Methods (1) 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. Asynchronous I/O – After I/O starts, control returns to user program without waiting for I/O completion. –System call – request to OS 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.

34 A. Frank - P. Weisberg Two I/O Methods (2) Asynchronous Synchronous

35 A. Frank - P. Weisberg Device-Status Table

36 A. Frank - P. Weisberg Direct Memory Access (DMA) DMA is used by smart high-speed I/O devices able to transmit information at close to memory speeds. DMA 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 one interrupt per byte.

37 A. Frank - P. Weisberg I/O Protection User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions. All I/O devices need to be protected from wrongdoing by the users (e.g., prevent current program from reading control cards of next job). All I/O instructions need to be privileged instructions. Given that the I/O instructions are privileged, how does the user program perform I/O? Solution: System Calls (from programs).

38 A. Frank - P. Weisberg System Call The method used by a process to request action by the operating system: 1.After system call parameter preparations, it uses the trap instruction to transfer control to the requested service routine in the OS. 2.The system verifies that the parameters are correct and legal, and executes the request. 3.Returns control to the instruction following the system call.

39 A. Frank - P. Weisberg System Call Dynamics

40 A. Frank - P. Weisberg System Call to Perform I/O

41 A. Frank - P. Weisberg CPU Protection Timer – interrupts computer after specified period to ensure operating system maintains control. Programmable interval timer used for timings, periodic interrupts. Set timer is a privileged instruction. Timer is commonly used to implement Time Sharing Systems.

42 A. Frank - P. Weisberg Timer Dynamics Timer to prevent infinite loop, that is a process hogging resources: –Timer is set to interrupt the computer after some time period. –Keep counter that is decremented by physical clock. –OS sets the counter (privileged instruction). –When counter is zero generate an interrupt. –Set up before scheduling process to regain control or terminate program that exceeds allotted time.

43 A. Frank - P. Weisberg Interrupt Types and Attributes An operating system is interrupt driven: 1.Traps (Exceptions) 2.External interrupts 3.System calls Various interrupt attributes (see next chart): −Asynchronous vs. Synchronous. −External/Hardware vs. Internal/Software. −Implicit vs. Explicit.

44 A. Frank - P. Weisberg Attributes of Interrupt Types Asynchronous Synchronous External interrupts Internal/ Software Implicit Explicit External/ Hardware Traps System calls Interrupt types