CMSC 421: Principles of Operating Systems
Fall 2019Jason Tang
�1
About Your Friendly Instructor
• Jason Tang (just call me Jason!)
• UMBC adjunct faculty member since 2012
• Taught CS 104, 202, 411, and 421
• Work full-time at a nearby mega-corporation as a software engineer
�2
Contact Information
• Email me at [email protected]
• Office in ITE 349
• Tuesday / Thursday, 7:00 pm - 8:00 pm, right after class
• Teaching Assistant:
• Vaishnavi Jamdade, [email protected]
�3
Am I in the Right Class?
• Prerequisites are:
• CMSC 341, and
• either CMSC 313, or (CMPE 212 + CMPE 310)
• Must be able to read hexadecimal notation
• Must already by familiar with the C language, and somewhat familiar with programming in Unix
• This does not mean Java, C++, or other languages
�4
Required C Knowledge
• Know how to write (or how to research on Stack Overflow) these things:
• Know how to read the man pages
• Open a file for reading and writing
• Use pointers to dynamically manage memory, with malloc() and free()
• Understand C-style strings, such as the difference memcpy() between strcpy()
�5
Topics Covered
• Interprocess communication (IPC)
• Process management and scheduling
• Multi-threaded programming and synchronization
• Memory management and virtual memory
• Hardware interrupt handling
• Filesystems
• Special topics
�6
Course Information
• http://www.csee.umbc.edu/~jtang/cs421.f19
• Grades will be posted on Blackboard
• Discussion forums are also on Blackboard
• All assignments submitted via submit system at linux.gl.umbc.edu
• Ensure you have a way to transfer files between your development machine and UMBC server (scp, PuTTy, Cyberduck, or equivalent)
• Using the clipboard to transfer data will not work
�7
Textbook
• Required: Operating System Concepts, Ninth Edition
• Recommended references:
• Advanced Programming in the Unix Environment
• The Linux Programming Interface
• Linux Kernel Development
�8
What Grade Can I Expect?
�9
CMSC 421 Historical Grade Distribution
F7%D
7%
C36% B
29%
A22%
ABCDF
Grading Criteria
�10
Homework 28% (4 each at 7%)
Project 22% (2 each at 11%)
Midterm 30% (2 each at 15%)
Final 20%
Homework and Project Assignments
• All assignments are individual efforts
• Due at 11:59:59 pm
• Assignment submission is disabled automatically at ten seconds past midnight
• This is strictly enforced by the submit system
• Neatness counts! Code must be properly indented, functions documented, good variable names chosen. All grading criteria include a “style” portion. You will lose points for sloppiness.
�11
Late Policy
• Once per semester, you may submit an assignment late by emailing the required files directly to the instructor (not the TA)
• You will receive an automatic 20% late penalty deduction
• This late submission must be received within 8 hours following the deadline
• Subsequent late submissions will be rejected by both the instructor and the TA
�12
Exams
• Midterm 1 is Tuesday, October 1, at normal lecture time
• Midterm 2 is Thursday, October 31, at normal lecture time
• Final is Thursday, December 12, starting at 6:00 pm
• No calculators, laptops, mobile phones, tablets, phablets, smart watches, AR glasses, …
• You will be provided a reference sheet for each exam
• This reference sheet also will be posted on Blackboard a few days before each exam
• You may bring a cheat sheet
• Study guides, with sample exam questions, are on the class website
�13
Academic Integrity
• You may get help from friends, family, neighbors, Blackboard discussions, Wikipedia, Google, etc., as long as:
• You (and only you) end up doing the typing
• You document all outside help at the top of your submission
• You do not claim credit for someone else’s work
• You may consult with the instructor, TA, and other students about the assignments
�14
Class Lab
• You have the option of gaining access to the ITE 240 lab to work on the assignments
• You can gain root-level access on lab computers for kernel development
• Visit the Computer Science office, ITE 325, to request lab access
�15
Initial Survey
• On Blackboard, go to Course Documents and take survey
• Survey is ungraded and anonymous
• Vote for contents of final two lectures
• Vote for theme of final project
• Survey closes at 11:59:59 PM on Saturday, September 7
�16
Homework 1
• HW1 has been posted to the course website, and is due on Thursday, September 12
• Introduces VirtualBox, installing and running Linux
• Make a simple modification to the Linux kernel code
• Write a C program to perform some file I/O
• Will take several hours (much of it unattended)
�17
Lecture 1: Introduction
Fall 2019Jason Tang
�18
Slides based upon Operating System Concept slides, http://codex.cs.yale.edu/avi/os-book/OS9/slide-dir/index.html Copyright Silberschatz, Galvin, and Gagne, 2013
Topics
• Organization of computer systems
• Major components of an operating systems
• Interrupt handling
�19
What is an Operating System?
• Program that acts as an intermediary between users and computer hardware:
• Execute user programs
• Efficiently use computer hardware
• [Usually] Make computer system easier to use
�20
Computer System Structure
• Hardware
• CPU, memory, I/O
• Operating System
• Controls and coordinates hardware among applications and users
• Applications
• Editors, web browsers, video games
• Users
• Humans, other computers on a network
�21
Computer System Structure
�22
User 1
User 2
User 3
Remote Server...
Spotify Chrome Steam BitTorrentApplications
Windows / macOS / Linux / FreeBSDOperating
System
Intel Xeon “Cannon Lake”, 64 GiB DDR4, AMD Radeon “Vega”
Computer Hardware
What Operating Systems Do
• Usually, users want convenience, ease of use, and performance
• Usually do not care about resource utilization
• Depends upon environment:
• Server, desktop, laptop, handheld, embedded, industrial, …
• Needs to balance user expectations with requirements:
• Number of users, power consumption, heat, radiation, ...
�23
Definitions
• OS is a resource allocator
• Manages all resources
• Handles conflicting requests “efficiently” and “fairly”
• OS is a control program
• Controls program execution to prevent errors and “improper use”
• Kernel is the one program that is always running
• Everything else is a system program or an application
�24
Boot Sequence
• At power-up or reboot, the CPU will start running the bootstrap
• Burned into ROM, EEPROM, or read from flash memory
• Begins initializing system
• [Optional] bootstrap then loads and runs a bootloader
• Bootloader has operating-system like behaviors, though simplified
• Bootstrap / bootloader finds, loads, and starts executing kernel
• Example: UEFI launches GRUB, which then runs the Linux kernel
�25
Computer System Organization
• One or more CPUs, device controllers, etc., connected to bus (or busses) providing access to shared memory (or memories)
�26
Computer System Operation
• CPUs and devices execute concurrently
• Each device controller is in charge of a particular device type
• Examples: PCI Express, Serial ATA, InfiniBand, Thunderbolt
• Most devices have their own local memory buffer (device memory)
• CPU moves data from/to main memory to/from device memory
• I/O is from device to controller’s memory buffer
• Device controller informs CPU that it has finished its operation by raising an interrupt
�27
Interrupt Overview
• CPU stores address of the instruction being interrupted
• CPU transfers control to the interrupt service routine (ISR), through the interrupt vector table
• Software-generated interrupt is called a trap or an exception (depends upon nomenclature)
• Modern operating systems are interrupt driven
�28
Interrupt Handling
• Prior to jumping to interrupt table, the operating system preserves state of the CPU:
• Stores registers, program counter, other control values
• OS then determines what interrupt occurred and how to handle it
• polling - OS queries all devices to find which one raised interrupt
• vectored interrupt - When interrupt was raised, the device wrote an interrupt number (or some other identifier) that the CPU can access
�29
I/O Handling
• OS sends command to device hardware (e.g., “Read 128 bytes from address 0x100”)
• Control returns to user program while I/O is being processed
• Device will raise an interrupt when operation has completed
• User program can either wait for completion (blocking or synchronous I/O), or do other work and be notified by the OS (non-blocking or asynchronous I/O)
�30
Interrupt Timeline
�31
CPU User ProcessISR
I/O DeviceTransferring
timeUser Processissues asynchronous
I/O request
Transfercompletes
Idle
Idle
User Processissues synchronous
I/O request
Transfercompletes
Top Related