cmsc 421: principles of operating systems

31
CMSC 421: Principles of Operating Systems Fall 2019 Jason Tang 1

Upload: others

Post on 02-Apr-2022

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CMSC 421: Principles of Operating Systems

CMSC 421: Principles of Operating Systems

Fall 2019Jason Tang

�1

Page 2: CMSC 421: Principles of Operating Systems

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

Page 3: CMSC 421: Principles of Operating Systems

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

Page 4: CMSC 421: Principles of Operating Systems

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

Page 5: CMSC 421: Principles of Operating Systems

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

Page 6: CMSC 421: Principles of Operating Systems

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

Page 7: CMSC 421: Principles of Operating Systems

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

Page 8: CMSC 421: Principles of Operating Systems

Textbook

• Required: Operating System Concepts, Ninth Edition

• Recommended references:

• Advanced Programming in the Unix Environment

• The Linux Programming Interface

• Linux Kernel Development

�8

Page 9: CMSC 421: Principles of Operating Systems

What Grade Can I Expect?

�9

CMSC 421 Historical Grade Distribution

F7%D

7%

C36% B

29%

A22%

ABCDF

Page 10: CMSC 421: Principles of Operating Systems

Grading Criteria

�10

Homework 28% (4 each at 7%)

Project 22% (2 each at 11%)

Midterm 30% (2 each at 15%)

Final 20%

Page 11: CMSC 421: Principles of Operating Systems

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

Page 12: CMSC 421: Principles of Operating Systems

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

Page 13: CMSC 421: Principles of Operating Systems

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

Page 14: CMSC 421: Principles of Operating Systems

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

Page 15: CMSC 421: Principles of Operating Systems

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

Page 16: CMSC 421: Principles of Operating Systems

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

Page 17: CMSC 421: Principles of Operating Systems

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

Page 18: CMSC 421: Principles of Operating Systems

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

Page 19: CMSC 421: Principles of Operating Systems

Topics

• Organization of computer systems

• Major components of an operating systems

• Interrupt handling

�19

Page 20: CMSC 421: Principles of Operating Systems

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

Page 21: CMSC 421: Principles of Operating Systems

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

Page 22: CMSC 421: Principles of Operating Systems

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

Page 23: CMSC 421: Principles of Operating Systems

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

Page 24: CMSC 421: Principles of Operating Systems

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

Page 25: CMSC 421: Principles of Operating Systems

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

Page 26: CMSC 421: Principles of Operating Systems

Computer System Organization

• One or more CPUs, device controllers, etc., connected to bus (or busses) providing access to shared memory (or memories)

�26

Page 27: CMSC 421: Principles of Operating Systems

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

Page 28: CMSC 421: Principles of Operating Systems

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

Page 29: CMSC 421: Principles of Operating Systems

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

Page 30: CMSC 421: Principles of Operating Systems

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

Page 31: CMSC 421: Principles of Operating Systems

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