CS 111 Spring 2022
Lecture 1 Page 1
Introduction
Spring 2022 Operating System Principles
Copyright By PowCoder代写 加微信 powcoder
Outline • Administrative materials
• Introduction to the course
– Why study operating systems? – Basics of operating systems
CS 111 Spring 2022
Lecture 1 Page 2
Administrative Issues
• Instructor and TAs
• Load and prerequisites
• Web site, syllabus, reading, and lectures
• Exams, homework, projects
• Academic honesty
CS 111 Spring 2022
Lecture 1 Page 3
Instructor:
• UCLA Computer Science department faculty member
• Long history of research in operating systems
• Office: No in person office hours this quarter – Office hours: TTh 10-11, via Zoom
• Zoom ID for office hours to be announced later – Often available at other times
CS 111 Spring 2022
Lecture 1 Page 4
• , section 1A
• Rustem Can Aygun, section 1B
• Bachupally, section 1C
• Office hours to be announced
–Also via Zoom
CS 111 Spring 2022
Lecture 1 Page 5
Instructor/TA Division of Responsibilities
• Instructor handles all lectures, readings, and tests
– Ask me about issues related to these
• TAs handle projects
– Ask them about issues related to these
• Generally, instructor won’t be involved with
project issues
– So direct those questions to the TAs
CS 111 Spring 2022
Lecture 1 Page 6
• We’ll primarily use a web site set up for this class
– https://bruinlearn.ucla.edu/courses/129698
– Schedules for reading, lectures, exams, projects
– Project materials
• And uploads of completed projects
– Copies of lecture slides
– Also Zoom IDs for lectures and taped lectures
– Announcements
– Sample midterm and final problems Spring 2022
Lecture 1 Page 7
Prerequisite Subject Knowledge
• CS32programming
– Objects, data structures, queues, stacks, tables, trees
• CS33systemsprogramming
– Assembly language, registers, memory
– Linkage conventions, stack frames, register saving
• CS35LSoftwareConstructionLaboratory – Useful software tools for systems programming
• If you haven’t taken these classes, expect to have a hard time in 111
CS 111 Spring 2022
Lecture 1 Page 8
Course Format
• Twoweeklyreadingassignments
– Mostly from the primary text
– Some supplementary materials available on web
• Twoweeklylectures
• Four(10-25hour)individualprojects – Exploring and exploiting OS features
– Plus one warm-up project
• Amidtermandafinalexam
CS 111 Spring 2022
Lecture 1 Page 9
Course Load
• Reputation: THE hardest undergrad CS class
– Fast pace through much non-trivial material • Expectations you should have
– lectures
– projects
– exam study
4-6 hours/week 3-6 hours/week 3-20 hours/week 5-15 hours (twice)
• Keeping up (week by week) is critical – Catching up is extremely difficult
CS 111 Spring 2022
Lecture 1 Page 10
Primary Text for Course
• RemziandAndreaArpaci-Dusseau:Operating Systems: Three Easy Pieces
– Freely available on line at http://pages.cs.wisc.edu/~remzi/OSTEP/
• Supplementedwithweb-basedmaterials
CS 111 Spring 2022
Lecture 1 Page 11
Course Grading
• Basis for grading: – Class evaluation
– 1 midterm exam – Final exam
– Other labs
1% 20% 26%
• I do look at distribution for final grades – But don’t use a formal curve
• All scores available on MyUCLA – Please check them for accuracy
CS 111 Spring 2022
Lecture 1 Page 12
Midterm Examination
• When:5thweek(Thursday,April28)
– Replacing that day’s lecture
– You can take it online during any two hour period that day
• Scope:Allmaterialuptotheexamdate – Approximately 60% lecture, 40% text
– No questions on purely project materials
– On line, multiple choice, open book/notes
– Test understanding of key concepts
– Test ability to apply principles to practical problems
CS 111 Spring 2022
Lecture 1 Page 13
Final Exam • When:Thursday,June9
– You can take it online during any 3 hour period that day
• Scope:Entirecourse
– On line, multiple choice, open book/notes
– Determining if you have mastered the full range of material presented in the class
CS 111 Spring 2022
Lecture 1 Page 14
Lab Projects • Format:
– 1 warm-up project
– 4 regular projects
– Done individually (except project 3)
– Develop ability to exploit OS features
– Develop programming/problem solving ability – Practice software project skills
CS 111 Spring 2022
Lecture 1 Page 15
Late Assignments & Make-ups
– Due dates set by TAs
– NOTE: They may change from the dates listed on the syllabus
– TAs also sets policy on late assignments
– The TAs will handle all issues related to labs • Ask them, not me
• Don’t expect me to overrule their decisions
– Alternate times or make-ups only possible with prior
consent of the instructor
CS 111 – If you miss a test, too bad Spring 2022
Lecture 1 Page 16
Academic Honesty
• ItisOKtostudywithfriends
– Discussing problems helps you to understand them
• ItisOKtodoindependentresearchonasubject
– There are many excellent treatments out there
• Butallworkyousubmitmustbeyourown – Do not write your lab answers with a friend
– Do not copy another student’s work
– Do not turn in solutions from off the web
– If you do research on a problem, cite your sources
• Idecidewhentwoassignmentsaretoosimilar
– And I forward them immediately to the Dean
• Ifyouneedhelp,asktheinstructor CS 111
Spring 2022
Lecture 1 Page 17
Academic Honesty – Projects • Doyourownprojects
– If you need additional help, ask the TA
• Youmustdesignandwriteallyourowncode
– Do not ask others how they solved the problem
– Do not copy solutions from the web, files or listings – Cite any research sources you use
• Protectyourself
– Do not show other people your solutions – Be careful with old listings
CS 111 Spring 2022
Lecture 1 Page 18
Academic Honesty and the Internet
• Youmightbeabletofindexistinganswerstosomeof the assignments on line
• Remember,ifyoucanfindit,socanwe – And we have, before
• ItISNOTOKtocopytheanswersfromother people’s old assignments
– People who tried that have been caught and referred to the Office of the Dean of Students
• ANYTHINGyougetofftheInternetmustbetreated as reference material
– If you use it, quote it and reference it
CS 111 Spring 2022
Lecture 1 Page 19
Academic Honesty – Tests
• It shouldn’t be necessary to say this, but . . .
• The rules for the tests will be stated before the test
• You must take the test yourself
• You must follow general UCLA academic
honesty principles
CS 111 Spring 2022
Lecture 1 Page 20
Introduction to the Course
• Purpose of course and relationships to other courses
• Why study operating systems? • What is an operating system?
CS 111 Spring 2022
Lecture 1 Page 21
What Will CS 111 Do? • Buildonconceptsfromothercourses
– Data structures, programming languages, assembly language programming, computer architectures, …
• Prepareyouforadvancedcourses
– Data bases, data mining, and distributed computing – Security, fault-tolerance, high availability
– Network protocols, computer system modelling
• Provideyouwithfoundationconcepts
– Processes, threads, virtual address space, files – Capabilities, synchronization, leases, deadlock
CS 111 Spring 2022
Lecture 1 Page 22
Why Study Operating Systems?
• Why do we have them, in the first place? • Why are they important?
• What do they do for us?
CS 111 Spring 2022
Lecture 1 Page 23
Starting From the Bottom
you’ve you got want
Here’s what what
CS 111 Spring 2022
Lecture 1 Page 24
What Can You Do With What
You’ve Got?
Read or write some binary words
Report X and Y
MOV ADD JMP SQRTPD
REQUEST SENSE
Write to groups of pixels
CS 111 Spring 2022
Lecture 1 Page 25
Read or write a block of data
CS 111 Spring 2022
Lecture 1 Page 26
And You Want This?
You’re Going to Need Some Help • And that’s what the operating system is about
• Helping you perform complex operations – That interact
– Using various hardware
– And probably various bits of software
• While hiding the complexity
• And making sure nothing gets in the way of
anything else
CS 111 Spring 2022
Lecture 1 Page 27
What Is An Operating System, Anyway?
• Systemsoftwareintendedtoprovidesupportfor higher level applications
– Some higher level system software applications – But primarily for user processes
• Thesoftwarethatsitsbetweenthehardwareand everything else
• Thesoftwarethathidesnastydetails
– Of hardware, software, and common tasks
• Onagoodday,theOSisyourbestcomputingfriend
CS 111 Spring 2022
Lecture 1 Page 28
But Why Are You Studying Them?
• High probability none of you will ever write an operating system
– Or even fix an operating system bug
• Not very many different operating systems are in use
– So the number of developers for them is small • So why should you care about them?
CS 111 Spring 2022
Lecture 1 Page 29
Everybody Has One
• Practically all computing devices you will ever use has an operating system
– Servers, laptops, desktop machines, tablets, smart phones, game consoles, set-top boxes
• Many things you don’t think of as computers have CPUs inside
– Usually with an operating system – Internet of Things devices
• So you will work with operating systems
CS 111 Spring 2022
Lecture 1 Page 30
How Do You Work With OSes? • You configure them
• You use their features when you write programs
• You rely on services that they offer – Memory management
– Persistent storage
– Scheduling and synchronization
– Interprocess communications
– Security
CS 111 Spring 2022
Lecture 1 Page 31
Another Good Reason
• Many hard problems have been tackled in the context of operating systems
– How to coordinate separate computations – How to manage shared resources
– How to virtualize hardware and software – How to organize communications
– How to protect your computing resources
• The operating system solutions are often
applicable to programs and systems you write
CS 111 Spring 2022
Lecture 1 Page 32
Some OS Wisdom
• View services as objects and operations
– Behind every object there is a data structure
• Interface vs. implementation
– An implementation is not a specification
– Many compliant implementations are possible – Inappropriate dependencies cause problems
• An interface specification is a contract – Specifies responsibilities of producers &
CS 111 – Basis for product/release interoperability Spring 2022
Lecture 1 Page 33
More OS Wisdom • Modularityandfunctionalencapsulation
– Complexity hiding and appropriate abstraction
• Separatepolicyfrommechanism
– Policy determines what can/should be done
– Mechanism implements basic operations to do it
– Mechanisms shouldn’t dictate or limit policies
– Policies must be changeable without changing mechanisms
• Parallelismandasynchronyarepowerfulandvital – But dangerous when used carelessly
• Performanceandcorrectnessareoftenatodds – Correctness doesn’t always win . . .
CS 111 Spring 2022
Lecture 1 Page 34
What Is An Operating System? • Many possible definitions
– It is low level software . . .
– That provides better, more usable abstractions of the hardware below it
– To allow easy, safe, fair use and sharing of those resources
CS 111 Spring 2022
Lecture 1 Page 35
What Does an OS Do?
• It manages hardware for programs
– Allocates hardware and manages its use – Enforces controlled sharing (and privacy) – Oversees execution and handles problems
• It abstracts the hardware
– Makes it easier to use and improves SW portability – Optimizes performance
• It provides new abstractions for applications – Powerful features beyond the bare hardware
CS 111 Spring 2022
Lecture 1 Page 36
What Does An OS Look Like? • Asetofmanagement&abstractionservices
– Invisible, they happen behind the scenes
• Applicationsseeobjectsandtheirservices
– CPU supports data-types and operations • bytes, shorts, longs, floats, pointers, …
• add, subtract, copy, compare, indirection, …
– So does an operating system, but at a higher level • files, processes, threads, devices, ports, …
• create, destroy, read, write, signal, …
• AnOSextendsacomputer
– Creating a much richer virtual computing platform • Supporting richer objects, more powerful operations
Lecture 1 Page 37
CS 111 Spring 2022
Where Does the OS Fit In?
Applications Software
(e.g., word processor, compiler, VOIP program, …)
Application Binary Interface
System Call Interface
Operating System
Privileged instruction set
Standard instruction set
System Services/Libraries
(e.g., string, random #s, encryption, graphics …)
Hardware (arithmetic, logical, copy, test, flow-control operations, …)
CS 111 Spring 2022
Lecture 1 Page 38
What’s Special About the OS?
• It is always in control of the hardware
– Automatically loaded when the machine boots – First software to have access to hardware
– Continues running while apps come & go
• It alone has complete access to hardware – Privileged instruction set, all of memory & I/O
• It mediates applications’ access to hardware – Block, permit, or modify application requests
• It is trusted
– To store and manage critical data – To always act in good faith
• If the OS crashes, it takes everything else with it
– Soitbetternotcrash… CS 111
Spring 2022
Lecture 1 Page 39
Instruction Set Architectures (ISAs) • Thesetofinstructionssupportedbyacomputer
– Which bit patterns correspond to what operations
• TherearemanydifferentISAs(allincompatible) – Different word/bus widths (8, 16, 32, 64 bit)
– Different features (low power, DSPs, floating point) – Different design philosophies (RISC vs. CISC)
– Competitive reasons (68000, x86, PowerPC)
• Theyusuallycomeinfamilies
– Newer models add features (e.g., Pentium vs. 386)
– But remain upwards-compatible with older models
• A program written for an ISA will run on any compliant CPU
CS 111 Spring 2022
Lecture 1 Page 40
Privileged vs. General Instructions
• Most modern ISAs divide the instruction set
into privileged vs. general
• Any code running on the machine can execute
general instructions
• Processor must be put into a special mode to execute privileged instructions
– Usually only in that mode when the OS is running – Privileged instructions do things that are
CS 111 Spring 2022
Lecture 1 Page 41
“dangerous”
• ISA doesn’t completely define a computer
– Functionality beyond user mode instructions • Interrupt controllers, DMA controllers
• Memory management unit, I/O busses
• BIOS, configuration, diagnostic features
• Multi-processor & interconnect support – I/O devices
• Display, disk, network, serial device controllers • These variations are called “platforms”
– The platform on which the OS must run
CS 111 Spring 2022
Lecture 1 Page 42
Portability to Multiple ISAs
• A successful OS will run on many ISAs – Some customers cannot choose their ISA
– If you don’t support it, you can’t sell to them
• Which implies that the OS will abstract the ISA
• Minimal assumptions about specific HW
– General frameworks are HW independent • Filesystems,protocols,processes,etc.
– HW assumptions isolated to specific modules • Contextswitching,I/O,memorymanagement
– Careful use of types
• Wordlength,signextension,byteorder,alignment
• How can an OS manufacturer distribute to all these different ISAs and platforms?
CS 111 Spring 2022
Lecture 1 Page 43
Binary Distribution Model
• Binary is the derivative of source
– The OS is written in source
– But a source distribution must be compiled – A binary distribution is ready to run
• OSes usually distributed in binary
• One binary distribution per ISA
• Binary model for platform support
– Device drivers can be added, after-market • Can be written and distributed by 3rd parties
• Same driver works with many versions of OS
Lecture 1 Page 44
CS 111 Spring 2022
Binary Configuration Model
• Good to eliminate manual/static configuration – Enable one distribution to serve all users
– Improve both ease of use and performance
• Automatic hardware discovery – Self-identifying busses
• PCI, USB, PCMCIA, EISA, etc.
– Automatically find and load required drivers
• Automatic resource allocation
– Eliminate fixed sized resource pools
– Dynamically (re)allocate resources on demand
CS 111 Spring 2022
Lecture 1 Page 45
What Functionality Is In the OS? • Asmuchasnecessary,aslittleaspossible
– OS code is very expensive to develop and maintain
• FunctionalitymustbeintheOSifit…
– Requires the use of privileged instructions
– Requires the manipulation of OS data structures
– Must maintain security, trust, or resource integrity
• Functionsshouldbeinlibrariesifthey…
– Are a service commonly needed by applications
– Do not actually have to be implemented inside OS
• Butthereisalsotheperformanceexcuse CS 111 – Some things may be faster if done in the OS
Spring 2022
Lecture 1 Page 47
The OS and Abstraction
• One major function of an OS is to offer abstract versions of resources
– As opposed to actual physical resources
• Essentially, the OS implements the abstract resources using the physical resources
– E.g., processes (an abstraction) are implemented using the CPU and RAM (physical resources)
– And files (an abstraction) are implemented using flash drives (a physical resource)
CS 111 Spring 2022
Lecture 1 Page 48
Why Abstract Resources?
• Theabstractionsaretypicallysimplerandbetter suited for programmers and users
– Easier to use than the original resources
• E.g., don’t need to worry about keeping track of disk interrupts
– Compartmentalize/encapsulate complexity
• E.g., need not be concerned about what other executing code is
doing and how to stay out of its way
– Eliminate behavior that is irrelevant to user
• E.g., hide the slow erase cycle of flash memory – Create more convenient behavior
CS 111 Spring 2022
• E.g., make it look like you have the network interface entirely for
your own use
Lecture 1 Page 49
Generalizing Abstractions
• Lots of variations in machines’ HW and SW
• Make many different types appear the same
– So applications can deal with single common class
• Usually involves a common unifying model – E.g., portable document format (pdf) for printers – Or SCSI standard for disks, CDs and tapes
• For example:
– Printer drivers make different printers look the
CS 111 – Browser plug-ins to handle multi-media data Spring 2022
Lecture 1 Page 50
Common Types of OS Resources
• Serially reusable resources • Partitionable resources
• Sharable resources
CS 111 Spring 2022
Lecture 1 Page 51
Serially Reusable Resources
• Used by multiple clients, but only one at a time
– Time multiplexing
• Require access control to ensure exclusive use
• Require graceful transitions from one user to the next
• Examples:
CS 111 Spring 2022
Lecture 1 Page 52
What Is A Graceful Transition?
• A switch that totally hides the fact that the resource used to belong to someone else
CS 111 Spring 2022
Don’t allow the second user to access the resource until the first user is finished with it
No incomplete operations that finish after the transition
Ensure that each subsequent user finds the resource in “like new” condition
No traces of data or state left over from the first user
Lecture 1 Page 53
Partitionable Resources
• Divided into disjoint pieces for multiple clients
– Spatial multiplexing
• Needs access control to ensure:
– Containment: you cannot access resources outside of your partition
– Privacy: nobody else can access resources in your partition
• Examples:
CS 111 Spring 2022
Lecture 1 Page 54
Do We Still Need Graceful Transitions?
• Most partitionable resources aren’t permanently allocated
– The piece of RAM you’re using now will belong to another process later
• As long as it’s “yours,” no transition required
• But sooner or later it’s likely to become
someone else’s
CS 111 Spring 2022
Lecture 1 Page 55
Shareable Resources
• Usable by multiple concurrent clients
– Clients don’t “wait” for access to resource
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com