principle of operating system chapter 1

Download Principle Of Operating System Chapter 1

If you can't read please download the document

Upload: satyamevjayte-haxor

Post on 19-Jun-2015

392 views

Category:

Software


0 download

DESCRIPTION

Principle Of Operating System Chapter 1

TRANSCRIPT

  • 1. INTRODUCTIONProf. Mrs. Trupti S. IndiWalchand Institute of TechnologyDepartment of Information TechnologySolapur University

2. What is an Operating System? A program that acts as an intermediary between a userof a computer and the computer hardware. Operating system goals: Execute user programs and make solving user problemseasier. Make the computer system convenient to use. Use the computer hardware in an efficient manner.2Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 3. Computer System Structure Computer system can be divided into four components Hardware provides basic computing resources CPU, memory, I/O devices Operating system Controls and coordinates use of hardware among variousapplications and users Application programs define the ways in which thesystem resources are used to solve the computingproblems of the users Word processors, compilers, web browsers, database systems,video games Users People, machines, other computers3Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 4. Four Components of a Computer System4Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 5. Operating System Definition OS is a resource allocator Manages all resources Decides between conflicting requests for efficient andfair resource use OS is a control program Controls execution of programs to prevent errors andimproper use of the computer5Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 6. Operating System Definition (Cont.) No universally accepted definition Everything a vendor ships when you order an operatingsystem is good approximation But varies wildly The one program running at all times on the computer isthe kernel. Everything else is either a system program(ships with the operating system) or an application program6Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 7. Computer Startup bootstrap program is loaded at power-up orreboot Typically stored in ROM or EPROM, generallyknown as firmware Initializates all aspects of system Loads operating system kernel and startsexecution7Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 8. Computer Startup8Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 9. Computer Startup9Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 10. Computer System Organization Computer-system operation One or more CPUs, device controllers connect throughcommon bus providing access to shared memory Concurrent execution of CPUs and devices competing formemory cycles10Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 11. 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 is from the device to local buffer of controller. Device controller informs CPU that it has finished its operation bycausing an interrupt.11Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 12. Interrupts The occurrence of an event is signaled by an interrupt fromhardware or software. Hardware interrupt can be triggered by sending a signal tothe CPU Software interrupt can be triggered by executing specialoperation called system call (or monitor call)A trap is a software-generated interrupt caused either by anerror (e.g. divide by zero) or invalid memory address orspecific request from user program. An operating system Prof. is interrupt T. S. Indi, Walchand driven. Institute of12Technology, Solapur University 13. Interrupt Driven Operating System For each type of interrupt, separate segments of code in theOS (called __________?__________) determine what actionshould be taken. ISR is responsible for dealing with the interrupt.13Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 14. Interrupt Driven Operating SystemSteps:1. When the CPU is interrupted, it stops what it is doing &immediately transfers execution to a fixed location.2. The fixed location contains the starting address of where theservice routine for the interrupt is located.3. The ISR executes; on completion, the CPU resumes theinterrupted computation.14Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 15. Interrupt Driven Operating System The interrupt routine is called through the table of pointers whichis stored in low memory These locations hold the addresses of the interrupt serviceroutines for the various devices. This array of addresses is calledInterrupt Vector.15Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 16. Interrupt Handling The operating system preserves the stateof the CPU by storing registers and theprogram counter. Determines which type of interrupt hasoccurred: polling vectored interrupt system Separate segments of code determinewhat action should be taken for each typeof interrupt16Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 17. Interrupt Timeline17Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 18. I/O Structure Synchronous I/O: After I/O starts, control returns to user program only uponI/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 withoutwaiting 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 tableentry to include interrupt.18Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 19. Two I/O Methods19Synchronous AsynchronousProf. T. S. Indi, Walchand Institute ofTechnology, Solapur University 20. Synchronous & Asynchronous I/OSynchronous I/O: read() or write() will block a user process until its completion OS overlaps synchronous I/O with another processAsynchronous I/O: read() or write() will not block a user process the user process can do other things before I/O completion I/O completion will notify the user process20Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 21. Device-Status Table21Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 22. Device Controllers A device controller is a part of a computer system that makes sense of thesignals going to, and coming from the CPU. There are many device controllers in a computer system. Any device connected to the computer is connected by a plug and socket,and the socket is connected to a device controller. Each device controller has a local buffer and a command register. It communicates with the CPU by interrupts. A device's controller plays an important role in the operation of thatdevice; it functions as a bridge between the device and the operatingsystem.22Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 23. Device Controllers A computer system contains a multitude of I/O devicesand their respective controllers: network card graphics adapter disk controller DVD-ROM controller serial port USB sound card Each device controller maintains a set of deviceregisters:- command registers (write-only);- status registers (read-only);- data registers (read/write).23Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 24. Device ControllersDevice controller- Status registerready: if the host is donebusy: if the controller is doneint: interrupt- Data registerA simple mouse design- Put (X, Y) in data registers on a move- Interrupt- Input on an interrupt- Read values in X, Y registers- Set ready bit- Wake up a process/thread or execute a piece of codeInput on an interrupt- Read values in X, Y registers- Set ready bit- Wake up a process/thread or execute a piece of code24Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 25. Device Controllers The CPU can access those registersthrough- special I/O instructions (in/out in Intelassembler) or- via memory mapping. Memory mapping is handled by thememory controller and is usually fasterthan explicit I/O instructions. When interacting with a devicecontroller, the CPU can wait for aresponse by polling the statusregister(s), i.e., by periodically checkingwhether the status of the device haschanged.I/O Software Stacks25Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 26. Device Drivers In computing, a device driver is a computerprogram that operates or controls a particulartype of device that is attached to a computer. A driver provides a software interface tohardware devices, enabling operating systemsand other computer programs to accesshardware functions without needing to knowprecise details of the hardware being used.26Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 27. I/O Software Stack27Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 28. I/O Interrupts To start an I/O operation, the CPU loads the appropriateregisters within the device controller. The device controller examines the contents of theseregisters to determine what action to taken. For Example: If it finds read request, the controller willstart the transfer of data from the device to its local buffer.Once the transfer of data is complete the device controllerinforms the CPU that it has finished its operation bytriggering an interrupt.28Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 29. QuizInstructions: Get into your Group For every question discuss within group andconclude answer with explanation (Duration:5 mins) Each group for correct answer (2 mks) and forvalid explanation (3mks) Same/Copy explanation reduction of 2mks29Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 30. Q. 1) Which is the layer of a computer systembetween the hardware and the user program?(A) Operating System(B) Operating Environment(C) System Environment(D) None30ANSWER: Operating SystemProf. T. S. Indi, Walchand Institute ofTechnology, Solapur University 31. Q. 2) The primary purpose of an operatingsystem is?(A) To make computers easier to use(B) To make the most efficient use of thecomputer hardware(C) To keep system programmers employed(D) To allow the people to use the computers31ANSWER:To make the most efficient use of thecomputer hardwareProf. T. S. Indi, Walchand Institute ofTechnology, Solapur University 32. Q. 3) The primary purpose of an operatingsystem is?(A) To make computers easier to use(B) To make the most efficient use of thecomputer hardware(C) To keep system programmers employed(D) To allow the people to use the computers32ANSWER:Operating SystemProf. T. S. Indi, Walchand Institute ofTechnology, Solapur University 33. Q. 4) Which run on computer hardware andserve as platform for other software to runon?(A) Application Software(B) Operating System(C) System Software(D) All33ANSWER:Operating SystemProf. T. S. Indi, Walchand Institute ofTechnology, Solapur University 34. Q. 5) When a computer is first turned on orrestarted, a special type of absolute loadercalled _____________ is executed(A) Compile and go loader(B) Bootstrap loader(C) Boot loader(D) Relating loader34ANSWER:Bootstrap loaderProf. T. S. Indi, Walchand Institute ofTechnology, Solapur University 35. Direct Memory Access Structure Used for high-speed I/O devices able to transmitinformation at close to memory speeds. Device controller transfers blocks of data from bufferstorage directly to main memory without CPUintervention. Only one interrupt is generated per block, ratherthan the one interrupt per byte.35Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 36. Storage Structure Main memory only large storage media that the CPU can accessdirectly. Secondary storage extension of main memory that provides largenonvolatile storage capacity. Magnetic disks rigid metal or glass platters covered with magneticrecording material Disk surface is logically divided into tracks, which are subdivided intosectors. The disk controller determines the logical interaction between thedevice and the computer.36Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 37. Storage Hierarchy Storage systems organized in hierarchy.SpeedCostVolatility Caching copying information into fasterstorage system; main memory can be viewedas a last cache for secondary storage.37Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 38. Storage-Device Hierarchy38Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 39. Caching Important principle, 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 problem Cache size and replacement policy39Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 40. Performance of Various Levels of Storage Movement between levels of storage hierarchy canbe explicit or implicit40Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 41. Migration of Integer A from Disk to Register Multitasking environments must be careful to use mostrecent value, no matter where it is stored in the storagehierarchy Multiprocessor environment must provide cache coherencyin hardware such that all CPUs have the most recent valuein their cache Distributed environment situation even more complex Several copies of a datum can exist Various solutions covered in Chapter 1741Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 42. Operating System Structure Multiprogramming needed for efficiency Single user cannot keep CPU and I/O devices busy at all times Multiprogramming organizes jobs (code and data) so CPU always has one to execute A subset of total jobs in system is kept in memory One job selected and run via job scheduling When it has to wait (for I/O for example), OS switches to another job42Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 43. Operating System Structure Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently thatusers can interact with each job while it is running, creating interactive computing Response time should be < 1 second Each user has at least one program executing in memory process If several jobs ready to run at the same time CPU scheduling If processes dont fit in memory, swapping moves them in and out to run Virtual memory allows execution of processes not completely in memory43Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University 44. END44Prof. T. S. Indi, Walchand Institute ofTechnology, Solapur University