This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Page 1 CS162 Operating Systems and Systems Programming Lecture 12 Kernel/User, I/O, Disks February 29, 2012 Anthony D. Joseph and Ion Stoica http://inst.eecs.berkeley.edu/~cs162 12.2 2/29/2012 Anthony D. Joseph and Ion Stoica CS162 ©UCB Spring 2012 • Dual Mode Operation: Kernel versus User Mode • I/O Systems – Hardware Access – Device Drivers • Disk Performance – Hardware performance parameters Note: Some slides and/or pictures in the following are adapted from slides ©2005 Silberschatz, Galvin, and Gagne. Many slides generated from my lecture notes by Kubiatowicz. Goals for Today 12.3 2/29/2012 Anthony D. Joseph and Ion Stoica CS162 ©UCB Spring 2012 Review: Example of General Address Translation Prog 1 Virtual Address Space 1 Prog 2 Virtual Address Space 2 Code Data Heap Stack Code Data Heap Stack Data 2 Stack 1 Heap 1 OS heap & Stacks Code 1 Stack 2 Data 1 Heap 2 Code 2 OS code OS data Translation Map 1 Translation Map 2 Physical Address Space 12.4 2/29/2012 Anthony D. Joseph and Ion Stoica CS162 ©UCB Spring 2012 Dual-Mode Operation • Can an application modify its own translation maps? – If it could, could get access to all of physical memory – Has to be restricted somehow • To assist with protection, hardware provides at least two modes (Dual-Mode Operation): – “Kernel” mode (or “supervisor” or “protected”) – “User” mode (Normal program mode) – Mode set with bits in special control register only accessible in kernel-mode • Intel processors actually have four “rings” of protection: – PL (Privilege Level) from 0 – 3 » PL0 has full access, PL3 has least – Typical OS kernels on Intel processors only use PL0 (“kernel”) and PL3 (“user”) Page 2 12.5 2/29/2012 Anthony D. Joseph and Ion Stoica CS162 ©UCB Spring 2012 For Protection, Lock User-Programs in Asylum • Idea: Lock user programs in padded cell with no exit or sharp objects – Cannot change mode to kernel mode – User cannot modify translation maps – Limited access to memory: cannot adversely effect other processes » Side-effect: Limited access to memory-mapped I/O operations – What else needs to be protected? • A couple of issues – How to share CPU between kernel and user programs? » Kinda like both the inmates and the warden in asylum are the same person. How do you manage this??? – How does one switch between kernel and user modes? » OS → user (kernel → user mode): getting into cell » User → OS (user → kernel mode): getting out of cell 12.6 2/29/2012 Anthony D. Joseph and Ion Stoica CS162 ©UCB Spring 2012 How to get from Kernel → User • What does the kernel do to create a new user process? – Allocate and initialize process control block – Read program off disk and store in memory – Allocate and initialize translation map » Point at code in memory so program can execute » Possibly point at statically initialized data – Run Program: » Set machine registers » Set hardware pointer to translation table...
View Full Document
- Spring '02
- Operating Systems, Virtual memory, Input/output, Seek time, Anthony D. Joseph, Ion Stoica