Operating Systems

User OS

Kernel & Device Drivers

Interface Programs

Introduction

Introduction Brian Mitchell ([email protected]) - Operating Systems 1 Introduction

• Instructor Brian Mitchell - “Brian” [email protected] www.mcs.drexel.edu/~bmitchel

• TA - To Be Announced • Course Information MCS720 – Tuesday’s 6 - 9 PM • Online Information www.mcs.drexel.edu/~bmitchel/course/mcs720 Please check course web page several times per week. The web page will be my primary mechanism for communicating: Special and Emergency Information (posted by 12:00 noon on day of the class) Syllabus Assignments Exam Information Solutions to Problems

Introduction Brian Mitchell ([email protected]) - Operating Systems 2 Introduction

• Course Objective – To investigate classical internal algorithms and structures of operating systems – Machine Architectures – Concurrent Programming • Textbook Applied Operating Systems Concepts, Avi Silberschatz, Peter Galvin, Greg Gagne • Additional References Modern Operating Systems, Andrew Tanenbaum Distributed Operating Systems, Andrew Tanenbaum Selected research papers

Introduction Brian Mitchell ([email protected]) - Operating Systems 3 Introduction

• Homework’s, Projects, Exams Programming Projects: This course will include a significant project that can be worked on individually or in teams. Specifications for the project are on the course web page.

Research Presentation: This course will require you review research papers related to operating systems, as well as present a paper that you select to the class.

Final: There will be a 90 minute final exam

Introduction Brian Mitchell ([email protected]) - Operating Systems 4 Course Topics

• Introduction • Processes & Threads • Process Synchronization • CPU • Memory Management • Virtual Memory • Deadlock • File and I/O Systems • Directory Services • Security and Protection • Case Studies • Special Purpose Operating Systems – Embedded – JavaOS – WebOS

Introduction Brian Mitchell ([email protected]) - Operating Systems 5 Project Introduction

• Learn about the internals of operating systems, operating system algorithms, and operating system and hardware integration. • Goal: Construct a simulated: – Hardware – Operating System – Assembler

User Programs

Operating System

Hardware

Introduction Brian Mitchell ([email protected]) - Operating Systems 6 Project Introduction

• Sample Programming Language – Simple, pseudo-assembler based – Instructions: • Nop, alm, frm, cmp, jeq, jgt, jlt, jge, jle, clr, inc, dec, add, sub, mul, div, mov, and, or, not, xor, hlt, dis

Sample Program start: alm R1,d500 ;allocate 500 bytes mov R2,#0 ;R2 will hold our offset looptop: mov (R1)+R2,R2 ;update memory location ;with value inc R2 ;increment R2 cmp R2,d500 ;compare R2 to 500 jlt looptop ;if R2<500 go to looptop halt ;stop execution

Introduction Brian Mitchell ([email protected]) - Operating Systems 7 Project Introduction

• Processing the programs

FIRST INSTRUCTION

Get Instruction

Validate Instruction

Fetch and resolve arguments (if any)

Execute Instruction NEXT INSTRUCTION Check and Handle Faults (if any)

Log Instruction Results in the Hardware Trace

Introduction Brian Mitchell ([email protected]) - Operating Systems 8 Project Introduction

• OS Memory Manager – Linked Lists – First, best, next, worst fit allocation algorithm – Interface with the page table in hardware – Handle program and page faults – Provide interface to user programs who require memory – Interface with hardware to manage the memory

Introduction Brian Mitchell ([email protected]) - Operating Systems 9 Project Introduction

• Simulated hardware

General Purpose Registers R1 R2 R3 R4 R5 R6 R7 R8 PAGE TABLE Control Registers TLB*

C T PF PC CACHE*

Physical Memory SWAP Space

Introduction Brian Mitchell ([email protected]) - Operating Systems 10 Project Information

• Getting Started – Sample code and ant (www.apache.org) script is provided in the project page

Introduction Brian Mitchell ([email protected]) - Operating Systems 11 Introduction

• Grading – The following distribution will be used to determine your final grade in this course: • 20%: Phase 1 Project Deliverable • 10%: Phase 2 Project Deliverable • 30%: Phase 3 Project Deliverable • 20%: Research Paper Presentation • 20%: Final Exam • Policies – Policies governing the project are described on the project web page. – Makeup exams will take the form of an oral exam or an alternative test (in-class or take-home).

