L01: Introduction - COMPSCI 377 Operating Systems

Transcription

L01: Introduction - COMPSCI 377 Operating Systems
Opera;ngSystems
CMPSCI377
TimRichards
UniversityofMassachuseIsAmherst
1
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
Today’sClass
§ Organiza)onalmee)ng
– Courseorganiza)on&outline
– Policies
– Prerequisites&coursesign-up
§ IntrotoOpera)ngsystems
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
2
Work
§ ReadChapter1
§ W01QuizonMoodle
§ Homework1
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
3
Organiza;onalInforma;on
§ Coursewebpage
– VisithJp://umass-cs-377.github.io
– Moodle377page:toturninassignments,discussion
forumsetc
– Piazza
§ Contactinfo
– [email protected]
§ PrimaryTA:[email protected]
§ SecondaryTA:[email protected]
§ Discussionsec)on(Wednesdays11:15-12:05)
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
3
PrerequisitesandSyllabus
§ CMPSCI230:computerSystemsPrinciples
§ Textbook:Opera)ngSystemConcepts
(Silberschatz,Galvin,Gagne)9thed
§ Courserequirements
– Severalhomeworksplusseveralin-classassignments(10%)
– Weeklyquizzes(10%)
– Severallab/programmingassignments(40%)
– 3exams(40%)–twomidtermsandafinal
§ Latepoliciesandchea)ng
– Automa)c48hourlateextension
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
CourseOrganiza;on:Misc
§ AccountsintheEd-lab:30+Linux-based
PCs
§ Discussionsec)ontohelpyouwithLab
assignmentsandcourseconcepts
§ Officehours:
– Instructor:
W10:00-11:00a,CS258orbyapp
– TAOfficehrsandloca)on:
Teddy-M11:00-1p,CS207(star)ngnextweek)
Tianbo-F11:00-1p,CS207
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
CourseRequirements
§ Note:Percentagesaresubjecttorevision.
§ Programmingprojects:40%
– Strictlatepolicy!
§ In-classexams:40%
§ Homework&Classwork:10%
§ Quizzes:10%
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
6
Exams
§ 3Exams:2Midtermsand1finalexam
§ Midtermexam1
– Feb18,2016(inclass)
§ Midtermexam2
– Mar24,2016(inclass)
§ Finalexam
– Apr29,10:30a-12:30p,ILCS211
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
8
Labs
§ 3-4Projects
– Focusontopicscoveredintheclass
§ ProjectswilluseC/C++(andsomeJava)
§ Mayworkingroupsof2
§ EdLabAccountsoruseyourownmachine
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
7
Plagiarism
§ Chea)ngincludes:
– “Borrowing”codefromsomeone
• Thisincludesreadingprevioussolu)ons
–
–
–
–
–
Givingcodetosomeone(evennextyear)
Copyingcodefromanyone(includingthenet)
Hiringsomeonetowriteyourcode
Submiongsomeoneelse’scodeasyourown
Lookingatanyoneelse’scode
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
8
CellPhoneandLaptopPolicy
classusepolicy:Don’t!
Cellphonesshouldbeofforonsilentalert
Tex)ngisstrictlyprohibitedinclass
Laptopsandtabletsmaybeusedinclass:
Noemail,browsing,facebook,twiJer
duringclasslectures
§ Laptopsallowedinthediscussionsec)on
§
§
§
§
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
9
CourseOutline&Topics
§
§
§
§
§
Introduc)on
ProcessesandThreads
MemoryManagement
StorageandFileSystems
DistributedSystems
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
10
What’sAnOpera;ngSystem?
§ Defini)onhaschangedoveryears
– Originally,verybarebones
– Now,includesmoreandmore
§ Opera)ngSystem(OS)
– Interfacebetweentheuserandthe
architecture
– Implementsavirtualmachinethatis
– (hopefully)easiertoprogramthanraw
hardware.
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
11
OS:Tradi;onalView
§ Interfacebetweenuserandarchitecture
– Hidesarchitecturaldetails
§ Implementsvirtualmachine:
– Easiertoprogramthanrawhardware
§ Illusionist
– Bigger,faster,reliable
§ Government
– Dividesresources
– “Taxes”=overhead
User-level Applications
virtual machine interface
Operating System
physical machine interface
Hardware
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
13
NewDevelopmentsinOS
§ Opera)ngsystems:ac)vefieldofresearch
– DemandsonOS’sgrowing
– Newapplica)onspaces(Web,Grid,Cloud)
– Rapidlyevolvinghardware
§ Adventofopen-sourceopera)ngsystems
– Linuxetc.
– YoucancontributetoanddevelopOS’s!
– Excellentresearchplatorm
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
14
OSMostNotableFeatures
• Services: The OS provides standard services (the
interface) which the hardware implements.
– Examples: the file system, virtual memory, networking, CPU
scheduling, and time-sharing
• Coordination: The OS coordinates multiple
applications and users to achieve fairness and
efficiency (throughput).
– Examples: concurrency, memory protection, networking, and
security.
• Goal: Design an OS so that the machine is convenient
to use (a software engineering problem) and efficient
(a system and engineering problem).
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
WhyStudyOpera;ngSystems?
• Abstraction: How to get the OS to give users an
illusion of infinite memory, CPUs, resources, world
wide computing, etc.
• System Design: How to make tradeoffs between
– performance and the convenience of OS abstractions,
– performance and the simplicity of OS design, and
– putting functionality in hardware or software.
• Basic Understanding: The OS provides the services
that allow application programs to work at all.
• System Intersection Point: The OS is the point where
hardware and software meet.
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
WhyStudyOpera;ngSystems?
Notmanyopera)ngsystemsareunderdevelopment,soyouare
unlikelytogetajobbuildinganOS.However,understanding
opera)ngsystemswillenableyoutouseyourcomputermore
effec)vely.Theyalsoserveasanexcellentexampleofsystem
designissueswhoseresultsandideasyouwillapplyelsewhere.
§ Background:Tounderstandthiscourseyoumusthavea
solidbasicunderstandingofhardware(CPUinstruc)onsets,
memoryhierarchies,I/Osystems,etc.)andsolidprogramming
skills(complexdatastructures,classesasanencapsula)on
mechanism,etc.)
– Obviously,youcannotunderstandtheimplica)onsofhow
componentsintersectwithoutunderstandingthecomponents.
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
BuildLargeComputerSystems
§ OSasanexampleoflargesystemdesign
§ Goals:Fast,reliable,largescale
§ Tobuildthesesystems,youneedtoknow
– Eachcomputer:
•
•
•
•
•
ArchitecturaldetailsthatmaJer
CandC++(niJygriJy&more)
Memorymanagement&locality
Concurrency&scheduling
Disks,network,filesystems
– Acrosscluster:
• Serverarchitectures
• Distributedcompu)ng,filesystems
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
18
HistoryofOpera;ngSystems
§ Andnow,forsomehistoricalcontext
– Frommainframestoweb-basedsystems
innineslides
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
19
1.Single-UserComputers
§ Hardware:expensive;humans:cheap
§ Oneuserata)meonconsole
– Interac)ngwithasprogramruns
§ Computerexecutesonefunc)onata)me
– Nooverlap:computa)on&I/O
§ Usermustbeatconsoletodebug
§ Mul)pleusers=inefficientuseofmachine
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
20
2.BatchProcessing
§ Executemul)ple“jobs”inbatch:
–
–
–
–
Loadprogram
Run
Printresults,dumpmachinestate
Repeat
§ Userssubmitjobs(oncardsortape)
§ Humanschedulesjobs
§ Opera)ngsystemloads&runsjobs
§ Moreefficientuseofmachine
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
21
3.OverlapI/OandComputa;on
§ Before:machinewaitsforI/Otocomplete
§ Newapproach:
– AllowCPUtoexecutewhilewai)ng
– Addbuffering
• Datafills“buffer”andthenoutput
– andinterrupthandling
• I/Oeventstriggerasignal(“interrupt”)
§ Moreefficientuseofmachine
– s)llonejobata)me
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
22
4.Mul;programming
§ Severalprogramstorunsimultaneously
– Runonejobun)lI/O
– Runanotherjob,etc.
§ OSmanagesinterac)ons
– Whichjobstorun(schedule)
– Protectsprogram’smemoryfromothers
– DecideswhichtoresumewhenCPUavailable
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
23
OSComplexity
§ Increasedfunc)onality&complexity
§ FirstOSfailures
– Mul)cs(GE&MIT):
announced1963,released1969
– OS/360releasedwith1000knownbugs
§ NeedtotreatOSdesignscien)fically
§ Managingcomplexitybecomeskeyto…
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
24
TheRenaissance(1970’s)
§ Hardware:cheap;humans:expensive
§ Userssharesystemviaterminals
§ TheUNIXera
– Mul)cs:
• armyofprogrammers,sixyears
– UNIX:
• threeguys,twoyears
• “Shell”:composablecommands
• Nodis)nc)onbetweenprograms&data
§ But:response)me&thrashing
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
25
IndustrialRevolu;on(1980’s)
§ Hardwareverycheap;
§ humansexpensive
§ WidespreaduseofPCs
– IBMPC:1981,Macintosh:1984
§ SimpleOS(DOS,MacOS)
– Nomul)programming,
concurrency,memoryprotec)on,virtualmemory,…
– Later:networking,file-sharing,remoteprin)ng…
– GUIaddedtoOS(“WIMP”)
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
26
TheModernEra(1990’s-now)
§ Hardwarecheap;processingdemands
increasing
§ “Real”opera)ngsystemsonPC’s
– NT(1991);MacOSX;Linux
§ Differentmodali)es:
– Real-)me:Strictorloosedeadlines
– Sensor/Embedded:Manysmallcomputers
– Parallel:Mul)pleprocessors,onemachine
– Distributed:Mul)plenetworkedprocessors
• ThinkP2P,theWeb,Google,cloud
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
27
ArchitecturalTrends
§ BigChanges
– In50years,almosteverycomputer
componentnow
9ordersofmagnitudefaster,larger,cheaper
1983
1999
0.5
500
$100,000
$500
memory
1MB
1GB
network
10Mbit/s
1Gb/s
1GB
1Tbyte
examples
Millions of
Instructions
Per Second
MIPS
cost/MIPS
disk
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
28
HistoryLesson
Thisdegreeofchangehasnocounterpartinanyotherareaof
business.
Examples:
§ Transporta)on--overthelast200years,wehavegonefrom
horseback(10miles/hour)totheConcorde(1000miles/hour)-
2ordersofmagnitude.
§ Communica)on--attheinven)onofthetelephone(voice),TV
(video)andfax(text\&pictures),communica)onwentfromthe
speedoftransporta)ontonearlythespeedoflight-7ordersof
magnitude.
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
OrdersofMagnitude
§ 10^0
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
30
OrdersofMagnitude
§ 10^1
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
31
OrdersofMagnitude
§ 10^2
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
32
OrdersofMagnitude
§ 10^3
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
33
OrdersofMagnitude
§ 10^4
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
34
OrdersofMagnitude
§ 10^5
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
35
OrdersofMagnitude
§ 10^6
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
36
OrdersofMagnitude
§ 10^7
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
37
OrdersofMagnitude
§ 10^8
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
38
OrdersofMagnitude
§ 10^9
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
39
ComingSoon
§ Moore’sLaw–runningoutofsteam
§ New“features”coming
– Mul)plecores
– Unreliablememory
– Seriouspower/heatconstraints
§ Othertradeoffspossible
– Compu)ngpowerforreliability…
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
40
What’sanOS?BillGatessays…
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
12
Whatisimportanttoyou?
§ Fromyourperspec)ve,thinkaboutthe
following:
– Whatisanopera)ngsystem?
– Whatisthemostimportantaspectofan
opera)ngsystem(accordingtoyour
defini)on)andwhy?
§ Takeamomenttothinkaboutthis…
§ Then,writeashortparagraphanswering
theseques)ons.8-digitspireIDandname
atthetopplease.Handinatendofclass.
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
43
Perspec;ves
§ Welookatopera)ngsystemsfrom…
§ TheUserView
– Easeofuse(mostly)
– Performance(some)
§ TheSystemView
– ResourceAlloca)on
– ProgramExecu)on
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
44
OSDefini;on
§ AnOScoversmanyrolesandfunc)ons.
§ Theyareubiquitousinoureverydaylives
– sure:laptops,desktops,phones,etc.
– but:cars,toasters,refrigerator,homes,medical
equipment,etc.
§ Defini;on?
– Ingeneral,wehavenoadequatedefini)onofan
opera)ngsystem.
– Theyexistbecausetheyoffersomereasonable
waytosolvetheproblemofcrea)ngausable
“compu)ngsystem”.
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
45
So,whatisanOS?
§ HugeRange
– Big(Windows,MacOSX,YourCar)
– Small(WearableComputers)
§ Wewillfollowthiscommondef.ofanOS:
– Aprogramthatconstantlyexecutes:kernel
– Librariesthathelpthekernel:middleware
– ProgramsthathelptheOS:systemprograms
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
46
ComputerSystemOrganiza;on
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
47
ComputerSystemOrganiza;on
Kernel
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
48
BootstrapProgram
§ HowdoesanOScometolife?
§ TheBootstrapProgram
– Asmallprogramtypicallystoredincomputer
hardware(ROM)
– Ini)alizescomputerhardware
– Knowswhereto“find”theinstruc)onsfor
theopera)ngsystemkernel,loadspartofit
intomemory,andhandsovercontrol.
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
49
SystemProcesses
§ OSStartup
– Kernelisloadedintomemory
– Beginsexecu)on
– Startssystemprocesses(daemons)
theseruninthe“background”
§ Then,wewait…
– TheOSwaitsforaneventtooccur
– Whenaneventoccurs,theOSwillstepinto
handletheevent.
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
50
Events!
§ Howdoweknowwhenaneventhappens?
– Aninterruptistriggered!
– Thisoriginatesfromeitherhardwareor
so~ware
§ Hardware
– Maytriggeraninterruptatany
)mebysendingasingletothe
CPU(viasystembus)
§ Sohware
– Maytriggeraninterruptwithasystemcall
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
51
InterruptTimeline
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
52
InterruptTimeline
Process makes I/O
Request
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
53
InterruptTimeline
Sends trap to indicate
completion.
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
54
InterruptTimeline
Process suspends.
Transfers I/O to memory
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
55
InterruptTimeline
Process resumes
execution
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
56
InterruptTimeline
Another I/O request
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
57
InterruptTimeline
Transfer done, signals
completion
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
58
InterruptTimeline
Process suspends,
Handles I/O
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
59
InterruptTimeline
Execution resumes
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
60
Mul;programming
§ ModernOpera)ngSystems
– Allowmul)pleprograms/processesto
executeconcurrently.
– Interruptsarekeyto)mesharingbetween
processes.
– EventsarecoretoanOSopera)on.
§ TheWeb
– Alsoeventdriven!
– Isthewebanopera)ngsystem?
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
61
NextTime
§ OSandComputerArchitecture
UNIVERSITYOFMASSACHUSETTSAMHERST•CollegeofInforma;onandComputerScience
62