SMD149 - Roland Parviainen October 31, 2005 1 / 54
Overview Course Information Roland Parviainen E-mail: rolle@csee.ltu.se, rolle@parviainen.org Phone: 070-5317170 Office:? Web: http://parviainen.org 2 / 54
Outline Overview Course Information to the course to Operating systems and a brief history Hardware and software concepts 3 / 54
Course Objectives Overview Course Information Fundamental course in systems programming and operating systems (theory and development) By the end of this course, you should Have gained an understanding of the evolution and purpose of an operating system Be able to describe the key elements of an operating system and their functionalities and interdependences Have learnt the significance of application programming interface (API) Have gained hands-on experience in implementing some OS functionalities 4 / 54
Course Information Overview Course Information Prerequisites SMD135 Program and data structures SMD137 Computer organization and logic design SMD138 Real-time systems Course textbook by H. M. Deitel, P. J. Deitel and D. R. Choffnes, Prentice Hall Publication, 3rd edition, 2004 (ISBN: 0131246968) Available at Bokis (680 kr) Other modern books should work as well http://www.sm.luth.se/csee/courses/smd/149/ Home work assignments, labs, news, slides, etc. 5 / 54
Course Structure Overview Course Information Modules Theoretical Processes and Threads Physical and Virtual Memory Secondary Storage and File Systems Processors: Performance and Management Networking and Distributed Computing Security Issues Laborations Systems programming (C/Unix) and Operating systems programming (Java/Nachos) 6 / 54
Lectures and labs Overview Course Information 15 scheduled, but only 14 will be used 2 lectures will cover laborations (systems programming, nachos) 10 scheduled labos 7 / 54
Examination and grading Overview Course Information No final exam Continuous examination Five homework assignments (each worth 40 points) You will generally have one week per homework Late submissions will NOT be graded Redo or repair of assignments is not permitted; exception: if you need 10 points or less to pass the course Three lab assignments (each worth 100 points) You will will generally have two weeks per lab Late submission can only get a maximum of pass grade Submissions after LP-2 (2005/06) ends will NOT be graded 8 / 54
Examination and grading Overview Course Information Maximum achievable number of points in the course is 500 (200 theoretical + 300 laborations) To pass the course (i.e., grade 3 ), you need to have passed both the theoretical and practical parts of the course At least 100 points to pass the theory part At least 150 points to pass the laborations part Grade 4 - at least 325 points and passed both parts Grade 5 - at least 400 points and passed both parts 9 / 54
Operating systems History Architectures What is an operating system The software that controls the hardware...all the software that is required in order for the user to manage the system and to run third-party application software for that system. In computing, an operating system (OS) is the system software responsible for the direct control and management of hardware and basic system operations. Additionally, it provides a foundation upon which to run application software such as word processing programs and web browsers. Resource manager 10 / 54
Operating systems History Architectures Components Kernel Shell Core components Often in the kernel: Processor scheduler Memory manager I/O manager Interprocess communication (IPC) manager File system manager 11 / 54
Operating systems History Architectures What is part of an operating system Kernel, Shells, Software Libraries, Application Programs, GUIs? Controversy United States v. Microsoft antitrust trials GNU/Linux naming controversy 12 / 54
Brief history History Architectures 40s and 50s Early computers had no operating system Single job at a time Faster computers - job switching overhead increased Single stream batch-processing systems Programs and data submitted at the same time Machine operators, not users, handled computers Replaced by operating systems... 13 / 54
History Architectures 60s Several jobs at a time I/O bound and processour bound jobs Multiprogramming 1964: System/360 with OS/360 from IBM (later MFT, MVT, SVS, MVS, MVS/XA, MVS/ESA, OS/390 and z/os) Interactive users Timesharing Real-time systems response in bounded time periods CTSS (Compatible time-sharing system), TSS (Time-sharing system), Multics, CP/CMS (Control program/conversational Monitor System) 14 / 54
History Architectures 60s Multics Developed using CTSS High level language Hardware: 400-1000 KMIPS Partly inspired Unix (Unics - Multics - bad pun...) Virtual Memory Unix 15 / 54
History Architectures 70s Commercialization of time-sharing systems Ethernet/LANs Foundations of Internet are started TCP, TCP/IP Personal computing starts 16 / 54
History Architectures 80s TCP/IP replaces NCP, DNS is developed 8 and 16 bit personal computers GUIs Xeroc Palo Alto Research Center (Xerox PARC) Apple Macintosh Distributed computing - client/server 17 / 54
History Architectures 90s HTTP and WWW Distributed computing explosion PCs with hundreds of MIPS Microsoft domination Plug and play 18 / 54
History Architectures 00s Middleware Web services Small and mobile devices 19 / 54
Architectures History Architectures Components Kernel Shell Core components Processor scheduler Memory manager I/O manager Interprocess communication (IPC) manager File system manager 20 / 54
Monolithic History Architectures All core components inside the kernel Modules can communicate directly through function calls Highly efficient Bugs and errors can be hard to isolate Security? Linux, many BSD systems, Solaris 21 / 54
History Architectures 22 / 54
Layered History Architectures Groups similar functions in layers Layers communicate only with the layer above or below Interfaces hides implementation Calls may have to go through several layers 23 / 54
History Architectures 24 / 54
Microkernel History Architectures Kernel only provides a small number of services (MM, IPC, synchronization) More advanced services are implemented as user processes Often inefficient: intermodule communication, context switches are expensive, etc. Mach, L4, QNX, BeOS, Minix Not to be confused with modular monolithic operating systems 25 / 54
History Architectures 26 / 54
History Architectures Microkernel vs. Monolithic vs. Layered Famous discussion: Linus Torvalds vs. Andy Tanenbaum, 1992: Linux is obsolete (http://www.oreilly.com/catalog/opensources/book/appa.html) Often partly mixed MacOS X, Windows NT (and XP, Vista, etc) 27 / 54
Network and distributed systems History Architectures Network Operating systems Runs on one computer Allows its processes to access resources on remote computers Distributed operating systems Single OS that manages resources on more than one computer system Amoeba, Chord Goals Transparent performance Scalability Fault tolerance Consistency 28 / 54
Hardware components A computer s hardware typically consists of: processor(s) main memory input/output devices Printed Circuit Board (PCB) Hardware component that provides electrical connections between devices The mainboard is the central PCB in a computer Devices such as processors and main memory are attached Include chips to perform low-level operations (e.g., BIOS) 29 / 54
Processor A processor is hardware that executes machine- language CPU executes the instructions of a program Coprocessor executes special-purpose instructions Registers are high-speed memory located on processors Data must be in registers before a processor can operate on it Instruction length is the size of a machine-language instruction 30 / 54
31 / 54
32 / 54
Main memory and storage Memory Main memory consists of volatile random access memory (RAM) Processes can access data locations in any order Common forms of RAM include: dynamic RAM (DRAM) - requires refresh circuit static RAM (SRAM) - does not require refresh circuit Secondary storage Secondary storage stores large quantities of persistent data at low cost Accessing data on a hard disk is slower than main memory Mechanical movement of read/write head Rotational latency Transfer time 33 / 54
Buses A bus is a collection of traces Traces are thin electrical connections that transport information between hardware devices A port is a bus that connects exactly two devices An I/O channel is a bus shared by several devices to perform I/O operations Example, the frontside bus (FSB) connects a processor to main memory 34 / 54
Direct Memory Access (DMA) DMA improves data transfer between memory and I/O devices Devices and controllers transfer data to and from main memory directly Processor is free to execute software instructions DMA channel uses an I/O controller to manage data transfer Notifies processor when I/O operation is complete Improves performance in systems that perform large numbers of I/O operations (e.g., mainframes and servers) 35 / 54
36 / 54
Processor support for Processor protection mechanismns for operating systems Prevents processes from accessing privileged instructions or memory Computer systems generally have several different execution modes: User mode (user state or problem state) User may execute only a subset of instructions Kernel mode (supervisor state) Processor may access privileged instructions and resources on behalf of processes 37 / 54
Interrupts and exceptions Discovering changes Polling Interrupts Exception 38 / 54
Timers and Clocks Timers An interval timer periodically generates an interrupt Operating systems use interval timers to prevent processes from monopolizing the processor Clocks Provide a measure of continuity A time-of-day clock enables an OS to determine the current time and date 39 / 54
Bootstrapping Loading initial OS components into memory Performed by a computer s Basic Input/Output System (BIOS) Initializes system hardware Loads instructions into main memory from a region of secondary storage called the boot sector If the system is not loaded, the user will be unable to access any of the computer s hardware 40 / 54
41 / 54
Caching Caches Relatively fast memory Maintain copies of data that will be accessed soon Increase program execution speed Examples include: L1 and L2 processor caches Main memory can be viewed as a cache for hard disks and other secondary storage devices 42 / 54
Buffering and Spooling Buffers Temporary storage area that holds data during I/O transfers Primarily used to: Coordinate communications between devices operating at different speeds Store data for asynchronous processing Allow signals to be delivered asynchronously Spooling Buffering technique in which an intermediate device, such as a disk, is interposed between a process and a low-speed I/O device Allows processes to request operations from a peripheral device without requiring that the device be ready to service the request 43 / 54
Software support Programming languages Some are directly understandable by computers, others require translation Classified generally as either: Machine language Assembly language High-level language Compilers, Interpreters, Loaders Firmware Middleware 44 / 54
Compiling, Linking and Loading Before a high-level-language program can execute, it must be: Translated into machine language Linked with various other machine-language programs on which it depends Loaded into memory 45 / 54
Compiling Translating high-level code to machine code Accepts source code as input and returns object code 46 / 54
Linking Create a single executable unit Integrate precompiled modules called libraries referenced by a program Assign relative addresses to different program or data units Resolve all external references between subprograms Produce an integrated module called a load module Linking can be performed at compile time, before loading, at load time or at runtime 47 / 54
Dynamic linking Executable contains undefined symbols and a list with objects/libraries that provides definitions Libraries need to be stored in one location only Errors in libraries can easily be fixed Multiple versions of libraries? 48 / 54
Loading Convert relative addresses to physical addresses Place each instruction and data unit in main memory Techniques for loading a program into memory Absolute loading Place program at the addresses specified by programmer or compiler (assuming addresses are available) Relocatable loading Relocate the program s addresses to correspond to its actual location in memory Dynamic loading Load program modules upon first use 49 / 54
50 / 54
51 / 54
52 / 54
Firmware and Middleware Firmware contains executable instructions stored in persistent memory attached to a device Programmed with microprogramming Layer of programming below a computer s machine-language Microcode: simple, fundamental instruction necessary to implement all machine-language operations More and more frequently: high-level languages Middleware is software for distributed systems Enables interactions among multiple processes running on one or more computers across a network Facilitates heterogeneous distributed systems Simplifies application programming 53 / 54
http://www.sm.luth.se/csee/courses/smd/149/ Home work assignment 1 deadline: 14 Nov. Next: Processes and threads Chapters 3, 4, 5 (Sections 5.1-5.3), 8 (Sections 8.1-8.7.5) 54 / 54