CS241Systems ProgrammingOverviewOverviewIntroductionWhat is an Operating SystemHistory of Operating Systems (1)History of Operating Systems (2)History of Operating Systems (3)History of Operating Systems (4)The Operating System ZooA Typical Computer from a Hardware Point of ViewA Typical Computer System (black box)ProcessorsMemory-Storage HierarchyMemoryI/O DevicesBusA peek into Unix/LinuxUnix: ApplicationUnix: LibrariesTypical Unix OS StructureTypical Unix OS StructureAnother Look: Unix “Onion”System CallsOS Major ConceptsProcess: a running programSome System Calls For Process ManagementFilesFile System ExampleFile SystemSteps in Making a System CallShellYou Live in Interesting Times…SummaryCS241Systems ProgrammingOverview Klara NahrstedtLecture 1January 20, 20061/20/2006CS 241 - Systems Programming, Klara Nahrstedt2OverviewzWhat is Operating System? z Brief History of OSz Hardware overviewz A peek at Unix z OS Major Concepts1/20/2006CS 241 - Systems Programming, Klara Nahrstedt3IntroductionzA computer system consists of–hardware–system programs–application programs1/20/2006CS 241 - Systems Programming, Klara Nahrstedt4What is an Operating SystemzIt is an extended machine–Hides the messy details which must be performed–Presents user with a virtual machine, easier to usez It is a resource manager–Each program gets time with the resource–Each program gets space on the resource1/20/2006CS 241 - Systems Programming, Klara Nahrstedt5History of Operating Systems (1)Early batch system–bring cards to 1401–read cards to tape–put tape on 7094 which does computing–put tape on 1401 which prints output1/20/2006CS 241 - Systems Programming, Klara Nahrstedt6History of Operating Systems (2)zFirst generation 1945 – 1955–vacuum tubes, plug boardszSecond generation 1955 - 1965–transistors, batch systemszThird generation 1965 – 1980–ICs and multiprogrammingzFourth generation 1980 – present–personal computers1/20/2006CS 241 - Systems Programming, Klara Nahrstedt7History of Operating Systems (3)zStructure of a typical FMS job – 2ndgeneration1/20/2006CS 241 - Systems Programming, Klara Nahrstedt8History of Operating Systems (4)zMultiprogramming system–three jobs in memory – 3rdgeneration1/20/2006CS 241 - Systems Programming, Klara Nahrstedt9The Operating System ZoozMainframe operating systemszServer operating systemszMultiprocessor operating systemszPersonal computer operating systemszReal-time operating systemszEmbedded operating systemszSmart card operating systems1/20/2006CS 241 - Systems Programming, Klara Nahrstedt10A Typical Computer from a Hardware Point of ViewCPUChipsetMemoryI/O busCPU. . .Network1/20/2006CS 241 - Systems Programming, Klara Nahrstedt11A Typical Computer System (black box)Operating System SoftwarePrograms and dataMemoryCPUCPU...OSAppsDataNetwork1/20/2006CS 241 - Systems Programming, Klara Nahrstedt12ProcessorszEach CPU has a specific set of instructionsz All CPUs contain–General registers inside to hold key variables and temporary results–Special registers visible to the programmerzProgram counter contains the memory address of the next instruction to be fetchedzStack pointer points to the top of the current stack in memoryzPSW (Program Status Word) contains the condition code bits which are set by comparison instructions, the CPU priority, the mode (user or kernel) and various other control bits.1/20/2006CS 241 - Systems Programming, Klara Nahrstedt13Memory-Storage Hierarchy1/20/2006CS 241 - Systems Programming, Klara Nahrstedt14MemoryzRegisters internal to CPU (as fast as CPU)–Storage 32x32 bits on a 32-bit CPU, 64x64 on 64 bit CPU (less than 1KB in both cases)zCache memory controlled by hardware–Cache hit and misszRAM (Random Access Memory)zDisk (magnetic disk), CD-ROM, DVD,…–Cylinder, track, …zNon-volatile Memory–ROM (Read Only Memory) z Programmed at the factory and can’t be changed–EEPROM (Electrically Erasable ROM) –Flash RAMz Can be erased and re-writtenzVolatile Memory –CMOS holds current time and date1/20/2006CS 241 - Systems Programming, Klara Nahrstedt15I/O DeviceszController–Example: Disk Controller–Controllers are complex converting OS request into device parameters–Controllers often contain small embedded computerszDevice–Fairly simple interfaces and standardized–IDE (Integrated Drive Electronics) – standard disk type on Pentiums and other computerszDevice Driver–Needed since each type of controller may be different. –Software that talks to a controller, giving it comments and accepting responses–Each controller manufacturer supplies a driver for each OS it supports (e.g., drivers for Windows XP, Longhorn, UNIX)1/20/2006CS 241 - Systems Programming, Klara Nahrstedt16BuszPentium systems have eight buses–Cache, local, memory, PCI, SCSI, USB, IDE, ISAzPCI (Peripheral Component Interconnect) bus is successor to IBM PC ISA bus– Intel bus, 528MB/seczISA (Industry Standard Architecture) bus– 16.67 MB/sec–Specialized buses:zSCSI (Small Computer System Interface)– 160MB/sec – for disks, scanners (popular on Macintosh, UNIX)zUSB (Universal Serial Bus) – 1.5 MB/seczIEEE 1394 – FireWire (Apple) bus– 50MB/sec, connectivity for cameras to computerzIDE (Integrated Drive Electronics) bus– Disk, CD-ROM1/20/2006CS 241 - Systems Programming, Klara Nahrstedt17A peek into Unix/LinuxApplicationPortable OS LayerLibrariesMachine-dependent layerUser space/levelKernel space/level• User/kernel modes are supported by hardware •Some systems do not have clear user-kernel boundary1/20/2006CS 241 - Systems Programming, Klara Nahrstedt18Unix: ApplicationApplication (E.g., emacs)LibrariesWritten by programmerCompiled by programmerUses function callsPortable OS LayerMachine-dependent layer1/20/2006CS 241 - Systems Programming, Klara Nahrstedt19Unix: LibrariesApplicationLibraries (e.g., stdio.h)Portable OS LayerMachine-dependent layerProvided pre-compiledDefined in headersInput to linker (compiler)Invoked like functionsMay be “resolved” when program is loaded1/20/2006CS 241 - Systems Programming, Klara Nahrstedt20Typical Unix OS StructureApplicationLibrariesPortable OS LayerMachine-dependent layersystem calls (read, open..)All “high-level” code1/20/2006CS 241 - Systems Programming, Klara Nahrstedt21Typical Unix OS StructureApplicationLibrariesPortable OS LayerMachine-dependent layerBootstrapSystem initializationInterrupt and exception I/O device driverMemory
View Full Document