360 likes | 565 Views
CMPT 300 Day: Operating System. Instructor: Senqiang Zhou TA: Rong Ge {szhoua, rge}@cs.sfu.ca. What Is This Course About?. Office Hours & Places. Instructor: Time: Mon. 14:30-15:30 Wed 11:00-12:00 Place: ASB 9911 TA: Time: Tue. 10:00-12:00 Fri. 14:00-15:00
E N D
CMPT 300 Day: Operating System Instructor: Senqiang Zhou TA: Rong Ge {szhoua, rge}@cs.sfu.ca
Office Hours & Places • Instructor: • Time: Mon. 14:30-15:30 Wed 11:00-12:00 • Place: ASB 9911 • TA: • Time: Tue. 10:00-12:00 Fri. 14:00-15:00 • Place: MTF109 North - CSIL Linux Study Area • E-MAIL List: cmpt-300-d1@sfu.ca • ACS SFU account desk at Strand Hall • Course web-page: • http://www.cs.sfu.ca/CC/300/szhoua/
Grading • Four assignments count for 20%. • One term project counts for 15%. • One 1-hour mid-term exam counts for 20%. • Covers Ch 1 to Ch 3 . • One 3-hour final exam counts for 45%. • Covers Ch1 to Ch 6.
Pre-requisites • C/C++: • Necessary for term project • Necessary to understand the codes in textbook • Basic hardware knowledge: • CPU, memory, bus, hard disk, I/O devices • Basic data structures: • Queue, stack, etc.
Chapter 1 Introduction
Outline • Definitions of operating system • History of operating systems • Categories of operating systems • Computer hardware review • Operating system concepts • System calls
Why Do We Need OS? • Many resources • Hardware: processors, memory, disks, printers, keyboard, monitors, network interfaces, … • Software: compilers, office tools, browsers, games, … • Many tasks • Programming, surfing web, handling emails, solving equations, playing music, … • Many users • Share the resources: fairness Vs. Efficiency
A Computer Without OS Consider a daily task: read data from diskette • Basic commands: 13 parameters • Disk address, #blocks to read, #blocks per track…. • Controller chips • 23 status and error field • Do you want to program the hardware directly? • A simpler interface is needed!
The Benefits of OS • Hide the tedious details • They are out of the user’s interest • E.g., to access data, only need to specify the file name. • Provide a variety of services: system calls • A set of procedures • an be called by programs using special instructions. • A simple interface • Present key features to programmer • Meet requirements from many programs
OS As A Virtual Machine • Virtual machine/extended machine • Hide the underlying hardware • Access hardware through a set of system calls • Trade-off • Higher efficiency in program development and system management • More important with complex software • Less efficiency in program execution • Less important with faster machine
OS As A Resource Manager • Multiplexing (sharing) resources • In time • Users/programs take turns using resources • CPU, printers, etc. • In space • Users/programs get parts of resources • Main memory, disk, etc. • Protecting resources • E.g., user’s memory space • Issues about a good manager • Fairness, efficiency, safety, …
What Is An Operating System? Provide user programs with a simpler interface Manage resources
Outline • What is an operating system? • History of operating systems • Categories of operating systems • Computer hardware review • Operating system concepts • System calls
History of Operating Systems • OS and architecture of computers • Computer evolves so does OS • To provide better service OS has impact on computer design • Keep evolving through years (1944-) • Four generations so far during 60 years • Speed, volume, storage, interface… • Most important: price keeps dropping • How many generations for car industry?
The First Generation Computer • Vacuum tubes and plug-boards • 1944-1955 • Huge volumes, slow speed, low stability, expensive! • Applications: • Straightforward numerical calculations • Absolutely no game! • Scenario • Single group of people designed, built, programmed, operated and maintained a machine • All in absolute machine language: no assembly language • No operating system • People did all the tasks.
The Second Generation OS • Transistors and batch systems • 1955-1965 • Applications • Scientific and engineering calculation • Programming Language: FORTRAN IBM 1401 IBM 7094 IBM 1401 Do computing Print out Read batch of jobs onto tape Cards from programmers Input tape Output tape
Ancestor of Today’s OS • Batch system • Read a job from tape run the job write output onto a output tape • Load next job • A typical input job: series of commands • $JOB$FORTRAN$LOAD$RUN • Examples: • FMS, IBSYS
The Third Generation OS • Features: ICs and multiprogramming • 1965-1980 • Applications • Numerical calculations in science & engineering • Word-oriented, large-scale scientific computers • Massive commercial data processing • Character-oriented, commercial computers
Key Advances in 3rd Gen OS • Multiprogramming • Run job 2 while job 1 waiting for I/O • Keep CPU busy • Spooling • Read jobs from cards to disk asap • Load new jobs from disk whenever old job done • Time sharing • CPU is allocated in turn • Different from multiprogramming Memory partitions
Milestones • IBM OS/360 • M.I.T. CTSS • M.I.T. MULTICS • Ken Thompson UNIX • AT&T UNIX System V • UC Berkeley UNIX BSD • IEEE POSIX • Andrew S. Tanenbaum MINIX • Linus Torvalds Linux
The Fourth Generation OS • Personal computers • 1980-now • VLSI circuits • Cheap: an individual has her own computer • Milestones • Kildall CP/M for Intel 8080, Z80 • MS-DOS/BASIC for IBM PC • Engelbart GUI • MS Windows, Windows NT • UNIX X Windows • Network & distributed operating systems
Outline • What is an operating system? • History of operating systems • Categories of operating systems • Computer hardware review • Operating system concepts • System calls
Categories of OS • Mainframe operating systems • Server operating systems • Multiprocessor operating systems • Personal computer operating systems • Real-time operating systems • Embedded operating systems • Smart card operating systems
Mainframe Operating Systems • Characters of mainframe computers • Strong I/O capability, e.g., 1000 disks, TB space • High-end servers: web server, B2B server • Features of OS • Batch (background) • Transaction processing (interactive) • Timesharing • Example: IBM OS/390
Server Operating Systems • Hardware platforms • Very large personal computers or workstations • Services • Printing • File accessing • Web • Examples • UNIX, Windows 2000, Linux
Multiprocessor Operating Systems • Multiple CPUs within a single system • Parallel computers: • Local memory, connected via WAN, loosely coupled • Multi-computers: • Local memory, connected via LAN, tightly coupled • Multiprocessors: • share memory, connected via BUS • Features of OS • Variations of the server operating systems • Special features for communication and connectivity between CPUs
Personal Computer OS • User friendly interface • Easy to manipulate • Abundant application software: word processing, spreadsheets, internet access, game… • Examples • Windows 98, Windows 2000 • Macintosh operating system • Linux
Outline • What is an operating system? • History of operating systems • Categories of operating systems • Computer hardware review • Operating system concepts • System calls
Floppy disk driver Hard disk driver Monitor Keyboard Floppy disk controller Video controller Keyboard controller Hard disk controller CPU Memory Components of A Computer • System bus: connect all components Bus I/O Devices
CPU (Processor) • Basic model • Fetching instruction decoding executing • Different CPUs have different instruction sets. • Registers • Program counter: pointer to next instruction • PSW: program status word • Condition code bit, the mode (kernel or user), etc. • Stack pointer: point to the top of current stack • General registers: hold temporary results
Working Modes • Two modes in CPU • Kernel mode: full capability • User mode: I/O, memory protection instructions are disallowed. • System calls: get OS service for user program, switch to kernel mode by TRAP instruction. User Program User Program OS System Call Service Done User mode Kernel mode User mode
Memory Hierarchy Reason: Trade off between speed and Cost RAM
Memory Management • Hold multiple programs in main memory • Improve CPU utilization. Why? • Problems • Protection • Program A is not allowed to fetch data within program B • Protect kernel from users’ programs • Relocation • Each program starts from logical address 0 • How to load and allocate them into main memory?
Base/Limit Registers 0xFFFFFFF • Base register • Point to the start of a program • Its content is added to every program address • Limit register • Record the size of program + data • Limit of addresses • Virtual address physical address • Base = 4096, limit = 6114 • Virtual addr = 2000 physical addr = 2000+4096=6096 < limit, legal! • MMU: memory management unit Limit Base 0
Split Program and Data Registers when running program 2 • Why: multiple users may run a same program • How: base/limit registers for program and data, respectively • Overhead of switching: context switch Registers when running program 1 Limit-2 Base-2 Limit-2 Base-2 Limit-1 Limit-1 Base-1 Base-1