1 / 38

Operating System Concepts - Implementation and Differences

Learn about operating system concepts such as interrupts, context switches, multiprogramming, timesharing, and protection of system resources. Explore the implementations in Windows, Linux, Unix, Solaris, and Mac OS X. Programming exercises enhance understanding.

floydcraig
Télécharger la présentation

Operating System Concepts - Implementation and Differences

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. 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 between implementations. • Will use programming to enhance our understanding of basic concepts.

  2. Today’s Topics • High level view of Operating System • Interrupts • Context Switches • Multiprogramming • Timesharing • Protection of system resources.

  3. Components of a Computer System User User User User • System and Application Programs • Operating System • Hardware (CPU, memory, I/O devices). System and application Programs Web Browsing Text Editor Database Compiler Operating System Hardware

  4. Components of a Computer System App1 App2 App3 App4 • System and Application Programs • Operating System • Hardware (CPU, memory, I/O devices) System and application Programs Web Browsing Text Editor Database iTunes Operating System Hardware

  5. System programs make our lives easier but are not part of the Operating System. • Compilers, editors, linkers, loaders, shells……. • Operating System performs two functions: • Allocates, schedules, manages, and protects system resources. • Provides a convenient interface to system resources. • Don’t want to have to write device driver to store files on disk.

  6. Interrupts • Operating systems are interrupt-driven. • Perform action, such as giving control of the CPU to an application, then does not regain control of CPU until an interrupt occurs.

  7. CPU and other devices can run concurrently. • Can start I/O operation and start application executing. • When requested operation completed, device generates hardware interrupt. • User programs generate interrupts when making system calls (requesting service from OS) • TRAP instruction. • Generally termed software interrupt.

  8. Interrupts • When an interrupt is generated, the CPU stops what it is doing and execution is transferred to the appropriate interrupt handler. • Addresses of interrupt handlers are found in the interrupt vector. • Table of addresses • Eachdevice (and TRAP) has a particular offset within the table

  9. Interrupt Vector 0 100 500 800 1500 1 2 3 0 I/O Device 1 1 I/O Device 2 2 NIC 3 TRAP

  10. Interrupts • Consider some Joe_Program (nickname is JP or Joe) executing and a device issues an interrupt. • Need to jump to interrupt handler, but ……

  11. Interrupts • Consider some Joe_Program executing and a device issues an interrupt. • Need to jump to interrupt handler, but …… • What do we do with Joe?

  12. Interrupts • Consider some Joe_Program executing and a device issues an interrupt. • Need to jump to interrupt handler, but …… • What do we do with Joe? • What is the minimal information to save to be able to restart his execution?

  13. Interrupts • Consider some Joe_Program executing and a device issues an interrupt. • What do we do with Joe? • What is the minimal information to save to be able to restart his execution? • Address of the next instruction.

  14. What if interrupt processing routine needs to use all of the CPU registers?

  15. What if interrupt processing routine needs to use all of the CPU registers? • Better save a copy of the state of all of the registers PJ is using.

  16. Once interrupt routine completed, how do we get JP restarted?

  17. Once interrupt routine completed, how do we get JP restarted? • Restore state of registers • Set the Instruction Pointer to the next instruction JP was going to execute. • It should appear to JP as if its execution was never interrupted.

  18. Saving and restoring application state is termed a context switch.

  19. Operating System Structure • A key concept of operating systems is multiprogramming (or multitasking). • Technique developed because CPU and I/O device time were very expensive. • Basic idea: • Keep multiple jobs in memory. • When one job blocks on I/O, the CPU immediately switches to another job.

  20. This keeps CPU and I/O devices fully utilized. • Without multiprogramming, CPU would be idle during I/O operations. • First developed for batch systems in the 60s. • No interactions between user and programs.

  21. Multiprogramming Batch Systems Problem: CPU and I/O very expensive. Solution: Multiplex CPU between multiple jobs.

  22. Time-Sharing Systems–Interactive Computing • Logical extension of multiprogramming. • The CPU is multiplexed among several jobs that are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory). • A job swapped in and out of memory to the disk. • Each user is executing a shell program. • Takes user command and executes it. • Waits for the next command.

  23. Time-Sharing Systems–Interactive Computing • Goal is to give the illusion that each user has own machine. • Response time is a priority.

  24. Protection of System Resources • I/O Devices • Memory • CPU • Files

  25. Protection of System Resources • Based on dual-mode execution: • kernel mode and user mode. • Privileged instructions can be issued only in kernel mode. • Mode bit in PSW, checked on every instruction.

  26. User process executing Mode Bit=1 Continue Execution System Call Trap, mode bit = 0 Return. Mode bit = 1 Execute System Call

  27. Protection of I/O Devices • All I/O instructions are privileged instructions. • Only accessed through system calls.

  28. Memory Protection • Must provide memory protection for the interrupt vector, interrupt service routines, and other applications address space. • Two registers that determine the range of legal addresses a program may access: • Base register – holds the smallest legal physical memory address. • Limit register – contains the size of the range • Memory outside the defined range is protected.

  29. Use of A Base and Limit Register

  30. Hardware Address Protection

  31. CPU (and OS) Protection • Keep user from monopolizing CPU. • Ensure OS regains control of CPU.

  32. CPU Protection • Timer – interrupts computer after specified period to ensure operating system maintains control. • Timer is decremented every clock tick. • When timer reaches the value 0, an interrupt occurs. • Timer commonly used to implement time sharing.

  33. Privileged Instructions • Load base and limit registers?

  34. Privileged Instructions • Load base and limit registers? • Set the system timer?

  35. Privileged Instructions • Load base and limit registers? • Set the system timer? • Read the system clock?

  36. Privileged Instructions • Set the system timer? • Read the system clock? • Load base and limit registers? • Open a file?

  37. Privileged Instructions • Load base and limit registers? • Set the system timer? • Read the system clock? • Open a file? • Compile a program and create executable?

  38. Privileged Instructions • Load base and limit registers? • Set the system timer? • Read the system clock? • Open a file? • Compile a program and create executable? • Enable/disable interrupts?

More Related