Download presentation
Presentation is loading. Please wait.
Published byLorin Simon Modified over 9 years ago
1
© Janice Regan, CMPT 300, May 2007 0 CMPT 300 Introduction to Operating Systems Operating Systems Overview Part 2: History (continued)
2
© Janice Regan, CMPT 300, May 2010 1 Time sharing: Scheduling, fair sharing Once multiple jobs can share the CPU (sequentially, not at the same time) it becomes necessary to determine how time is shared between the processes The simplest approach to time sharing(taken by CTSS and some later OS’s) Each process is given N seconds of CPU, after N seconds the next processes takes its turn There are many complexities to this simple process and other variants of sharing, some of which we will discuss later.
3
© Janice Regan, CMPT 300, May 2010 2 Program 2 Instruction P+1 Simple time sharing operation Instruction P Instruction P+2 InstructionP+3 Instruction P+5 Instruction P+7 Instruction P+8 Instruction P+9.:.: ISR4 (timer interrupt service routine) Timer Timer for program 1’s allowed time expires Send Interrupt Save registers and state program1 Restore registers and state program2 Instruction N Instruction N+1 Instruction N+2 Instruction N+3 Instruction N+5 Instruction N+6 Instruction N+8 Instruction N+7.:.: Program 1 Save registers and state program2 Restore registers and state program1 Note: program1 has been selected by the scheduler as the next program to run Timer for program 1’s allowed time expires Send interrupt
4
Time sharing and scheduling In the previous example the simplest case (only two programs) was considered In a real system there will be many programs running. Each time an ISR runs, at the end of the interrupt servicing the scheduler must run to determine which program to give the CPU to next, and what to set the timer to © Janice Regan, CMPT 300, May 2007 3
5
© Janice Regan, CMPT 300, May 2010 4 Time sharing (CTSS) For efficiency Monitor JOB 1 free Monitor JOB 2 free Monitor JOB 3 free Monitor JOB 4 free Monitor JOB 1 free JOB2 JOB 4
6
© Janice Regan, CMPT 300, May 2010 5 Minicomputers Near the end of this generation (1965-1980) small, less expensive machines came into common use (for example the DEC PDP and VAX series) Costs were reduced from millions to 100’s of thousands (about a factor of 20). Memory counted in Kbytes, small words Used to develop UNIX operating system (mult-user) Problems as mini computers proliferated, each vendor had their own flavour of UNIX (BSD, system 5, POSIX …) or their own proprietary OS (VMS … ), compatability was not a given Mainframes and supercomputers were still necessary for computationally intensive applications.
7
© Janice Regan, CMPT 300, May 2010 6 The next generation(1980- now) Use LSI (large scale integrated circuits) to build microcomputers Reduced price (thousands not 100’s of thousands) First used early operating systems like CP/M (control program for microcomputers) or DOS (disk operating system) First uses of user friendly GUIs Have now evolved to Windows, Linux, MAC/OS Single user multitasking operating systems
8
Commonly used OSs Versions of commonly used OSs like windows, Unix, Linux are available for different types of platforms (PCs, Handhelds, Embedded systems) Specialized OSs for purposes such as real time programming and optimizing servers © Janice Regan, CMPT 300, May 2007 7
9
8 CMPT 300 Introduction to Operating Systems Operating Systems Overview Part 3 Processes
10
© Janice Regan, CMPT 300, May 2007 9 What is a process? A program in execution An instance of a program running on a computer An entity that can be assigned to and executed on a computer
11
© Janice Regan, CMPT 300, May 2007 10 What is a process? A process (active entity) is a program (static entity) in execution, and includes An address space, an area in memory (memory location x to y) containing List of instructions Any required data The stack for the program Registers Other information (includes resources used)
12
Building the image: C Write code for your application (1 or more files) Use a preprocessor to add critical components to your code Prototypes of functions in libraries Control for conditional compilation Use a compiler to translate your preprocessed code to machine language creating an object file for each code file you compiled Use the linker to combine your object files and the object files for libraries used by your code and create an executable file © Janice Regan, CMPT 300, May 2007 11
13
The executable file You executable file will contain A list of instructions in machine language Reserved space for your local variables Your executable file will be stored on disk Any time you wish to execute your program you will instruct the OS to add the program (the job) to its long term queue waiting to be placed in memory and run (by clicking on the executable or entering a command line instruction) Your job will be loaded into memory by the OS and will begin to run when the OS allows it to. When your job (your program) is loaded and starts to run it becomes a process © Janice Regan, CMPT 300, May 2007 12
14
© Janice Regan, CMPT 300, May 2007 13 Operating system The operating system is not one process It creates and manages and terminates processes for users It may create processes to control and share resources within the computer (printers …), manage those processes and even terminate those processes It handles system calls from user processes Remember only one process can execute in the CPU at any one time That process may be a user program or one of the OS controlled processes
15
© Janice Regan, CMPT 300, May 2007 14 The operating system Topics that are important to understand advances in operating systems include Memory management File system management Scheduling, resource management Providing user interfaces to access “kernel” functions (such as input and output) Advances in hardware (structure of system) Security and protection of information
16
© Janice Regan, CMPT 300, May 2007 15 Processes Processes are restricted to their own areas of assigned memory Processes may run in “privileged” or “kernel” mode. These processes have full direct access to all resources and instructions in the system. Usually reserved for the OS and processes owned by the OS Processes may run in “user” or “protected” mode. Such processes have access to a limited set of instructions. The limitations generally relate to direct access to hardware of the system critical management functions. Usually the only mode available to user processes
17
© Janice Regan, CMPT 300, May 2007 16 Process context The context of a process must be preserved, It includes The values of the registers Any other information necessary to restore the process after it has been saved. Saving or restoring the context of a process is called context switching One context switch is required to save the currently running program. The scheduler runs to determine the next process to run. Then another context switch occurs to restore the context of the next program
18
Process management The OS keeps track of all processes. Usually a process descriptor block is used to record all properties of a particular process. A process table is used to manage the process descriptor blocks. A process can run in “user” or “kernel” mode. What happens if a “user” mode process wants to do output (use a “kernel” mode instruction to access the hardware) ? © Janice Regan, CMPT 300, May 2007 17
19
System Calls Encapsulates commonly used functions of the OS so they are easily available to “user” processes written in various languages System calls are accessed Using system function calls (C read() …) Using command line instructions or GUI tools (mkdir …) © Janice Regan, CMPT 300, May 2007 18
20
© Janice Regan, CMPT 300, May 2010 19 How system calls work (UNIX) System calls run partially in system mode A system call is made by a “user” process, when the system subroutine starts executing the process is still in “user” mode Within the system call instructions execute a context switch from “user” mode controlled by the “user” process to “kernel” mode controlled by the OS The OS executes the required “kernel” mode operations Instructions execute another context switch back to the “user” mode before the system call returns to the “user” process
21
© Janice Regan, CMPT 300, May 2010 20 System Calls: An example To read or print a system call will be made The system call will Switch context to “kernel” mode set up the operation, start the hardware pass the CPU to a program to execute until the I/0 operation is complete (in system mode). The hardware will send an interrupt when it is done. The interrupt will pass the CPU back to the system call The system call will do any clean up or additional work needed to complete the I/O operation then switch context to “user” mode and pass control back to the users program
22
Services provided by system calls Creating and managing processes File management (Input and Output) Directory/File management Using timers and other system hardware Be sure to read the excellent summary in your text (chapter 1.6) © Janice Regan, CMPT 300, May 2007 21
23
© Janice Regan, CMPT 300, May 2007 22 Virtual memory/Memory management Another innovation in more modern OSs Similar process to that used by cache Pages of memory are moved between the disks and the memory to effectively extend the amount of available memory. Processes use pages of memory (more later), first we need to understand processes
24
OS architectures An OS can be built based on one or more of the following architectures (Read chapter 1.7) Monolithic Layered Microkernel Client Server Virtual machine Exokernel © Janice Regan, CMPT 300, May 2007 23
25
Monolithic Entire OS runs as a single program in kernel mode Many procedures for different purposes Complex: any procedure can call any other Some structure: system calls all execute the same way Structure of OS Main program to invoke other processes A set of service procedures to execute system calls A set of utility procedures to support the service procedures © Janice Regan, CMPT 300, May 2007 24
26
Layered Generalize the layers observed in the monolithic structure Further separate the functions of the OS Make a layer for each of the groups of functions Note that only adjacent layers should communicate directly © Janice Regan, CMPT 300, May 2007 25
27
Microkernel In a monolithic system errors can make the system fail (e.g. an error in a driver added to the system) Split the OS into smaller modules. One module runs in “kernel” mode and manages the whole OS Other modules run in user mode each as a separate process (an error in a driver only breaks the module for that driver not the whole OS) © Janice Regan, CMPT 300, May 2007 26
28
Example Microkernel (MINIX) © Janice Regan, CMPT 300, May 2007 27 MICROKERNEL Interrupts, communication between processes, scheduling, timers, DEVICE DRIVERS (1 module each type of driver) SERVICES (file server, process manager, …) User tools and processes (shell …)
29
Virtual machines Started as a way to allow interactive use of batch processing machines Now can have many “hosts” that appear to be individual machines all running on the same server. The virtual machines can even run different operating systems © Janice Regan, CMPT 300, May 2007 28
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.