Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS Design.

Similar presentations


Presentation on theme: "Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS Design."— Presentation transcript:

1 Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS Design

2 Design of Operating Systems  OS manages h/w resources o Allows running many programs at the same time o Allows programs to interact with h/w devices 2 Hardware OS Kernel Program1UI Background tasks Program2

3 Key Ideas in OS Design  How does OS allow running many programs? o Provides virtualization mechanism that allows programs to share resources securely  How does OS allow programs to interact with h/w? o Provides a h/w abstraction, implemented via system calls 3

4 Virtualization  OS provides the illusion that each program is running on its own machine o Program thinks it has full access to CPU, memory, disk o This is called virtualization because there is one physical machine, but the OS provides the illusion of multiple virtual machines Hardware OS Kernel Program1UI Background tasks Program2 4

5 Benefits of Virtualization  Virtual machines provide resource isolation o Program is not aware that other programs exist, i.e., each program is isolated from others o A program cannot accidentally overwrite another program’s memory or files, causing it to crash o Ideally, if a program uses too much memory, disk, etc., only its performance degrades  What are the properties of an “ideal” virtual machine? 5

6 Implementing Virtualization  OS implements virtual machines by virtualizing each physical resource  Processor -> Threads o OS provides the illusion that a large number of virtual processors, called threads, are available to programs  Run cpu.c  Memory -> Virtual Memory o OS provides the illusion that each program has access to a large amount of contiguous, private memory  Run mem.c  Disk -> Files o OS provides the illusion that a large number of virtual disks, called files, are available to programs 6

7 Concurrency  Thread abstraction is powerful because it allows a program to perform several tasks in parallel (or concurrently) o E.g., a web server can serve multiple web requests, by using a thread per request  However, running threads concurrently raises some challenging problems o Run threads-race.c with args 100, 1000, 10000, 100000 o Run threads-sync.c  The OS runs multiple programs concurrently, and thus must handle these problems as well 7

8 System Calls  Programs request h/w access via system calls o Similar to procedure calls, but a little more complicated o System calls provide an abstraction of h/w, making it easier to write programs  Set of system calls is OS API  Examples: o Create/destroy process o Allocate/deallocate memory o Read/write a file 8

9 System Call Example  Program calls read() syscall to read a file from disk o Execution goes via a library that generates a trap o Trap invokes the kernel, which accesses disk o Kernel returns results to program  Will discuss traps, and need for traps later Hardware OS Kernel Program1 Library 9 trap readreturn results

10 OS Interface 10 OS Kernel Video Card CPU Monitor Printer Disk Memory Network Application layer system calls: thread_create(), read(), write(), thread_join()... Device MgmtFile SystemNetwork Comm. Process MgmtProtectionSecurity Hardware layer virtual machine interface physical machine interface Thread schedulerMemory management OS interface

11 Summary  Two important OS concepts o OS isolates applications using virtualization o OS abstracts h/w with a simpler interface  Virtualization o Each program thinks it owns the machine o Programs don’t need to worry about other running programs  E.g., a program cannot corrupt other programs  Abstraction o Simpler interface to h/w implemented via system calls o Eases programing, improves portability 11


Download ppt "Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS Design."

Similar presentations


Ads by Google