Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do (previous.

Similar presentations


Presentation on theme: "Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do (previous."— Presentation transcript:

1 Chapter 1: Introduction

2 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do (previous lecture) Computer-System Organization Operating-System Structure Operating-System Operations Process Management Memory Management Storage Management

3 1.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 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 1.4 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Computer-System Operation 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 device moves data to local buffer of controller. Device controller informs CPU that it has finished its operation by causing an interrupt.

5 1.5 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Types of Interrupt Interrupt: Occurrence of an event is signaled by an interrupt from either hardware or software interrupt. Hardware Interrupt: hardware sends signal to the CPU. Software Interrupt: software executes a special operation (system call) When CPU is interrupted, it stops, transfer exec, to a fixed location. The fixed location contains the address of the service routine. When the service routine is completed, the CPU resumes the interrupted computation.

6 1.6 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Common Functions of Interrupts Interrupt transfers control to the interrupt service routine generally, through the interrupt vector interrupt service routine deals with the interrupt. It contains the addresses of all the service routines. Must save the address of the interrupted instruction. Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt. A trap is a software-generated interrupt caused either by an error or a user request. An operating system is interrupt driven.

7 1.7 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Interrupt Handling The OS preserves the state of the CPU by storing registers and the program counter. Determines which type of interrupt has occurred. Separate segments of code determine what action should be taken for each type of interrupt

8 1.8 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Computer Startup bootstrap program is loaded at power-up or reboot OS needs an initial program to run. Typically stored in ROM or (Erasable programmable read-only memory) EEPROM, generally known as firmware Initializates all aspects of system (CPU registers, device controllers, memory contents) Loads operating system kernel and starts execution

9 1.9 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Interrupt Timeline

10 1.10 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts I/O Structure General purpose computer system, consists of CPUs and multiple device controllers connected to through a common bus. Each device controller in charge of a specific type of device. Small computer-systems interface SCSI controller may attached to more than one device. A device controller maintains local buffer storage. It moves data between peripheral devices and it controls its local buffers. Typically, O.S. has a device driver to communicate with each device controller.

11 1.11 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts I/O Structure One interrupt per byte Starting I/O operation: Device driver load appropriate registers within device controller. Device controller examines instructions to determine what action to take (read a character from keyboard) Controller starts transfer data from device to its buffer. Controller informs device driver via an interrupt its finished. Device driver returns control to OS ( return data or pointer to data) This process is ok, for small data few characters. One interrupt per byte to let the device driver knows about the completion of the operation. How about huge amount of data.

12 1.12 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts I/O Structure One Interrupt Per Block For high volume of data, OS uses direct memory access DMA: After setting up buffers, pointers, counters for I/O devices, Device controller moves an entire block of data to or from its local buffers storage to memory, with no intervention by the CPU Only one interrupt is generated for each block to tell the device driver that the operation has completed, rather than the one interrupt per byte generated.

13 1.13 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts How computer works?

14 1.14 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Storage Structure Main memory –the CPU can access directly. Any program to run should be here. Secondary storage – extension of main memory that provides large storage capacity. 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.

15 1.15 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Storage Hierarchy Storage systems organized in hierarchy. Speed Cost size Volatility v.s. non-Volatility Caching – copying information into faster storage system; main memory can be viewed as a last cache for secondary storage.

16 1.16 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Storage-Device Hierarchy

17 1.17 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Caching Performed at many levels in a computer (in hardware, operating system, software) Information in use 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 important design

18 1.18 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Migration of Data Multitasking environments must be careful to use most recent value Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache Distributed environment situation even more complex Several copies of a datum can exist

19 1.19 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Storage Structure RAM random-access-memory (rewritable memory) ROM read-only-memory: cannot changed only static program EEPROM used in smart phones, stored factory- installed program Electronic disk: Volatile Non-volatile: usually contains hidden magnetic hard disk and a battery for a backup power  If the power interrupted, electronic disk controller copies data from RAM to magnetic disk.  When power restored, controller copies its contents back into RAM.  Other Examples: flash memory in camera and PDAs.

20 1.20 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Operating-System Operations Need to distinguish between OS code and user code. Two separate mode of operations: User mode: Kernel mode: (supervisor, system or privileged mode) A bit called mode bit added to the hardware to indicate the current mode kernel (0) or user (1). Dual-mode operation allows OS to protect itself and other system components User mode: when the computer is executed in behalf of a user application. Kernel mode when the computer is executed in behalf of OS. User application issues a system call to request a service from OS. Changed from user mode to kernel mode by changing mode bit to (0). at the system boot time, hardware starts in kernel mode.

21 1.21 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Operating-System Operations Mode bit provided by hardware  Provides ability to distinguish when system is running user code or kernel code  Some instructions designated as privileged, only executable in kernel mode  System call changes mode to kernel, return from call resets it to user Privileged instruction is a machine instruction, only executed in kernel mode. If an attempted is made to execute a privileged instruction in user mode, hardware does not execute it and treat it as illegal and traps it to OS. A system call is the method used by the process to request an action by the OS.

22 1.22 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Mode Transition

23 1.23 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Mode Transition Timer Timer to prevent infinite loop / process hogging resources Set interrupt after specific period Operating system decrements counter When counter zero generate an interrupt Set up before scheduling process to regain control or terminate program that exceeds the specified time.

24 1.24 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Process Management A process is a program in execution. It is a unit of work within the system. Program is a passive entity, like a file on a disk. process is an active entity. A process is a unite of work in a system. Process needs resources to accomplish its task CPU, memory, I/O, files Initialization data Process termination requires reclaim of any reusable resources.

25 1.25 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Process Management Single-threaded process has one program counter (specifying the next instruction to execute) Process executes instructions sequentially, one at a time, until completion Multi-threaded process has one program counter per thread Typically system has many processes, some users, some operating system running concurrently on one or more CPUs Concurrency by multiplexing the CPUs among the processes / threads

26 1.26 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Process Management Activities The operating system is responsible for the following activities in connection with process management: Scheduling processes and threads on the CPUs Creating and deleting both user and system processes Suspending and resuming processes Providing mechanisms for process synchronization Providing mechanisms for process communication

27 1.27 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Memory Management It has: All data in memory before and after processing All instructions in memory in order to execute Memory management determines what is in memory & when Optimizing CPU utilization and computer response to users Memory management activities Keeping track of which parts of memory are currently being used and by whom Deciding which processes and data to move into and out of memory Allocating and de-allocating memory space as needed

28 1.28 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Performance of Various Storage Movement between levels of storage hierarchy can be explicit or implicit


Download ppt "Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do (previous."

Similar presentations


Ads by Google