Introduction Brian Mitchell ([email protected]) - Operating Systems 12 Introduction

• Computer hardware requires software to perform useful operations • Types of software – Systems Programs: manage the operation of the computer itself – Application Programs: solve user problems • The Operating System (OS) is the most fundamental of all systems programs – OS controls ALL of the computers resources – OS provides VALUABLE services to user programs – OS COORDINATES the execution of user programs – OS PROVIDES resources to user programs

Introduction Brian Mitchell ([email protected]) - Operating Systems 13 Computer Systems Structure

• Modern computer systems consist of: – One or more processors – Main memory – Clocks (Synchronization, coordination) – Terminals – Disks – Network Interfaces – Input/Output Devices • Systems Architectures – SISD, SIMD, MIMD, MISD (we will look at these later) • Processor Organization – Single Processor – Multiprocessor – Symmetric Multiprocessor – Distributed – Clusters

Introduction Brian Mitchell ([email protected]) - Operating Systems 14 Rationale for OS

• Directly interfacing user programs with hardware is COMPLEX • Building programs for specific computer architectures is not portable • If every program included code to interface with the computer hardware – Redundancy – Inconsistent quality – Inefficient use of resources

• DESIRE => Shield programmers from the complexity of the hardware – OS is a layer that sits on top of the hardware – OS provides an interface or virtual machine that is easy to understand and program

Introduction Brian Mitchell ([email protected]) - Operating Systems 15 OS Architecture

• Most Operating Systems use a layered architecture

Banking Airline Word System Reservation Processor USER Command Compilers Editors Interpreter

Operating System SYSTEM

Machine Language

Microprogramming

Physical Devices HARDWARE

Introduction Brian Mitchell ([email protected]) - Operating Systems 16 OS Architecture (con’t)

• Physical Devices – Computer hardware - CPU, memory, I/O devices, network interfaces • Microprogramming – ROM-based programs – Controls CISC processors • Machine Language – Instructions supported by the hardware – Binary encoded – Processors typically support 50-300 instructions • CISC vs RISC – Use registers as the basis for performing most operations • Running programs • Device interfaces

Introduction Brian Mitchell ([email protected]) - Operating Systems 17 OS Architecture (con’t)

• Operating Systems – Hide the complexity of software • Read 200 bytes from file A versus managing the motor and arms of the disk drive – Provide an interface for the programmer • Usually documented as a set of API’s – ex: Win32 on Windows98 & WindowsNT – Win32 contains about 6,000 API’s – OpenFile(), CreateProcess(), ... – Systems software usually sits on top of the kernel of the OS • Command Interpreter, Security Manager, Utilities (e.g., awk, grep on Unix) – Most processors support multiple execution modes • Minimally Kernel/Supervisor and User modes

Introduction Brian Mitchell ([email protected]) - Operating Systems 18 OS Architecture (con’t)

• Operating system runs in Kernel mode and user programs run in User mode • Kernel Mode – Full access to machine instruction set – Direct access to hardware, memory, and input/output devices – OS and device drivers must run in Kernel mode • User Mode – Access to a limited set of machine instructions – No direct access to hardware, memory and input/output devices • Device access is coordinated by OS – Typically user mode instructions consist of computational instructions • MS DOS only supported Kernel mode

Introduction Brian Mitchell ([email protected]) - Operating Systems 19 OS Architecture - Summary

• Operating System acts as an extended machine from a user program perspective – Reduce complexity – Increase system integrity – Reduce redundancy

• Operating System acts as a resource manager – Hardware provides many resources to user programs – Demand for resources may exceed resource capacity – OS must optimally manage allocation of the resources • Ex: Memory, Processor/CPU time

Introduction Brian Mitchell ([email protected]) - Operating Systems 20 Example: Web Browser

WEB Browser http://www.mcs.drexel.edu

Socket API User Mode

Operating System Switch to TCP/IP Frames Kernel Mode Device Driver Memory-Mapped Kernel Mode

Network Interface Card (NIC)

Electrical Signals Network

Introduction Brian Mitchell ([email protected]) - Operating Systems 21 History of Operating Systems

