Published on

Published in: Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • What’s the largest single use of microprocessors? Not computers – Embedded computers (10 billion versus 400 million) Example: Nintendo game machine. Second largest? Automobiles. Both require concurrency, but no need for protection
  • 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 various applications and users Application programs – define the ways in which the system resources are used to solve the computing problems of the users Word processors, compilers, web browsers, database systems, video games Users People, machines, other computers
  • Intel Pentium D 940 Extreme Edition – Dual hyperthreaded core
  • The best part of computer science: Suppose you don’t know anything today, wait a few years and no one will know anything!
  • OS first appeared as a subroutine “library” shared by all users. Library: pull card decks from wall.
  • Multiprogramming: 2 jobs (1 takes 10 hrs, the other 10 mins). Don’t have to wait 10 hrs! lists 1777 people who “contributed to Multics”. Probably 30-40 core developers.
  • Computers are friendly things: 1 terminal, feed me. Add another terminal, feed me. Can you keep doing this? NO! Eventually fall off a cliff (add one more user, computer slows down by a factor of 1000)
  • No, Feature creep. PC made OS a subroutine all over again. But then realized even single users need memory protection, multiprogramming, etc. Same is true of PDAs and phones
  • Why do we need distributed systems? Resource sharing (printers, Internet connections,…) and info sharing (files, email, IM, …)
  • How many people have written a 1K program? 15 pages How many people have written a 10K program? 150 pages
  • Chap1

    1. 1. Operating Systems Introduction Xiaoyu Zhang 1
    2. 2. Computing Devices Everywhere 2
    3. 3. Computer System Organization• 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 3
    4. 4. How do we tame complexity?• Every piece of computer hardware different – Different CPU • Pentium, PowerPC, MIPS, … – Different amounts of memory, disk, … – Different types of devices • Mice, Keyboards, Sensors, Cameras, Fingerprint readers – Different networking environment • Cable, DSL, Wireless, Firewalls,…• Questions: – Does the programmer need to write a single program that performs many independent activities? – Does every program have to be altered for every piece of hardware? – Does a faulty program crash everything? – Does every program have access to all hardware? 4
    5. 5. Four Components of a Computer SystemAn operating system is the interface between the user and the hardware.Definition: An operating system implements a virtual machine that is(hopefully) easier and safer to program and use than the raw hardware. 5
    6. 6. Operating System Application Virtual Machine Interface Operating System Physical Machine Interface Hardware• Services (Resource management): The OS provides standard services (the interface) which the hardware implements. These services include the file system, virtual memory, networking, CPU scheduling, etc.• Coordination (Control): The OS coordinates multiple applications and users to achieve fairness and efficiency (throughput). Examples: concurrency, protection, networking, and security.• The OS design goal is to make the machine convenient to use (a software engineering problem) and efficient (a system and engineering problem). 6
    7. 7. Virtual Machines: Layers of OSs• Useful for OS development – When OS crashes, restricted to one VM – Can aid testing programs on other OSs 7
    8. 8. Virtual Machines• Software emulation of an abstract machine – Make it look like hardware has features you want – Programs from one hardware & OS work on another one• Programming simplicity – Each process thinks it has all memory/CPU time – Each process thinks it owns all devices – Different Devices appear to have same interface – Device Interfaces more powerful than raw hardware • Bitmapped display ⇒ windowing system • Ethernet card ⇒ reliable, ordered, networking (TCP/IP)• Fault Isolation – Processes unable to directly impact other processes – Bugs cannot crash whole machine• Protection and Portability 8
    9. 9. Summary of Operating System Principles• OS as juggler: providing the illusion of a dedicated machine with infinite memory and CPU.• OS as government: protecting users from each other, allocating resources efficiently and fairly, and providing secure and safe communication.• OS as complex system: keeping OS design and implementation as simple as possible is the key to getting the OS to work.• OS as history teacher: learning from past to predict the future, i.e., OS design tradeoffs change with technology. 9
    10. 10. What is an Operating System,… Really?• Most Likely: – Memory Management – I/O Management – CPU Scheduling – Communications? (Does Email belong in OS?)• What about? – File System? – Multimedia Support? – User Interface? – Internet Browser? • Is this only interesting to Academics?? 10
    11. 11. Operating System Definition (cont)• No universally accepted definition• “Everything a vendor ships when you order an operating system” is good approximation – But varies wildly• “The one program running at all times on the computer” is the kernel. Everything else is either a system program (ships with the operating system) or an application program 11
    12. 12. Why Study Operating Systems?• Abstraction: How to get the OS to give users an illusion of infinite memory, CPUs, resources, world wide computing, etc.• System Design: How to make tradeoffs between – performance and the convenience of OS abstractions, – performance and the simplicity of OS design, and – putting functionality in hardware or software.• As systems change the OS must adapt (e.g., new hardware, software). 12
    13. 13. Why Study Operating Systems?• The operating system makes the computer work - it is a key abstraction layer for applications.• Understanding operating systems will enable you to use your computer more effectively. They are an excellent example of system design issues whose results and ideas you will apply in all aspects of experimental computer science.• Background: To understand this course you must have a solid basic understanding of hardware (CS 331: CPU instruction sets, memory hierarchies, I/O systems, etc.) and solid programming skills (complex data structures, debugging, etc., e.g. what you learned in CS 311)• Obviously, you cannot understand the implications of how components intersect without understanding the components. 13
    14. 14. What if we didn’t have an Operating System?• Source Code⇒Compiler⇒Object Code⇒Hardware• How do you get object code onto the hardware?• How do you print out the answer?• Once upon a time, had to Toggle in program in binary and read out answer from LED’s! Altair 8080 14
    15. 15. Simple OS: What if only one application?• Examples: – Very early computers – Early PCs – Embedded controllers (elevators, cars, etc)• OS becomes just a library of standard services – Standard device drivers – Interrupt handlers – Math libraries 15
    16. 16. MS-DOS Layer Structure 16
    17. 17. More complex OS: Multiple Apps• Full Coordination and Protection – Manage interactions between different users – Multiple programs running simultaneously – Multiplex and protect Hardware Resources • CPU, Memory, I/O devices like disks, printers, etc• Facilitator – Still provides Standard libraries, facilities• Would this complexity make sense if there were only one application that you cared about? 17
    18. 18. Interrupt Driven O.S.• Most modern operating systems are interrupt driven. – Start-up: 1) 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).
    19. 19. 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. – 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.
    20. 20. Example: Protecting Processes from Each Other• Problem: Run multiple applications in such a way that they are protected from one another• Goal: – Keep User Programs from Crashing OS – Keep User Programs from Crashing each other – [Keep Parts of OS from crashing other parts?]• (Some of the required) Mechanisms: – Address Translation – Dual Mode Operation• Simple Policy: – Programs are not allowed to read/write memory of other Programs or of Operating System 20
    21. 21. Address Translation• Address Space – A group of memory addresses usable by something – Each program (process) and kernel has potentially different address spaces.• Address Translation: – Translate from Virtual Addresses (emitted by CPU) into Physical Addresses (of memory) – Mapping often performed in Hardware by Memory Management Unit (MMU) Virtual Physical Addresses Addresses CPU MMU 21
    22. 22. Example of Address Translation Code Data 2 Code Stack 1 Data Data Heap 1 Heap Heap Code 1 Stack Stack Stack 2 Prog 1 Data 1 Prog 2 Virtual Virtual Address Heap 2 Address Space 1 Code 2 Space 2 OS code OS dataTranslation Map 1 Translation Map 2 OS heap & Stacks Physical Address Space 22
    23. 23. Dual Mode Operation• Hardware provides at least two modes: – “Kernel” mode (or “supervisor” or “protected”) – “User” mode: Normal programs executed• Some instructions/ops prohibited in user mode: – Example: cannot modify page tables in user mode • Attempt to modify ⇒ Exception generated• Transitions from user mode to kernel mode: – System Calls, Interrupts, Other exceptions 24
    24. 24. UNIX System Structure ApplicationsUser Mode Standard LibsKernel Mode Hardware 25
    25. 25. “In conclusion…”• Operating systems provide a virtual machine abstraction to handle diverse hardware• Operating systems simplify application development by providing standard services• Operating systems coordinate resources and protect users from each other• Operating systems can provide an array of fault containment, fault tolerance, and fault recovery 26
    26. 26. Moore’s Law Change Drives OS Change 1981 2006 Factor CPU MHz, 10 3200x4 1,280 Cycles/inst 3—10 0.25—0.5 6—40 DRAM capacity 128KB 4GB 32,768 Disk capacity 10MB 1TB 100,000 Net bandwidth 9600 b/s 1 Gb/s 110,000 # addr bits 16 32 2 #users/machine 10s ≤ 1 ≤ 0.1 Price $25,000 $4,000 0.2 Typical academic computer 1981 vs 2006 27
    27. 27. Moore’s law effects• Nothing like this in any other area of business• Transportation in over 200 years: – 2 orders of magnitude from horseback @10mph to Concorde @1000mph – Computers do this every decade!• What does this mean for us? – Techniques have to vary over time to adapt to changing tradeoffs• I place a lot more emphasis on principles – The key concepts underlying computer systems – Less emphasis on facts that are likely to change over the next few years…• Let’s examine the way changes in $/MIPS has radically changed how OS’s work 28
    28. 28. Dawn of time ENIAC: (1945—1955)• “The machine designed by Drs. Eckert and Mauchly was a monstrosity. When it was finished, the ENIAC filled an entire room, weighed thirty tons, and consumed two hundred kilowatts of power.”• 29
    29. 29. History Phase 1 (1948—1970) Hardware Expensive, Humans Cheap• When computers cost millions of $’s, optimize for more efficient use of the hardware! – Lack of interaction between user and computer• User at console: one user at a time• Batch monitor: load program, run, print• Optimize to better use hardware – When user thinking at console, computer idle⇒BAD! – Feed computer batches and make users wait• No protection: what if batch program has bug? 30
    30. 30. History Phase 1½ (late 60s/early 70s)• Data channels, Interrupts: overlap I/O and compute – DMA – Direct Memory Access for I/O devices – I/O can be completed asynchronously• Multiprogramming: several programs run simultaneously – Small jobs not delayed by large jobs – More overlap between I/O and CPU – Need memory protection between programs and/or OS• Complexity gets out of hand: – Multics: announced in 1963, ran in 1969 • 1777 people “contributed to Multics” (30-40 core dev) • Turing award lecture from Fernando Corbató (key researcher): “On building systems that will fail” – OS 360: released with 1000 known bugs (APARs) • “Anomalous Program Activity Report”• OS finally becomes an important science: – How to deal with complexity??? – UNIX based on Multics, but vastly simplified 31
    31. 31. History Phase 2 (1970 – 1985)Hardware Cheaper, Humans Expensive• Computers available for tens of thousands of dollars instead of millions• OS Technology maturing/stabilizing• Interactive timesharing: – Use cheap terminals (~$1000) to let multiple users interact with the system at the same time – Sacrifice CPU time to get better response time – Users do debugging, editing, and email online• Problem: Thrashing – Performance very non-linear response with load Response time – Thrashing caused by many factors including • Swapping, queueing Users 32
    32. 32. History Phase 3 (1981— ) Hardware Very Cheap, Humans Very Expensive• Computer costs $1K, Programmer costs $100K/year – If you can make someone 1% more efficient by giving them a computer, it’s worth it! – Use computers to make people more efficient• Personal computing: – Computers cheap, so give everyone a PC• Limited Hardware Resources Initially: – OS becomes a subroutine library – One application at a time (MSDOS, CP/M, …)• Eventually PCs become powerful: – OS regains all the complexity of a “big” OS – multiprogramming, memory protection, etc (NT,OS/2)• Question: As hardware gets cheaper does need for OS go away? 33
    33. 33. History Phase 3 (con’t) Graphical User Interfaces• Xerox Star: 1981 – Originally a research Xerox Star project (Alto) – First “mice”, “windows”• Apple Lisa/Machintosh: 1984 – “Look and Feel” suit 1988• Microsoft Windows: – Win 1.0 (1985) – Win 3.1 (1990) – Win 95 (1995) – Win NT (1993) – Win 2000 (2000) Windows 3.1 – Win XP (2001) – Win Vista (2007) 34
    34. 34. History Phase 4 (1989—): Distributed Systems• Networking (Local Area Networking) – Different machines share resources – Printers, File Servers, Web Servers – Client – Server Model• Services – Computing – File Storage 35
    35. 35. History Phase 5 (1995—): Mobile Systems• Ubiquitous Mobile Devices – Laptops, PDAs, phones – Small, portable, and inexpensive • Recently twice as many smart phones as PDAs • Many computers/person! – Limited capabilities (memory, CPU, power, etc…)• Wireless/Wide Area Networking – Leveraging the infrastructure – Huge distributed pool of resources extend devices – Traditional computers split into pieces. Wireless keyboards/mice, CPU distributed, storage remote• Peer-to-peer systems – Many devices with equal responsibilities work together – Components of “Operating System” spread across globe 36
    36. 36. History of OS: Summary• Change is continuous and OSs should adapt – Not: look how stupid batch processing was – But: Made sense at the time• Situation today is much like the late 60s [poll] – Small OS: 100K lines – Large OS: >10M lines (5M for the browser!) • 100-1000 people-years• Complexity still reigns – NT under development from early 90’s to late 90’s • Never worked very well – Jury still out on Windows 2000/XP – Windows Vista (aka “Longhorn”) delayed many times • Latest release date of 2005, 2006, 2007 (finally) 37
    37. 37. Now for a quick tour of OS Structures 38
    38. 38. 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 job• Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users 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 don’t fit in memory, swapping moves them in and out to run – Virtual memory allows execution of processes not completely in memory 39
    39. 39. Operating System Services (What things does the OS do?)• Services that (more-or-less) map onto components – Program execution • How do you execute concurrent sequences of instructions? – I/O operations • Standardized interfaces to extremely diverse devices – File system manipulation • How do you read/write/preserve files? • Looming concern: How do you even find files??? – Communications • Networking protocols/Interface with CyberSpace?• Control capabilities – Error detection & recovery – Resource allocation – Accounting – Protection 40
    40. 40. Operating Systems Components (What are the pieces of the OS)• Process Management• Main-Memory Management• I/O System management• File Management• Networking• User Interfaces 41
    41. 41. Process Management• A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity.• Process needs resources to accomplish its task – CPU, memory, I/O, files – Initialization data• Process termination requires reclaim of any reusable resources• Single-threaded process has one program counter specifying location of 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 user, some operating system running concurrently on one or more CPUs – Concurrency by multiplexing the CPUs among the processes / threads 42
    42. 42. Process Management ActivitiesThe operating system is responsible for the following activities in connection with process management:• Creating and deleting both user and system processes• Suspending and resuming processes• Providing mechanisms for process synchronization• Providing mechanisms for process communication• Providing mechanisms for deadlock handling 43
    43. 43. Memory Management• 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 (or parts thereof) and data to move into and out of memory – Allocating and deallocating memory space as needed 44
    44. 44. Storage Management• OS provides uniform, logical view of information storage – Abstracts physical properties to logical storage unit - file – Each medium is controlled by device (i.e., disk drive, tape drive) • Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random)• File-System management – Files usually organized into directories – Access control on most systems to determine who can access what – OS activities include • Creating and deleting files and directories • Primitives to manipulate files and dirs • Mapping files onto secondary storage • Backup files onto stable (non-volatile) storage media 45
    45. 45. Mass-Storage Management• Usually disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time.• Proper management is of central importance• Entire speed of computer operation hinges on disk subsystem and its algorithms• OS activities – Free-space management – Storage allocation – Disk scheduling• Some storage need not be fast – Tertiary storage includes optical storage, magnetic tape – Still must be managed – Varies between WORM (write-once, read-many-times) and RW (read-write) 46
    46. 46. I/O Subsystem• One purpose of OS is to hide peculiarities of hardware devices from the user• I/O subsystem responsible for – Memory management of I/O including • buffering (storing data temporarily while it is being transferred), • caching (storing parts of data in faster storage for performance), • spooling (the overlapping of output of one job with input of other jobs) – General device-driver interface – Drivers for specific hardware devices 47
    47. 47. Protection and Security• Protection – any mechanism for controlling access of processes or users to resources defined by the OS• Security – defense of the system against internal and external attacks – Huge range, including denial-of-service, worms, viruses, identity theft, theft of service• Systems generally first distinguish among users, to determine who can do what – User identities (user IDs, security IDs) include name and associated number, one per user – User ID then associated with all files, processes of that user to determine access control – Group identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, file – Privilege escalation allows user to change to effective ID with more rights 48
    48. 48. Conclusion• Rapid Change in Hardware Leads to changing OS – Batch ⇒ Multiprogramming ⇒ Timeshare ⇒ Graphical UI ⇒ Ubiquitous Devices ⇒ Cyberspace/Metaverse/??• OS features migrated from mainframes ⇒ PCs• Standard Components and Services – Process Control – Main Memory – I/O – File System – UI• Complexity is always out of control – However, “Resistance is NOT Useless!” 49
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.