Unformatted text preview:

Manages Resources Josh Rogan Operating Systems Notes I Fall 2014 Website http people cs pitt edu jmisurda teaching cs1550 htm August 25 2014 Operating Systems o CPU Time o Memory o I O devices o Security Crosscutting o Think about the hello world program call stack Everything passed to o Exclusive Access to the CPU s o Huge amounts of dedicated RAM o Exclusive access to I O devices Not true tons of other threads that need to share something else passing the text Disks File systems Abstract Details Need to share Exclusive access to files Other files need access at the same time Sharing o Transparent security All of this sharing should happen securely Varieties of OS o Mainframe OS Server OS Parallel Computer OS Personal Computer o Real Time OS Scheduling OS Hard real time Soft real time Penalty for missing deadline is failure Cars aviation nuclear power plant etc Penalty for missing deadline is degradation Think video streaming o Embedded OS Most popular o Smart Card OS August 27 2014 Multi Programming o Memory Partitioning Simple idea Give each program a fixed sized region Image Protection Don t allow other programs to access other protected parts of memory Moving Problem Can t access addresses directly as they change every time Josh Rogan Operating Systems Notes I Fall 2014 Need room to grow Process s Address Space Abstracted idea that the memory is all your own Solves relocation problem addresses aren t moving or changing Solves protection problem You can t access anything but your own Needs room to grow o System Call Basic layers involved in a system call To exert control on resources the operating system not the program must be in control How is this possible instructions o Hardware divides instructions into two sets User and Privileged o Operating system runs first o How do we make unprivileged programs do privileged work They don t do it themselves System Calls Why is it that we can t call system calls directly o The OS is a separate process has its own address space and we don t know where the addresses are outside of our own process o Each process has its own address 3332 There is nothing unique about 3332 o TL DR Can t access address on different process How does the System Call work o Control change without an address o First we need to move from protected mode to privileged kernel mode o Systems calls are numbered via a table Ex System Call 4 Switch to the OS and run that code there o System call is an interrupt from software o Hardware also have interrupts This means that there needs to be two tables So one of the things the Operating system has to do is setup the interrupt vector Setup the interrupt dispatch code in the kernel Two levels of indirection two tables o Has to change state and store the other registers Context Switch Context Switch Switching from one running process to another Solution Keep a hidden set of registers for the operating system Josh Rogan Operating Systems Notes I Fall 2014 Solution Save the state of the program paused into RAM locations that are reserved solely for the program that made the system call No one else will be able to access these memory locations Important Switching context takes time And is done often When comparing algorithms and argue performance we will argue by discussing the number of context switches o TL DR Has to switch mode find the address via interrupts and table look up to the proper system call and dealing with the context switch o Protect and Share CPU Time Preemption Memory I O Spools Security Address Spaces Virtual Memory Simultaneous peripheral operation on line o I O Interrupts Architecture Designs o Monolithic OS Hardware can cause interrupts which causes software to interrupt and run the necessary code for that hardware to give us data Very similar to software interrupts Kernel s code data all of it compiled and linked together in one giant process Everything is all in the kernel s address space Very similar to the way user programs are made Difficult to update small parts of the machine If any part of the system crashes the whole system basically crashes TL DR Less context switches better performance But large code base can cause system failures more unreliable o Microkernel Example The Scheduler doesn t actually need anything privileged Simply needs a linked list Does this really need to be in kernel mode Keeps the kernel small Only has code that needs to be privileged Ex Context Switches Example Create a user mode Process Server that does the scheduler Makes the decision of what process to go to next and then communicate to the kernel what process to go to next then the kernel can switch the process Requires more context switches If some module crashes it may be able to restart TL DR More context switches worse performance But small code base can make it easier to debug and reduce system failures more reliable Josh Rogan Operating Systems Notes I Fall 2014 September 3 2014 Virtual Machines Emulators Java Virtual Machine o Fake instructions for particular hardware o No registers Stack based Process Level Virtual Machine o Ability to install a guest operating system o Experimentation Hypervisors Virtual Machine Monitor system Scheduling Multiprogramming o Doesn t require a host OS Each system has more access More similar to an operating o How do we run more than one program o Process a running program and its associated data Exclusive access o Threads Same address space It is good for information sharing User Threads vs Kernel Threads o User Thread Kernel only has process state Only the user program knows about the thread state Implemented via a library Not as many context switches Function calls won t have to save state o Kernel Thread Kernel knows about the thread state and the process state o Pthread library is a layer above both of these and could be implemented either way o Tradeoffs User threads will not have as many context switches User thread hypothetical scenario A thread in a process runs first and has an infinite loop JUMP TO SELF The kernel thread would send a signal interrupt Switches to the kernel then it will run the scheduler which can run a different thread in the same process The user thread would send a signal interrupt Switch to the kernel run the scheduler and choose the other process Switch again and it will run that left process again which will run greedy thread again It will go exactly to where it left off Josh Rogan Operating Systems Notes I Fall 2014 o However this is okay the


View Full Document

Pitt CS 1550 - Operating Systems

Download Operating Systems
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Operating Systems and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Operating Systems 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?