12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec...

16
12/2/09 1 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13

description

What is an Operating System Resources –Textbooks I like: 12/2/09 UCB CS61CL F09 Lec 13 3

Transcript of 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec...

Page 1: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

12/2/09 1

What is an Operating System

Andy KonwinskiCS61CL

Dec 2, 2009Lecture 13

UCB CS61CL F09 Lec 13

Page 2: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Today• What is an operating system• Dual mode operation: kernel vs. user mode• Current trends and issues

12/2/09 UCB CS61CL F09 Lec 13 2

Page 3: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

What is an Operating System• Resources

– Textbooks I like:

12/2/09 UCB CS61CL F09 Lec 13 3

Page 4: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

What is an Operating System• No single all encompassing definition• Used to be an actual person, an “operator”

– You were operator for your CAL16 processor

• General definition:– A layer of software that provides user programs

with a simpler, cleaner, model of the computer and handles the messy job of managing the resources.

12/2/09 UCB CS61CL F09 Lec 13 4

Page 5: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

What is an Operating System• Where the OS fits in

12/2/09 UCB CS61CL F09 Lec 13 5

(modified version of fig 1-1, tanenbaum, pg2)

software

hardware

Operating SystemKernel mode

User mode Music player

Email readerWeb browser

Page 6: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Part 1: Clean abstractions of HW• Hardware is messy (e.g. assembly lang.,

interacting with a device)• Application developers want useful high level

abstractions

12/2/09 UCB CS61CL F09 Lec 13 6

Page 7: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Example: File System• Application level: files• Hardware level: controller, blocks• Operating system to manage the mapping

between files and blocks, also protection.

12/2/09 UCB CS61CL F09 Lec 13 7

MS Word Foo.txt

File System

Operating System

Sector #, disk#

Disk controller

Disk

Cylinder, sector, head

Network controller

Frames, MAC address

NIC

Page 8: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Part 2: Resource manager• Multiplex one set of hardware resources

between apps/users– CPU/Memory/cache– I/O devices

» Communication (network cards, hard drive)» Human I/O (mouse, keyboard, monitor, printer)

12/2/09 UCB CS61CL F09 Lec 13 8

CPUHardDrive

network…

Andy: MS Word

Andy: Day of Defeat

Jamie: WinAmp

Page 9: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Part 2b: fault/performance isolation• Resources should be shared fairly• Isolation between users (processes)

– Fault isolation: when one program crashes, it should not cause others to crash

– Performance isolation: e.g. if spotlight runs, my Quicktime movie shouldn’t skip.

12/2/09 UCB CS61CL F09 Lec 13 9

Page 10: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Example: virtual memory• Each application sees continuous, nearly

infinite, mem. address namespace• Hardware provides: finite memory, page

table base register, TLB, disk• Operating system: orchestrates.

– manages page table entries (e.g. updating Valid bit when swapping), flushes the TLB when necessary, pages to disk, etc.

12/2/09 UCB CS61CL F09 Lec 13 10

Page 11: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Administrative• Midterm 2 back last week, regrades done• This is final class• Optional lab on threads• Regrade requests for Midterm 2 due by end

of day Friday• Review lecture next week

12/2/09 UCB CS61CL F09 Lec 13 11

Page 12: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Dual mode operation• Hardware knows that an operating system will be

used, and that it needs more privileges than application software.

• Hardware bit for user/kernel mode.• Need kernel mode access for:

– Accessing kernel data structures, e.g. list open files– Mapping device mem to main mem, e.g. graphics card– Kernel registers, e.g. page table offset– Privileged instructions, e.g. switch to kernel mode

12/2/09 UCB CS61CL F09 Lec 13 12

Page 13: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Switching between User/Kernel mode

12/2/09 UCB CS61CL F09 Lec 13 13

Application code:

OS code:

KernelUser

Mode bit:

Instruction 1Instruction 2…SyscallInstruction N……

Bootup instructions…Dispatch application…Handle syscall… Finish syscall

Page 14: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Interrupts• Hardware interrupts• Software-generated interrupts (called Traps)

– System calls: user has OS do something on its behalf, trap or syscall instruction.

– Exceptions: if privileged instruction called when in user-level, handled similar to a system call

12/2/09 UCB CS61CL F09 Lec 13 14

Page 15: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Trends• OS used to handle concurrency for us (time

sharing), now applications are making smarter use of concurrency (threading)

– ParLab

• Cloud computing– RAD Lab

12/2/09 UCB CS61CL F09 Lec 13 15

Page 16: 12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.

Summary• OS multiplexes hardware resources &

provides clean abstraction for applications. • Dual mode operation, interrupts, exceptions• Parallel and cloud computing

• Take CS162 to pick up where we’re leaving off and actually build an OS (and see more of me)!

12/2/09 UCB CS61CL F09 Lec 13 16