Presentation is loading. Please wait.

Presentation is loading. Please wait.

Design of Operating Systems

Similar presentations


Presentation on theme: "Design of Operating Systems"— Presentation transcript:

1 Design of Operating Systems
CIS 486 Design of Operating Systems CIS 486 Syracuse University Fall 2017

2 CIS 486 Syracuse University Fall 2017
Why do we need OS? CIS 486 Syracuse University Fall 2017

3 Why do we need OS? Two Core Purposes:
Abstraction Hides low level details of hardware implementation from user and even software developer. What implications would it have for software developers if there were no abstraction? CIS 486 Syracuse University Fall 2017

4 No Abstraction? Programmers would need to know about the exact specifications of computer hardware (drivers). Programmers would need to know where in memory (RAM) the program would be running. Programmers would likely need to configure HW devices (ethernet card is initialized?) What about HW fault management? CIS 486 Syracuse University Fall 2017

5 Why do we need OS? Two Core Purposes cont’d. Resource Management
Correctness in sharing of hardware resources. Fair allocation of resources (multiple programs running?). Implications of no resource management? CIS 486 Syracuse University Fall 2017

6 No Resource Management?
Multiple running programs reading from disk, would these step over each other? Data protection? Could programs read/write each other’s memory in RAM? Or files on disk? Single program hogs some resource (disk, ethernet, etc.). Under what circumstances might we not need a lot abstraction & resource management? CIS 486 Syracuse University Fall 2017

7 OS Layer CIS 486 Syracuse University Fall 2017

8 Firmware vs Operating System
Typically runs on simple devices that execute a single function (or very simple functions). Saved in non-volatile memory Built in to HW, effectively part of the HW, but can be upgraded/corrupted/infected. Operating System Runs multiple, highly-varied functions (programs). Typically works in conjunction with firmware (will see this later). CIS 486 Syracuse University Fall 2017

9 Where can we find OS? Computers Cell phones iPod iPad Gaming consoles
Smart watches Real-Time OSs Distributed OSs CIS 486 Syracuse University Fall 2017

10 CIS 486 Syracuse University Fall 2017
History of OS CIS 486 Syracuse University Fall 2017

11 Timeline Charles Babbage’s Difference Engine 1823 – 1842
Mechanical calculator First generation vacuum tubes, plug boards Second generation transistors, batch systems, card readers, etc. Third generation – 1980 ICs and multiprogramming Fourth generation 1980 – present personal computers CIS 486 Syracuse University Fall 2017

12 Difference Engine Mechanical in nature used to calculate polynomial functions (logarithmic/trigonometric tables). Ada Lovelace wrote the first algorithm to compute the Bernoulli sequence Original project was not completed due to cost. Finally built in early 90’s. CIS 486 Syracuse University Fall 2017

13 First Generation ENIAC was one of the first turring-complete binary computers. Developed at the University of Pennsylvania Commissioned in 1946 Primarily designed to compute artillery firing tables. Was “programmed” via switches and cables taking days (after the program was worked out on paper). CIS 486 Syracuse University Fall 2017

14 Second Generation Punch cards were stored on a deck of cards.
Each card was more or less a single instruction. Operating Systems: A multi-perspective episodic approach, Jae C. Oh CIS 486 Syracuse University Fall 2017

15 Punch cards Punch cards ran in batch
Multiple programs grouped together. Transferred to tape Ran multiple programs sequentially. CIS 486 Syracuse University Fall 2017 Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

16 Third Generation Multiprogramming: When one program was blocked on I/O, run a different one. Led to time-sharing, where developers had terminals at their desks. Microprocessor was born in 1971 at Intel. MULTICs (MULTiplexed Information and Computing Service) was developed. But was too big and complex. UNICS = UNiplexed Information and Computing Service was a stripped down version. UNICS rewritten in C became UNIX CIS 486 Syracuse University Fall 2017

17 Fourth Generation Personal Computing started.
Large scale integrated circuits introduced. Computers could now fit on your desk and used not just by  technocrats. Commercial success begins: MS-DOS, Apple Macintosh. CIS 486 Syracuse University Fall 2017

18 Computer Organization
CIS 486 Syracuse University Fall 2017

19 Von Neumann Machines Computers today are still Von Neumann machines
Store programs in memory (along with data), fetch instruction, (decode instruction), execute instruction. All computer have the following components: CPU Memory Input/Output CIS 486 Syracuse University Fall 2017

20 Fetch, Decode, Execute Program Counter: Keeps track of address of current instruction to execute. Status Register: Indicates current state of the processor. Instruction Register: Holds instruction just decoded Algorithmic Logic Unit: Performs algorithmic and logical computations. CIS 486 Syracuse University Fall 2017

21 Memory Hierarchy CIS 486 Syracuse University Fall 2017
CIS 486 Syracuse University Fall 2017

22 Question Why does having a cache help at all? What principals can you recall about the execution of programs? CIS 486 Syracuse University Fall 2017

23 Locality of Reference Spatial locality: Memory locations close to the last used locations are likely to be used soon. Temporal locality: Memory locations used recently are likely to be used again soon. CIS 486 Syracuse University Fall 2017

24 Structure of a disk drive
Hard disks Structure of a disk drive Modern Operating Systems, 3rd ed., Andrew Tanenbuam  CIS 486 Syracuse University Fall 2017

