220 likes | 479 Views
OS Structure, Processes & Philosophizing. Vivek Pai / Kai Li Princeton University. But First, A Word From Our Sponsor…. Project 1 – you have to do two things bootblock.s createimage.c Both are “conceptually simple” Just a “simple matter of programming” Fred Brooks – Mythical Man-Month.
E N D
OS Structure, Processes& Philosophizing Vivek Pai / Kai Li Princeton University
But First, A Word From Our Sponsor… Project 1 – you have to do two things • bootblock.s • createimage.c Both are “conceptually simple” • Just a “simple matter of programming” • Fred Brooks – Mythical Man-Month
What you need to do • Create bootblock.s • Compile it • Using createimage, append dummy kernel • Transfer “image” to floppy disk • Boot from floppy disk
Monolithic User program User program • All kernel routines are together • A system call interface • Examples: • Linux • Most Unix OS • NT return call entry Kernel many many things
Monolithic Pros and Cons Pros • Relatively few crossings • Shared kernel address space • Performance Cons • Flexibility • Stability • Experimentation
Layered Structure • Hiding information at each layer • Develop a layer at a time • Examples • THE (6 layers) • MS-DOS (4 layers) Level N . . . Level 2 Level 1 Hardware
Layering Pros and Cons Pros • Separation of concerns • Simplicity / elegance Cons • Boundary crossings • Performance?
Microkernel User program Services • Micro-kernel is “micro” • Services are implemented as regular process • Micro-kernel get services on behalf of users by messaging with the service processes • Example: Taos, Mach return call entry m-kernel
Microkernel Pros and Cons Pros • Easier to develop services • Fault isolation • Customization • Smaller kernel => easier to optimize Cons • Lots of boundary crossings • Really poor performance
Virtual Machine • Virtual machine monitor • provide multiple virtual “real” hardware • run different OS codes • Example • IBM VM/370 • virtual 8086 mode • Java user user OS1 OSn . . . VM1 VMn Small kernel Bare hardware
Hardware Support • What is the minimal support? • Can virtual machine be protected without such support? • Hint: what is a Turing machine?
Time For Philosophizin’ “I can out-learn you, I can out-read you, I can out-think you, & I can out-philosophize you…”
What Is a Program? • Idea / desire / specification • Source code • Compiled executable But what “brings it to life”?
Programs Have a Time Component What is the program doing now? • Execution state • Program state • Can two people do different things with the same program? • Can one person? How?
Resource Virtualization • CPU • Memory • Devices
Concurrency and Process • Problem • A shared CPU, many I/O devices and lots of interrupts • Users feel they have machine to themselves • Answer • Decompose hard problems into simple ones • Deal with one at a time • Process is such a unit
Process • Sequential execution • No concurrency inside a process • Everything happens sequentially • Process state • Registers • Main memory • Files in UNIX • Communication ports
Program and Process main() { ... foo() ... } foo() { ... } Program main() { ... foo() ... } foo() { ... } Process heap stack main foo registers PC
Process vs. Program • Process > program • Program is just part of process state • Example: many users can run the same program • Process < program • A program can invoke more than one process • Example: Fork off processes to lookup webster
Process State Transition terminate Scheduler dispatch Running Wait for resource Create a process Ready Blocked Resource becomes available
Process Control Block(Process Table) What • Process management info • State (ready, running, blocked) • Registers, PSW, parents, etc • Memory management info • Segments, page table, stats, etc • I/O and file management • Communication ports, directories, file descriptors, etc.
Discussion Question: What need to be saved and restored on a context switch and how? What are the implications?