Overview and Introduction to Computing Systems Fred Kuhns Bryan504 fredk@cs.wustl.edu Introduction • A computer system consists of – hardware – system programs – application programs Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 2 What is an Operating System • It is an extended machine (Presents a Convenient Interface to users) – Hides the messy details which must be performed – Presents user with a virtual machine, easier to use • It is a resource manager – Each program gets time with the resource – Each program gets space on the resource Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 3 History of Operating Systems Early batch system – – – – bring cards to 1401 read cards to tape put tape on 7094 which does computing put tape on 1401 which prints output Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 4 History of Operating Systems • First generation 1945 - 1955 – vacuum tubes, plug boards • Second generation 1955 - 1965 – transistors, batch systems • Third generation 1965 – 1980 – ICs and multiprogramming • Fourth generation 1980 – present – personal computers Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 5 History of Operating Systems • Structure of a typical FMS job – 2nd generation Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 6 History of Operating Systems • Multiprogramming system – three jobs in memory – 3rd generation Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 7 Current “Specialized” OSes • • • • • • • Mainframe operating systems Server operating systems Multiprocessor operating systems Personal computer operating systems Real-time operating systems Embedded operating systems Smart card operating systems Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 8 Basic Hardware Elements • Processor - traditionally controls the operation of the computer and performs the data processing function • Memory - Stores data and programs, typically volatile (aka real or primary memory) • I/O modules - move data between computer and external environment (i.e. disks, network) • System Bus - communication among processors, memory, and I/O modules Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 9 Computer Hardware Review Monitor Bus • Components of a simple personal computer Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 10 Computer Components: Another view CPU PC MAR IR MBR Memory .. . Instruction Instruction Instruction .. . Data Data Data Data .. . I/O AR execution unit I/O BR I/O Module .. Buffers N PC - Program Counter IR - Instruction Register MAR - Memory Address Register Fred Kuhns (6/23/2016) 0 1 MBR - Memory Buffer Register I/O AR - Input/Output Address Register I/O BE - Input/Output Buffer Register CS422S: Operating Systems Organization 11 Control and Status Registers • Program Counter (PC) – Contains the address of an instruction to be fetched • Instruction Register (IR) – Contains the instruction most recently fetched • Program Status Word (PSW) – condition codes – Interrupt enable/disable – Supervisor/user mode Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 12 Instruction Cycle • Processor fetches instruction from memory • PC contains address of next instruction to be fetched • PC incremented after each fetch Fetch Cycle START Fred Kuhns (6/23/2016) Fetch Next Instruction Execute Cycle Execute Instruction CS422S: Operating Systems Organization HALT 13 Modern Instruction Cycle (a) A three-stage pipeline (b) A superscalar CPU Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 14 Typical memory hierarchy • numbers shown are rough approximations Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 15 Going Down the Hierarchy • • • • Decreasing cost per bit Increasing capacity Increasing access time Decreasing frequency of access of the memory by the processor – exploit locality of reference Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 16 Cache/Main-Memory Structure Slot Number Tag Memory Address 0 1 2 3 Block (k words) Block 0 1 2 C - 1 Block Length (k words) (b) Cache Block 2n - 1 Word Length (a) Main Memory Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 17 Cache Design • Write policy – keeping cache and main memory consistent • Mapping function – determines which cache location block occupies • Replacement algorithm – determines which block to replace (LRU) • Block size – data unit exchanged between cache and main memory Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 18 Structure of a disk drive Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 19 Multiprogramming and Addressing • program addresses are relative to Base Address • MMU maps virtual to physical address Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 20 I/O Techniques • Programmed I/O – Processor does all the work. Poll for results. • Interrupt Driven I/O – Device notifies CPU when I/O operation complete • Direct memory access (DMA) – DMA controller performes “Programmed I/O”, not CPU. – CPU notified with DMA complete Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 21 I/O Operations and Interrupts (a) (b) (a) Steps in starting an I/O and receiving interrupt (b) How the CPU is interrupted Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 22 Instruction Cycle with Interrupts Interrupt Cycle Execute Cycle Interrupts Disabled START Fetch Next Instruction Execute Instruction Interrupts Enabled Fetch Cycle Check for & Process Int HALT Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 23 Buses • Structure of a large Pentium system Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 24 Basic Operating System Concepts • • • • • • • • Processes Deadlocks Memory Management Input/Output Files Security The Shell Policy versus Mechanism Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 25 What is A Process? • A process is a program in execution. A process needs resources (CPU time, memory, files, I/O devices) to accomplish task. • Process management activities: – creation and deletion. – suspension and resumption. – Mechanisms for synchronization, communication and deadlock handling Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 26 Processes - An Introduction • A process tree – A created two child processes, B and C – B created three child processes, D, E, and F Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 27 Process Memory Space • Processes have three segments: text, data, stack Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 28 Deadlock - An Introduction (a) A potential deadlock. (b) an actual deadlock. Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 29 Example File System Structure File system for a university department Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 30 File Systems • Before mounting, – files on floppy are inaccessible • After mounting floppy on b, – files on floppy are part of file hierarchy Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 31 Inter-Process Communication Two processes connected by a pipe Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 32 System Calls • Interface between running program and the operating system – Generally written in assembly-language – Wrapper libraries provide high-level interface • Three general methods are used to pass parameters: – Pass parameters in registers. – Store the parameters in a table in memory. – Push (store) the parameters onto the stack by the program. Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 33 Steps in Making a System Call There are 11 steps in making the system call read (fd, buffer, nbytes) Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 34 Some System Calls For Process Management Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 35 Some System Calls For File Management Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 36 Some System Calls For Directory Management Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 37 Some System Calls For Miscellaneous Tasks Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 38 System Calls - Process Management • A stripped down shell: while (TRUE) { /* repeat forever */ type_prompt( ); /* display prompt */ read_command (command, parameters) /* input from terminal */ if (fork() != 0) { /* Parent code */ waitpid( -1, &status, 0); */ } else { /* Child code */ execve (command, parameters, 0); }} Fred Kuhns (6/23/2016) /* fork child process */ /* wait for child to exit /* execute command */ CS422S: Operating Systems Organization 39 System Calls (a) Two directories before linking /usr/jim/memo to ast's directory (b) The same directories after linking Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 40 System Calls (a) File system before the mount (b) File system after the mount Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 41 System Calls Some Win32 API calls Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 42 Monolithic Design Simple structuring model for a monolithic system Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 43 Layered Design Structure of the THE operating system Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 44 Virtual Machines Structure of VM/370 with CMS Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 45 Client-Server Model The client-server model Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 46 Microkernel Design The client-server model in a distributed system Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 47 Policy Versus Mechanism • Policy (What) - Specifies desired behavior or What should occur • Mechanisms (How) - how the policy is carried out - implementation of core processing. • The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed later. Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 48 Metric Units The metric prefixes Fred Kuhns (6/23/2016) CS422S: Operating Systems Organization 49