25 CIS 486 Syracuse University Fall 2017
Process CIS 486 Syracuse University Fall 2017

26 A Program in Execution A program is typically defined as an executable file. A process is a program in execution. The same program may be running multiple times on the same machine. CIS 486 Syracuse University Fall 2017

27 Question What state should we keep track of for a running program?
CIS 486 Syracuse University Fall 2017

28 Process Control Block PCB: Operating System data structure for maintaining a process. Process state: Running, waiting, etc. Process Id: Unique identifier in OS. Program Counter: Next instruction to execute for the process. CPU Registers: A copy of the registers for this process. Address space: management information (stack pointer, etc.). CIS 486 Syracuse University Fall 2017

29 Question Why might the OS need a copy of the registers?
CIS 486 Syracuse University Fall 2017

30 Multi-Programming Multi-programming: concept of running multiple processes at the same time. (Some times referred to as multi-tasking). We do not assume multiple CPUs (multiple CPUs called parallel execution). Only a single process is running at any individual time. OS scheduler switches between processes so quickly so as to give illusion of parallelization. CIS 486 Syracuse University Fall 2017

31 Context Switching A context switch: Occurs when the operating system swaps the current running process for another. Operating system will run a sub-routine to switch the current process A to the next process to run B. Save all of the CPU registers into the PCB for A. Mark process A as ready. Load all of the registers into the CPU from process B’s PCB. Mark process B as running. CIS 486 Syracuse University Fall 2017

32 Question What do you think the last register loaded into the CPU for the next process is? CIS 486 Syracuse University Fall 2017

33 Operating System Users
OS users Software developers Operating system developers CIS 486 Syracuse University Fall 2017

34 System Calls & Interrupts
CIS 486 Syracuse University Fall 2017

35 Question If the CPU only ever does fetch, decode, execute, how does the code for doing the context switch logic get run? CIS 486 Syracuse University Fall 2017

36 Interrupts Since we can’t inject new code, hardware has to help!
An interrupt is a signal to the processor that something needs attention. An interrupt can be triggered via software OR hardware (but CPU must support). HW interrupt: Typically via a device: keyboard, disk, ethernet, etc. These are asynchronous and can come at any time. SW Interrupt: Triggered via a trap which can be triggered by an fault (divide–by-zero) or a system call. CIS 486 Syracuse University Fall 2017

37 System Call System calls are exposed for software developers to invoke code in the operating system. Access devices: Read from file Get mouse position Create directory Open a web-page. Impact OS management: Open an application (creates a new process). Allocate space for new variable in heap. CIS 486 Syracuse University Fall 2017

38 Kernel vs user mode Once the trap has occurred, the operating system switches to privileged mode (special CPU flag/register to enable kernel mode). When kernel mode = true, code run is allowed to control the devices and execute in privileged mode. CIS 486 Syracuse University Fall 2017

39 Point of View Operating System Kernel Mode “Unlimited Access”
Application Program User Mode Limited Access Requests made to OS via System Calls / Exceptions Operating System Kernel Mode “Unlimited Access” Requests made to hardware.

40 Interrupt Handling CIS 486 Syracuse University Fall 2017

41 Interrupt Vector (Table)
Associates interrupt requests with interrupt handlers (code). CIS 486 Syracuse University Fall 2017 Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

42

43 A stripped down shell while (TRUE) { /* repeat forever */
type_prompt( ); /* display prompt */ read_command (command, parameters) /* input from terminal */ if (fork() != 0) { /* fork off child process */ /* Parent code */ waitpid( -1, &status, 0); /* wait for child to exit */ } else { /* Child code */ execve (command, parameters, 0); /* execute command */ }

44 System Calls Some Win32 API calls

45 Systems calls: Windows vs. Linux
Linux Running Apache Server

46 Systems calls: Windows vs. Linux
Windows Running Apache Server

47 Operating System SubSystems
Process Management Memory Management File System Organization System Call Handling Device Operation

48 Operating System Architectures
Monolithic - No structure Layered Systems – Each layer invokes subroutines in the layer beneath it. Virtual Machine – Operating system does not extend machine, but creates complete virtual copy. Exokernels – Complete machine with subset of resources. MicroKernel – Operating system subsystems run in user space as processes.

49 Operating System Zoo Mainframe Operating Systems
Server Operating Systems Multiprocessor Operating Systems Personal Computer Operating Systems Real-Time Operating Systems Soft vs. Hard real-time system Embedded Operating Systems Smart Card Operating Systems

50 Definitions Process – A program in execution (running).
Kernel Mode vs User Mode - Kernel mode implies the computer is executing code from the Operating system. User mode means the computer is running application code. Locality of Reference – Addresses close-to a referenced address have a much higher probability of being referenced. Virtual vs Physical Address – The physical address is a location in the main memory (RAM). The virtual address is the relative addresses within a process. Context Switching – One process pauses another process resumes. Protection – Ensure that processes do not write over other process’s address space or the Operating System’s address space. Relocation – When compiled processes do not Multi-programming – Multiple processes are present in main memory at any given time. Time-Sharing - Fast switching between these processes gives the appearance that there are many programs running at once. Interrupts – Interrupts `interrupt’ the normal flow of instruction execution.


Download ppt "Design of Operating Systems"

Similar presentations


Ads by Google