cs 326 operating systems introduction
TRANSCRIPT
CS 326Operating Systems
IntroductionGreg Benson
Department of Computer ScienceUniversity of San Francisco
Today’s Topics
• Course overview and logistics
• What is an operating system?
• A brief history of operating systems
• Some OS concepts
• Roadmap for this semester
2
Brief summary of OS
• Operating systems are everywhere and essential to everything we do on computers
• We will learn how operating systems are designed and implemented
• We will learn by coding large parts of a real operating system
3
Course Information
• Lecture in Kudlick classroom
• Tue and Thu 1:30pm to 3:15pm
• Lab section in PC Lab (Harney 535)
• Thu 3:15pm to 5:00pm
• Midterm: TBA
• Final: Wed 12/14 12:00pm
4
Course Resources
• Class website
• http://www.cs.usfca.edu/benson/cs326
• Class mailing list:
• Subscribe to mailing list at:
• https://cs.usfca.edu/mailman/listinfo/cs326
5
Prerequisites
• Desire to learn something complicated
• Assembly Language (CS 210)
• Binary and hexadecimal representation
• Addresses, stacks, interrupts
• Data Structures and Algorithms (CS 245)
• Linked Lists, queues, trees, hash tables
• Good C programming skills
• Most operating systems are written in C
6
Operating Systems ConceptsSeventh Editionby Silberschatz, Galvin, and Gagne
John Wiley & SonsISBN: 0471694665
A comprehensive book, we will read a large portion
Books: Main Text
7
Programming in Cby Kochan
SamsISBN: 0672326663
Good treatment of pointersGood language and library reference
Books: C Reference
8
Books: Optional
9
Advanced Programming in the UNIX Environmentby Stevens and Rago
The C Programming Languageby Kernighan and Ritchie
Development Platform
• Linux
• C compiler (gcc)
• Debugger (gdb)
• x86 emulators and virtual machines
• VMware, QEMU, Bochs
• Source code control (subversion)
10
Assignments and Exams
• Projects (5 total)
• Programming problems
• Design document and results
• Interactive grading
• Code qaulity
• Midterm, Final (comprehensive)
11
Grading
12
Breakdown
PolicyAbsolute Scale
Midterm 1 20%
Final 30%
Projects 50%
A- 90%
B- 80%
C- 70%
D- 60%
Course Policies
• Due dates and lateness
• Late assignments will NOT be accepted
• Turn in what you have for partial credit
• Disputes only considered within 1 week of returned work
• Missed exams: call or email me ahead
• Class and lab attendance
• Not required, but ...
13
Cheating and Plagiarism
• Just don’t do it -- work hard and you can do well
• What is cheating?
• Copying source code or parts of code
• Having someone tell you how to solve a problem
• Telling someone how to solve a problem
• What is acceptable discussion?
• Discussing existing or given code
• Discussing the project requirements
• Discussing techniques given in class and lab
• Consequences - you will get an F in the class
14
How to do well
• Have fun!• Read the book and given code• Keep up: start the projects early• Learn by doing• Come to lecture and labs• Come to office hours• Post to class mailing list• Ask lots of questions!!!
15
What you get
• A deep understanding of how an OS works
• How the OS kernel manages hardware
• Relationship between applications and the OS
• Kernel hacking experience (can apply to Linux, BSD, Mac OS X, Windows)
• UNIX systems programming
• How to deal with concurrency
• Needed in many apps: databases, games, servers
• Debugging skills
16
Lecture/Lab Format
• Lecture (roughly)• 50 mins lecture• 10 mins break• 45 mins lecture
• Lab• Special coverage• Help with projects• Interactive grading
17
What is an Operating System?
• The OS is software that sits between applications and the hardware
18
Firefox
Operating System
CPU Memory Network Disk
Vi Half-Life
Why is an OS so special?
• Most people take the OS for granted
• Not many people really understand how it work (e.g. running programs, files)
• Except USF CS students!
• Operating systems are very complicated
• Is there a bug-free OS?
• Windows, Linux, Others
19
Dealing with OS complexity
• Abstraction
• It’s needed everywhere in CS
• Modularity
• Keep common functionality together
• Iterative design
• OSes do pretty well given the complexity
20
Some OS Tricks
• Program loading and linking
• E.g. clicking on Firefox, the OS does:
• Transfers executable from disk to memory
• Links the executable with required libraries
• Some libraries may be in memory, some on disk
• Running two or more programs at the same time
• Many computers have only one processor
• Multiple programs can run simultaneously
• The OS must switch between programs allowing each to make progress
21
More OS Magic
• Programs expect a large, uniform address space
• Perhaps need more memory than physical memory
• Disk space is used to augment physical memory
• If the OS is smart, only infrequently used data will be pushed to disk
• Storing information
• Files must be saved to or retrieved from a disk
• Must be able to easily locate files (hierarchy and search)
• Must be able to reuse freed disk space
• Files must be exact
• All of these operations must be fast
22
Conflicting Goals
• Protection
• Programs should not interfere with each other
• Programs cannot touch each other’s memory
• One program cannot prevent another from running
• Some files should not be accessible by others
• Sharing
• Programs need to share resource (e.g. network, disk, display)
• We want some files to be shared
• All users can run the same “ls” program
• Need shared read access to /etc/passwd, libraries
23
What is an OS? Definition
• An extended machine or virtual machine
• Programs utilize OS services through system calls
• A resource manager
• The OS manages: CPU cycles, memory, disks, network cards, etc.
• The OS provides multiprogramming: multiple programs executing simultaneously on the same machine
• In general, an OS is the software that bridges the gap between the hardware and application programs
24
A very brief history of OSes
• No OS
• The OS as a library
• The OS as a job controller (one at a time)
• Multiprogramming
• Multiuser
• Multiprocessor
• Distributed
• Others: embedded, real-time, secure
• See book
25
The Process
• A central concept in operating systems
• A process is a program in execution
• A process has an address space (0 to N)
• code, data, stack
• Processes
• execute independently
• are protected from each other
• can start other processes
• can terminate
26
The OS as a process manager
• The OS provides support for the process model
• System calls for process creation
• System call for communication
• The OS protects processes
• The OS schedules processes
• How and when to switch from one process to another
27
Components of an OS
• The kernel
• Code that resides in main memory
• Controls the machine resources
• Provides the system call interface
• Executes with special privileges
• User-level code
• Outside the kernel all programs run in user-mode
• Has limited access to CPU and hardware
• Accesses the kernel via system calls
28
Types of user-level processes
• System software
• Used to support the execution of applications
• E.g., libraries, compilers, linkers, servers, etc
• Applications
• End user programs
• E.g., word processors and web browsers
• Some system programs may also be application programs (e.g. the shell)
29
Role of Hardware
• CPU protection: preemption
• The kernel needs a way to interrupt a running process
• The hardware clock interrupts the CPU and transfers control to the kernel
• The kernel can determine if the current process should stop
30
Role of Hardware Continued
• Memory protection: virtual memory
• Modern CPUs support virtual addressing
• A process generates a virtual address for every memory access
• The OS translates the virtual address into a physical address
• CPU keeps track of recent translations
31
OS Design Goals
• Efficiency
• Fast operations, don’t want to get in the way of application
• Fairness
• Give each application equal access to resources (not always though)
• Reliability
• Don’t fail or handle failures gracefully
• Security
• Don’t protect data and resources from unauthorized users
32
Current OS Characteristics
• Huge: Millions of lines of code
• Complex:
• Asynchronous
• Hardware idiosyncrasies
• Conflicting user needs
• Performance is crucial
• Pooly understood:
• The system outlives its builders
• Never fully debugged
• Behavior is hard to predict
• Often unreliable
33
Why Study OS?
• Internet still driver many software technologies included OS research
• Linux and other open source OSes gaining ground
• Linux accepted and promoted by Sun, IBM, and the US Government
• Linux runs on almost everything
• Apple uses BSD as basis for Mac OS X
• Windows?
34
More Details on Projects
• We will be using C exclusively
• First project will be C systems programming on Linux
• Remaining projects will be to develop Pintos (more later)
35
Roadmap
• C programming and UNIX system calls
• Processes and Threads
• System call implementation
• Virtual memory
• File systems
36
Reading Assignment
• Silberschatz: Chapter 1
• Kochan: Chapters 7, 8, and 9 (as needed)
37