Unformatted text preview:

CS162 Operating Systems and Systems Programming Application Professor Anthony D Joseph Spring 2003 Hardware Lecture 1 Introduction 0 0 Administrivia 1 0 Main points Physical Machine Interface In some sense OS is just a software engineering problem how do you convert what the hardware gives you into something that the application programmers want What is an operating system and what isn t it Principles of operating system design For any OS area file systems virtual memory networking CPU scheduling you begin by asking two questions Why study operating systems 1 1 Virtual Machine Interface Operating System What is an operating system What s the hardware interface the physical reality What s the application interface the nicer abstraction Of course should also ask why the interfaces look the way they do and whether it might be better to push more responsibilities into applications or into hardware or vice versa examples RISC architectures VBasic libraries etc 1 1 1 Virtual Machines API Application Programming Interface Hardware Interface Figure is from Silberschatz and Galvin Chapter 1 Definition An operating system implements a virtual machine that is hopefully easier and safer to program and use than the raw hardware 1 1 2 Virtual machine model provides software emulation of an abstract machine Also used to allow programs for one hardware OS platform to run on another one e g Windows programs on a Macintosh perhaps even running several VMs concurrently Useful for OS research and development much easier to debug Protection and portability e g Java VM The project in this course is to build some of the portable components of an OS on top of Nachos which provides a simulation environment That is it simulates the hardware and machine dependent layer interrupts I O etc and the execution of user programs running on top of it Note that Nachos runs on many different hardware OS platforms Operating systems have two general functions Silberschatz and Galvin An OS is similar to a government This becomes political do you think a government does anything useful by itself CS 162 Spring 2003 Lecture 1 1 9 CS 162 Spring 2003 Lecture 1 2 9 1 1 5 Simple OS What if only one application at a time Examples very early computers early PC s embedded controllers elevators 1 Coordinator traffic cop allow multiple applications users to work together in efficient and fair ways examples concurrency memory cars Nintendos PDAs intelligent light switches protection file systems networking This is Resource Allocation and Then OS is just a library of standard services Examples standard device drivers interrupt handlers math libraries etc Control Goals are fair management of shared resources protection and efficiency 2 Standard services provide standard facilities that everyone needs examples standard libraries windowing systems View OS as a facilitator Goal is to make application programming easier faster and less error prone 1 1 6 More complex OS what if you want to share the machine among multiple applications Then OS must manage interactions between different applications and different 1 1 3 users for all hardware resources CPU physical memory I O devices like disks and printers interrupts etc So what is in an OS and what isn t Of course there is no universal agreement on this but Most likely What about Of course the OS can still provide libraries of standard services Memory management i o management CPU scheduling communications multitasking multiprogramming 1 1 7 Example of OS coordination protection Problem How do different applications run on the same machine at the same time without stomping on each other File System Multimedia support User Interface window manager Internet Browser Bonus question is this just of interest to academics If not then why might it be important Goals of protection Keep user programs from crashing OS Keep user programs from crashing each other 1 1 7 1 Hardware support for protection 1 1 4 What if you didn t have an operating system Hardware provides two things to help isolate a program s effects to within just that program Address translation source code compiler object code hardware How do you get object code onto the hardware How do you print out the answer Before OS s used to have to toggle in program in binary and then read Dual mode operation out answers from LED s CS 162 Spring 2003 Lecture 1 3 9 CS 162 Spring 2003 Lecture 1 4 9 1 1 7 2 Address translation Address space literally all the memory addresses a program can touch All the state that a program can affect or be affected by code data Achieve protection by restricting what a program can touch heap Hardware translates every memory reference from virtual addresses to physical addresses software sets up and manages the mapping in the translation box stack prog 1 Virtual Address CPU Translation Box MMU Physical Address virtual address space Physical Memory data2 stack1 code1 heap1 code2 stack2 data1 heap2 code data heap stack prog2 virtual address space OS code OS data OS heap stacks physical memory Data read or write untranslated Example of Address Translation Address Translation in Modern Architectures Two views of memory View from the CPU what program sees virtual memory Translation helps implement protection because there is no way for a program to even talk about other program s addresses no way for it to touch operating system code or data View from memory physical memory Translation box also called a memory management unit converts between the two views Translation also helps with the issue of how to stuff multiple programs into memory Translation is implemented using some form of table lookup we ll discuss various options for implementing the translation box later Separate table for each user address space CS 162 Spring 2003 Lecture 1 5 9 CS 162 Spring 2003 Lecture 1 6 9 1 2 4 3 Dual mode operation Can an application modify its own translation tables If it could then it could get access to all of physical memory Has to be restricted somehow 1 2 Operating Systems Principles Throughout the course you ll see four common themes recurring over and over Dual mode operation When in the OS can do anything called kernel mode supervisor OS as illusionist make hardware limitations go away OS provides illusion of dedicated machine with infinite memory and infinite processors mode or protected mode When in a user program restricted to only touching that program s memory user mode Implemented by setting a hardware provided bit


View Full Document

Berkeley COMPSCI 162 - Lecture Notes

Documents in this Course
Lecture 1

Lecture 1

12 pages

Nachos

Nachos

41 pages

Security

Security

39 pages

Load more
Loading Unlocking...
Login

Join to view Lecture Notes 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 Lecture Notes 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?