COMP 530 Operating Systems Welcome to COMP 530 Don Porter 1 COMP 530 Operating Systems Welcome Today s goals Give you a flavor of my teaching style with a mini lecture Cover course organization My high level goals for the class Demystify how computers work No magic Learn core principles secure multiplexing scheduling concurrency performance analysis This is a class for everyone not just gurus Challenging but supportive environment 2 COMP 530 Operating Systems So what is an OS 2 3 COMP 530 Operating Systems One view of an OS 2 4 COMP 530 Operating Systems Another simple view of an OS App App App App OS Hardware 2 5 HardwareOSAppAppAppApp COMP 530 Operating Systems A less happy view of an OS 2 6 COMP 530 Operating Systems So which one is right They all are 2 7 COMP 530 Operating Systems An OS serves three constituencies 1 Human users a desktop environment 2 Application Developers More usable abstractions of the hardware 3 Hardware manufacturers An abstraction of the applications to the device 2 8 COMP 530 Operating Systems Why Study Operating Systems Primary Goal Demystify how computers work Lots of abstractions and heuristics between your application and the hardware A good computer scientist should understand what happens inside the system when one types a command Secondary Learn how to write robust programs OSes like Linux have many users and work on a wide range of hardware Deal with subtle issues concurrency consistency etc COMP 530 Operating Systems Background 1 CPUs have 2 modes user and supervisor Sometimes more but whatevs Supervisor mode Issue commands to hardware devices Power off Reboot Suspend Launch missiles Do awesome stuff User mode Run other code hardware tattles if you try anything reserved for the supervisor 2 10 COMP 530 Operating Systems OS architecture App App App App OS Hardware 2 11 HardwareOSAppAppAppApp COMP 530 Operating Systems OS architecture App App App App Libraries Kernel Hardware User Super visor 2 12 HardwareLibrariesAppAppAppAppKernel COMP 530 Operating Systems User 2 Applications Application Programming Interface API Win32 Windows POSIX Unix Linux Cocoa Cocoa Touch Mac OS iOS Application facing functions provided by libraries Injected by the OS into each application 2 13 COMP 530 Operating Systems OS architecture App App App App Libraries Kernel Hardware User Super visor 2 14 HardwareLibrariesAppAppAppAppKernel COMP 530 Operating Systems OS architecture Win32 API App App App Libraries Libraries Libraries Kernel Hardware User Super visor 2 15 AppHardwareLibrariesKernelAppLibrariesAppLibrariesWin32API COMP 530 Operating Systems Famous libraries anyone Windows ntdll dll kernel32 dll user32 dll gdi32 dll Linux Unix libc so ld so libpthread so libm so 2 16 COMP 530 Operating Systems Caveat 1 Libraries include a lot of code for common functions Why bother reimplementing sqrt They also give high level abstractions of hardware Files printer dancing Homer Simpson USB doll How does this work 2 17 COMP 530 Operating Systems System Call Special instruction to switch from user to supervisor mode Transfers CPU control to the kernel One of a small ish number of well defined functions How many system calls does Windows or Linux have Windows 1200 Linux 350 2 18 COMP 530 Operating Systems OS architecture Open file hw1 txt Ok here s handle 4 App App App Libraries Libraries Libraries System Call Table 350 1200 User Super visor Kernel Hardware 2 19 AppHardwareLibrariesKernelAppLibrariesAppLibrariesSystem Call Table 350 1200 Open file hw1 txt Ok here s handle 4 COMP 530 Operating Systems Caveat 2 Some libraries also call special apps provided by the OS called a daemon or service Communicate through kernel provided API Example Print spooler App sends pdf to spooler Spooler checks quotas etc Turns pdf into printer specific format Sends reformatted document to device via OS kernel 2 20 COMP 530 Operating Systems OS architecture App App Daemon Libraries Libraries Libraries System Call Table 350 1200 Kernel Hardware User Super visor 2 21 AppHardwareLibrariesKernelAppLibrariesDaemonLibrariesSystem Call Table 350 1200 COMP 530 Operating Systems User 3 Hardware OS kernels are programmed at a higher low level of abstraction Disk blocks vs specific types of disks For most types of hardware the kernel has a lowest common denominator interface E g Disks video cards network cards keyboard Think Java abstract class Sometimes called a hardware abstraction layer HAL Each specific device Nvidia GeForce 600 needs to implement the abstract class Each implementation is called a device driver 2 22 COMP 530 Operating Systems OS architecture App App Daemon Libraries Libraries Libraries System Call Table 350 1200 Driver Driver Kernel HAL Driver Hardware User Super visor 2 23 AppHardwareLibrariesKernelAppLibrariesDaemonLibrariesSystem Call Table 350 1200 HALDriverDriverDriver COMP 530 Operating Systems What about User 1 What is the desktop Really just a special daemon that interacts closely with keyboard mouse and display drivers Launches programs when you double click etc Some program libraries call desktop daemon to render content etc 2 24 COMP 530 Operating Systems An OS serves three types of users 1 Give users a desktop environment Desktop or window manager or GUI 2 Give applications a more usable abstraction of the hardware Libraries system calls and daemons 3 Give hardware manufacturers an abstraction of the applications Device Driver API or HAL 2 25 COMP 530 Operating Systems Multiplexing Resources Many applications may need to share the hardware Different strategies based on the device Time sharing CPUs disk arm Each app gets the resource for a while and passes it on Space sharing RAM disk space Each app gets part of the resource all the time Exclusive use mouse keyboard video card One app has exclusive use for an indefinite period COMP 530 Operating Systems So what is Linux Really just an OS kernel Including lots of device drivers Conflated with environment consisting of Linux kernel Gnu libc X window manager daemon CUPS printer manager Etc 2 27 COMP 530 Operating Systems So what is Ubuntu Centos A distribution bundles all of that stuff together Pick versions that are tested to work together Usually also includes a software update system 2 28 COMP 530 Operating Systems OSX vs iOS Same basic kernel a few different compile options Different window manager and libraries 2 29 COMP 530 Operating Systems What is Unix A very old OS 1970s innovative still in use Innovations Kernel written
View Full Document