• First Generation (1945-1955) – Hardware was tube-based – Programs were hardwired on plugboards – Hardware could run one program at a time – Applications: Numerical Calculations • Second Generation (1955-1965) – Transistor-based – Assembler - improvement over machine language – High Level Language - FORTRAN – Batch oriented • Jobs were created on card or tape • Jobs were serially executed – Scientific / Engineering applications – Early operating systems introduced • Capabilities limited to controlling the serial execution of batch jobs

Introduction Brian Mitchell ([email protected]) - Operating Systems 22 History of Operating Systems

• Third Generation (1965-1980) – IC circuits (LSI, VLSI chips) – Business applications supported in addition to scientific and engineering applications • Business Applications: IO-based • Engineering/Scientific Applications : CPU- based – OS supported several new capabilities • Multiprogramming – Load multiple jobs into memory – When one job was waiting for I/O the OS ran another job – Job spooling - queue of ready to run jobs reduced operator intervention • Timesharing – Support for multiple, concurrent users – OS timeslices user sessions – OS takes responsibility for maximizing CPU and device utilization

Introduction Brian Mitchell ([email protected]) - Operating Systems 23 History of Operating Systems

• Fourth Generation (1980 - ) – Workstations and PC’s – Computer networks become commonplace – CPU’s with millions of transistors offer high computational power – Desire: User friendly software Result: Complex operating systems – OS designed to scale and integrate well with new computer architectures • Real time / Embedded • SMP • CISC, RISC • Parallel • Network – OS address new concerns • Network transparency • Security

Introduction Brian Mitchell ([email protected]) - Operating Systems 24 History of Operating Systems

• Fifth Generation (2000? - ???? ) – OS designed to support massively parallel computer architectures • Thousands of CPU’s – MPP architectures may consist of thousands of independent computers connected by high-speed networks • ex: BISDN at 155Mbits/sec – MPP architectures may consist of processor boards “plugged” into custom design backplanes – One or multiple copies of the OS? – Issues • Cache coherence • Management and coordination of distributed resources • Bandwidth limitations • Keeping consistent time

Introduction Brian Mitchell ([email protected]) - Operating Systems 25 Special Operating System Types

• Distributed Systems – Goal is to distribute the computation across several physical processors – Can use either standard networks, or proprietary inter-connection technologies – Advantages: • Scalability at low cost • Reliability – Disadvantages: • Programming is complex • Overhead may be large • Real time systems – Typically used to control a device – Well defined time constraints must be respected – General purpose operating systems do not often handle the requirements of a real- time system

Introduction Brian Mitchell ([email protected]) - Operating Systems 26 Operating System Components

• Process Management – A process is a program in execution – OS manages the creation and deletion of processes • Main-Memory Management – OS keeps track of memory in use and free memory, who is using the memory, allocation and freeing of memory. • Secondary-Storage Management – OS uses secondary storage to extend physical memory – Secondary Storage typically resides on disk • I/O System Management – OS uses the I/O system for management of devices (device drivers) – Caching – Example: File System

Introduction Brian Mitchell ([email protected]) - Operating Systems 27 Operating System Components

• File Management – OS Manages the creation and deletion of files, and directories – OS also manages file system permissions • Who owns the file, who can modify the file • Protection System – Distinguish authorized versus non- authorized usage of OS resources • Networking – Enables OS users to utilize network resources • Remote disks, Internet, shared printers, file servers, email, … • Command-Interpreter System, Graphical User Interfaces – Provides the user with an interface for using the operating system facilities

Introduction Brian Mitchell ([email protected]) - Operating Systems 28 Operating System Interfaces

• Operating Systems typically provide two interfaces: – User interfaces: Command Line Interpreter, or graphical user interface – Program interfaces: OS provide interfaces via application programming interfaces to programs. • Sometimes called system calls • System Calls – Operating system designers typically package system calls as C language function calls • Example: Win32 on Windows 95/98/NT – Most operating systems also provide additional classes for better integration with object oriented languages such as C++ • Example: MFC on Windows 95/98/NT

Introduction Brian Mitchell ([email protected]) - Operating Systems 29 Virtual Machines

• A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware. • A virtual machine provides an interface identical to the underlying bare hardware. • The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory. • Some operating systems (e.g., VM by IBM), work by running all processes in a virtual machine • VM concepts are most widely applied in interpretive languages (e.g., Java) – Interface to the machine is facilitated by the virtual machine

Introduction Brian Mitchell ([email protected]) - Operating Systems 30