1 / 38

CS 345

CS 345. 1. Compile and Validate. A task is a unit of execution (also referred to as a process). A shell (Command Language Interpreter) is a task that functions as an interface between the user and an Operating System.

huela
Download Presentation

CS 345

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. CS 345 OS Overview (Chapter 1)

  2. 1. Compile and Validate • A task is a unit of execution (also referred to as a process). • A shell (Command Language Interpreter) is a task that functions as an interface between the user and an Operating System. • A shell interprets textual commands coming either from the user’s keyboard or from a script file and executes the commands either directly or creates a new child process to execute the command. For Project 1: • Download all the project files from class website. • os345.c, os345interrupts.c, os345signals.c os345tasks.c, os345semaphores.c • os345.h, os345config.h, os345signals.h • os345p1.c,os345p2.c, os345p3.c, os345p4.c, os345p5.c, os345p6.c • os345park.c, os345park.h, os345lc3.c, os345lc3.h, os345mmu.c, os345fat.c, os345fat.h • Edit os345config.h (if necessary) to select host OS/IDE/ISA. (Only enable one of the following defines: DOS, GCC, MAC, or NET.) • Compile and execute your OS. Project 1 - Shell

  3. Why CS 345? OS Overview (Chapter 1)

  4. Operating Systems • What is an operating system? • Hard to define precisely, because operating systems arose historically as people needed to solve problems associated with using computers. • How about… “Software that makes computing power available to users by controlling the hardware.” “Software executes when nothing else is happening.” “A collection of software modules including device drivers, libraries, and access routines.” OS Overview (Chapter 1)

  5. What Does a Modern OS Do? • Provides Abstractions: • Hardware has low-level physical resources with complicated, idiosyncratic interfaces. • OS provides abstractions that present clean interfaces. • Goal: make computer easier to use. • Examples: Processes, Unbounded Memory, Files, Synchronization and Communication Mechanisms. • Provides Standard Interface: • Goal: portability. • Unix runs on many very different computer systems. OS Overview (Chapter 1)

  6. What Does a Modern OS Do? • Mediates Resource Usage: • Goal: allow multiple users to share resources fairly, efficiently, safely and securely. • Examples: • Multiple processes share one processor. (preemptable resource) • Multiple programs share one physical memory (preemptable resource). • Multiple users and files share one disk. (non-preemptable resource) • Multiple programs share a given amount of disk and network bandwidth (preemptable resource). • Consumes Resources: • Solaris takes up about 8 Mbytes physical memory (or about $400). OS Overview (Chapter 1)

  7. The Future… • In the future, computers will continue to become physically smaller and more portable. • Operating systems have to deal with issues like disconnected operation and mobility. • Media rich information within the grasp of common people - information with psuedo-real time components like voice and video. • Operating systems will have to adjust to deliver acceptable performance for these new forms of data. OS Overview (Chapter 1)

  8. Finally • Operating systems are so large no one person understands whole system. Outlives any of its original builders. • The major problem facing computer science today is how to build large, reliable software systems. • Operating systems are one of very few examples of existing large software systems, and by studying operating systems we may learn lessons applicable to the construction of larger systems. OS Overview (Chapter 1)

  9. Chapter 1 – Computer Systems Let’s figure out what’s inside this thing...

  10. Learning Objectives • Describe the basic elements of a computer system and their interrelationship. • Explain the steps taken by a processor to execute an instruction. • Understand the concept of interrupts and how and why a processor uses interrupts • List and describe the levels of a typical computer memory hierarchy. • Explain the basic characteristics of multiprocessor and multicore organization. • Discuss the concept of locality and analyze the performance of a multilevel memory hierarchy. • Understand the operation of a stack and its use to support procedure call and return. OS Overview (Chapter 1)

  11. Objectives Computer Systems • Registers • Interrupts • Caching • Input/Output • Protection What is a computer system? What are the basic elements of a computer system? OS Overview (Chapter 1)

  12. Objectives Computer Systems • Registers • Interrupts • Caching • Input/Output • Protection • Summary OS Overview (Chapter 1)

  13. Registers CPU OS Overview (Chapter 1)

  14. Registers Processor Registers • User-visible registers • May be referenced by machine language • Available to all programs - application programs and system programs • Data Registers – can be changed by user • Address Registers – could be separate from data register • Stack Registers – user / supervisor stacks • Condition Codes – results of operations • Control and status registers • May or may not be visible • Program Counter (PC) – address of next instruction • Instruction Register (IR) – most recently fetched instruction • MAR/MBR – memory reference registers • Program Status Word (PSW) – condition codes, interrupts, mode OS Overview (Chapter 1)

  15. Registers Lots of Registers… OS Overview (Chapter 1)

  16. Computer Systems • Registers • Interrupts • Caching • Input/Output • Protection • Summary OS Overview (Chapter 1)

  17. Interrupts Interrupts • The interrupt was the principle tool available to system programmers in developing multi-tasking systems! • Improves processing efficiency by allowing the processor to execute other instructions while an I/O operation is in progress • A suspension of a process caused by an event external to that process and performed in such a way that the process can be resumed OS Overview (Chapter 1)

  18. Interrupts Processing of Interrupts • Classes of Interrupts • Program • arithmetic overflow • division by zero • execute illegal instruction • reference outside user’s memory space • Timer • I/O • Hardware failure • An interrupt handler determines nature of the interrupt and performs whatever actions are needed • Control is transferred to this program • Generally part of the operating system OS Overview (Chapter 1)

  19. Fetch Cycle Execute Cycle Interrupt Cycle Interrupts Disabled Execute Instruction Check for Interrupt: Process Interrupt Fetch Next Instruction START Interrupts Enabled HALT Interrupts Interrupt Cycle • Processor checks for interrupts • If no interrupts fetch the next instruction for the current program • If an interrupt is pending, suspend execution of the current program, and execute the interrupt handler OS Overview (Chapter 1)

  20. Interrupts Multiple Interrupts • 2 Choices • Disable Interrupts • Disable upon entering an interrupt handler • Enable upon exiting • Allow Interrupts • Allow an interrupt handler to be interrupted • Priorities? OS Overview (Chapter 1)

  21. Computer Systems • Registers • Interrupts • Caching • Input/Output • Protection • Summary OS Overview (Chapter 1)

  22. More Expensive Faster & Smaller Bigger Slower Caching Memory Hierarchy Registers Cache Main Memory Disk Cache Magnetic Disk Magnetic Tape Optical Disk OS Overview (Chapter 1)

  23. Computer Systems • Registers • Interrupts • Caching • Input/Output • Protection • Summary OS Overview (Chapter 1)

  24. Input / Output Programmed I/O • I/O module performs the action, not the processor • Sets appropriate bits in the I/O status register • No interrupts occur • Processor is kept busy checking status OS Overview (Chapter 1)

  25. Input / Output Interrupt-Driven I/O • Processor is interrupted when I/O module ready to exchange data • Processor is free to do other work • No needless waiting • Consumes a lot of processor time because every word read or written passes through the processor OS Overview (Chapter 1)

  26. Input / Output Direct Memory Access • Transfers a block of data directly to or from memory • An interrupt is sent when the task is complete • The processor is only involved at the beginning and end of the transfer • What does this mean with respect to a paged system? OS Overview (Chapter 1)

  27. Computer Systems • Registers • Interrupts • Caching • Input/Output • Protection • Summary OS Overview (Chapter 1)

  28. Protection Hardware Protection • Why protect hardware? • From what? • Shared hardware resources – memory, disk, … • Errant programs • How? • CPU provides 2 modes of operation • User Mode (non-privileged) • Supervisor mode (privileged) • Privileged instructions can only be executed in monitor mode • All I/O instructions are privileged OS Overview (Chapter 1)

  29. Summary…

  30. Summary What is an O.S.? • Not always a clear definition as to what constitutes an O.S. and what is an application • CD-Rom Driver • Scandisk • Internet Explorer • Intermediary between the hardware and the users • Allocate resources (CPU, Memory, disk space, etc.) between programs and users efficiently • Allow the user to conveniently access data and programs • Protect the system from incorrect or malicious programs and users OS Overview (Chapter 1)

  31. Summary Hardware Review • Elements of a system: • Processor • Registers (address, data, control) • Instruction cycle (fetch, decode, execute) • Interrupts • Usually includes hardware and special instructions to help the O.S. manage memory, devices, etc. • Memory • Different levels (cache, main memory, disk) • Operating system will generally manage memory (both RAM and disk), and move data back and forth as required • I/O • Usually use Interrupts, DMA • Operating system usually controls use of I/O devices OS Overview (Chapter 1)

  32. Summary Registers • Used for frequently accessed items • User-Visible registers – Available to the programmer and compiler • Data Registers • Address Registers (Index, Segment, Stack Pointer) • Condition code/flags • Control and Status registers – Used to control the processor • Program Counter/Instruction Pointer • Memory address/data • Processor Status Word • Debugging registers • Temp registers • Memory Management registers OS Overview (Chapter 1)

  33. Summary Interrupts • Interrupts • Allow I/O devices to get the CPUs attention at regular intervals (Program, Timer, I/O, Hardware failure) • Helps the O.S. by reducing the time spent monitoring I/O devices • CPU checks for interrupts after each instruction, starts the handler if needed • May allow nested interrupts • I/O techniques • Programmed I/O • Interrupt-Driven I/O • Direct Memory Access OS Overview (Chapter 1)

  34. Summary Interrupts and I/O • Handling and Interrupts: • Figure 1.10 (pg 23) • Device sends interrupt request to CPU • CPU finishes current instruction • CPU acknowledges request • CPU saves PC and PSW • CPU loads PC with the address of the first instruction in the interrupt handler (may get help from interrupt request) • Interrupt handler starts, often saves other CPU registers and key values • Interrupt handler responds to the device • Interrupt handler restores CPU registers and key values • CPU restores PC and PSW and resumes previous program OS Overview (Chapter 1)

  35. Summary Memory • Varying types of memory • Registers, Cache, RAM, Disk, CD • Vary in speed, size, cost • CPU and O.S. try to keep frequently used data in faster memory • Cache – Use a small high-speed memory to improve the apparent speed of a larger low-speed memory • Keep track of what is currently being used, load into high-speed memory • Replacement Algorithm – What do we get rid of when we run out of memory? • Write Policy – How do we respond to modifications? OS Overview (Chapter 1)

  36. OS Overview (Chapter 1)

  37. Topics to Cover… • OS Objectives • OS Services • Resource Manager • Evolution • Achievements • Processes • Memory management • Information protection and security • Scheduling and resource management • System architecture OS Overview (Chapter 1)

More Related