operating system concepts - uni-hamburg.de · 28/10/15 os concepts 1 . what is an os • hard to...

55
Introduc)on to Opera)ng System Concepts Prak)kum Kernel Programming University of Hamburg Scien)fic Compu)ng Winter semester 2015/2016 Konstan)nos Chasapis Konstan)nos.chasapis@informa)k.uni-hamburg.de

Upload: others

Post on 28-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Introduc)ontoOpera)ngSystemConcepts

Prak)kumKernelProgrammingUniversityofHamburgScien)ficCompu)ng

Wintersemester2015/2016

Konstan)nosChasapisKonstan)nos.chasapis@informa)k.uni-hamburg.de

Page 2: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Outline

•  WhatisanOpera)ngSystem•  HistoryofOpera)ngSystems•  ComputerHardware•  TypesofOpera)ngSystems•  ProcessManagement•  MemoryManagement•  StorageManagement*disclaimer:someofthetopicspresentedhereareincomplete.28/10/15 OS Concepts 1

Page 3: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

WhatisanOS•  Hardtodefine•  Abstractsasetofhardwareresources– Highlevelinterfaceinsteadofmachinecode

•  e.g.filestorageontopofblockdevices•  Resourcemanagement

– Mul)plexing(sharing)resources•  e.g.assignCPU)metoapplica)ons

Hardware

Operating System

Libraries

Applications

28/10/15 OS Concepts 2

Page 4: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

1stGenera)on

•  VacuumTubes(1945-55)– ~20,000vacuumtubeswereused– Programmingwasdoneinabsolutemachinecode

– Assemblylanguagewasunknown– Eachprogramusedthemachineexclusively

– MostfamousENIAC•  Announcedin1946•  Solvelargeclassnumericalproblems

28/10/15 OS Concepts 3

Page 5: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

2ndGenera)on•  Transistorsandbatchsystems(1955-65)–  Designers/Builders/Operators/Programmers/Maintainers

–  Programmersfirstwrotetheprogramonpaper,thenpuncheditoncards

–  Cardreaderstoreadtheprogramsource

–  Outputstoredontapesandalsoprinted–  1stuseofcompilers(FORTRAN)

28/10/15 OS Concepts 4

Page 6: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

3rdGenera)on•  ICsandMul)programming(1965-1980)

–  IBM360Mainframe•  Mul)programming•  Severalprogramsinmemoryatoncewithseparatememory,overlapI/Owithcomputa)on

–  Timesharing•  Eachuserhasanonlineterminal•  CTSS(Compa)bleTimeSharingSystem)•  MULTICS(MULTiplexInforma)onandCompu)ngSystem)•  UNIX,astripped-downversionofMULTICS•  BSC(BerkeleySodwareDistribu)on)

28/10/15 OS Concepts 5

Page 7: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

4thGenera)on

•  PersonalComputers(1980-today)– SYSTEMV,1stcommercialUNIXopera)ngSystem(1983)

– LSI(LargeScaleIntegra)on)–  IBMPC(early1980s)

•  Intel80286CPU•  DOS(DiskOpera)ngSystem)•  MS-DOS(MicrosodDOS)

– LISA•  FirstcomputerwithGUI•  Protectedmemory,preemp)vemul)tasking

28/10/15 OS Concepts 6

Page 8: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

5thGenera)on

•  Smartphones(1990-today)•  SymbianOS•  RIM’sBlackberryOS•  WindowsMobile•  Android•  iOS

28/10/15 OS Concepts 7

Page 9: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

ModernOpera)ngSystems

28/10/15 OS Concepts 8

Page 10: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Outline

•  WhatisanOpera)ngSystem•  HistoryofOpera)ngSystems•  ComputerHardware•  TypesofOpera)ngSystems•  ProcessManagement•  MemoryManagement•  StorageManagement

28/10/15 OS Concepts 9

Page 11: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

ComputerHardware

•  Processor•  Mainmemory•  I/Odevices•  Disk•  Busses

28/10/15 OS Concepts 10

Page 12: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Processor(CPU)

•  Specificinstruc)onset

•  Basiccycle•  fetch•  decode•  execute•  Mul)plecores•  Mul)plelevelsofcachememory

https://commons.wikimedia.org/wiki/File:AMD_Bulldozer_block_diagram_%288_core_CPU%29.PNG 28/10/15 OS Concepts 11

Page 13: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

MainMemory

•  Randomaccessmemory(RAM)– Largebutslow– Vola)le,losesdatainpowerloss

•  Sta)c(SRAM)•  Fastbutexpensive•  UsedasCPUcache

– Dynamic(DRAM)•  Storebitsincapacitors•  Requirerefreshtoretainstate•  LargerthanSRAMbutslower

– Non-Vola)le,keepstatewithoutpower•  Notyetmaturetechnology

RAM Disk

CPU Cache Registers

28/10/15 OS Concepts 12

Page 14: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Disks

•  Mechanicaldevice•  Highcapacity

– 200xsizeofRAM•  Slow

– 1000xslowerthanRAM•  Magne)crecording•  Movingparts

– Rota)ngplaiers– Head

•  Seek)me28/10/15 OS Concepts 13

Page 15: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

I/ODevices

•  Usuallytwoparts– Theactualdevice– Controller

•  Chip(s)thatphysicallycontrolsthedevice•  “Talks”totheopera)ngsystem(OS)•  Devicedriver

–  SodwarethatconnectsOSwiththecontroller

28/10/15 OS Concepts 14

Page 16: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

I/ODevices(cont.)

•  Formsofcommunica)on– Busywai)ng

•  OSwaitsun)ldeviceresponse–  Interrupts

•  DeviceinformtheOSthat“something”happened– Polling

•  TheOSregularlychecksthedevice– DMA(DirectMemoryAccess)

•  Specialhardware•  DatamovementfrommemorytocontrollerwithoutgoingthroughtheCPU

28/10/15 OS Concepts 15

Page 17: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Busses•  Connectcomputercomponents

–  Parallel(mul)plewires)•  Carrydatawordsinparallel

–  Serial(lanes)•  Carrydatainserialformineachlane

•  Differentspeeds•  Differentfunc)onality•  Examples

–  PCIe(PeripheralComponentInterconnectexpress)–  SATA(SerialATA)

28/10/15 OS Concepts 16

Page 18: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Outline

•  WhatisanOpera)ngSystem•  HistoryofOpera)ngSystems•  ComputerHardware•  TypesofOpera)ngSystems•  ProcessManagement•  MemoryManagement•  StorageManagement

28/10/15 OS Concepts 17

Page 19: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

TypesofOSs•  Mul)-user

–  Mul)pleusersaccessthecomputersimultaneously•  Single-tasking

–  Onlyonerunningprogram•  Mul)-tasking

–  Allowsmorethanoneprogramtoruninparallel•  Twotypes:

–  Pre-emp)ve,theOSinterruptstherunningprogramandassignstheCPUtothenext

–  Co-opera)ve,eachprocessgive)metotheothers•  Real-)me

–  Aimsatexecu)ngreal-)meapplica)ons

28/10/15 OS Concepts 18

Page 20: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

TypesofOSs(cont.)

•  Distributed– Managesagroupofindependentcomputersandmakesthemappeartobeasinglecomputer

•  Templated– Asinglevirtualmachineimageasaguestopera)ngsystem,thensavingitasatoolformul)plerunningvirtualmachines

•  Embedded– Designedtobeusedinembeddedcomputersystems

28/10/15 OS Concepts 19

Page 21: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Monolithickernel•  Singleimagethatrunsinasingleaddressspace

– Asetofprimi)veopera)onsareimplementedintheopera)ngsystemlevel

•  Processmanagement•  Memorymanagement•  DeviceDrivers

– Trivial(IPC)InterProcessCommunica)on– Easytodesign– Difficulttomaintainandextend– Examples:

•  MULTICS,SunOS,Linux,BSD

28/10/15 OS Concepts 20

Page 22: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Micro-kernel•  TheminimumamountofsodwarethatprovidesthemechanismsneededtoimplementanOS– Alsoknownasμ-kernel– Provides

•  Built-inIPC•  Lowleveladdressspacemanagement•  Threadmanagement

– Easytoextend– Performancepenal)es(requiresIPCcalls)– Examples

•  Symbian,MacOS,WinNT28/10/15 OS Concepts 21

Page 23: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Monolithicvs.μ-kernelEverythingthatrunsinkernelmodedefinestheOS

Source: http://en.wikipedia.org/wiki/Microkernel#mediaviewer/File:OS-structure.svg

28/10/15 OS Concepts 22

Page 24: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Outline

•  WhatisanOpera)ngSystem•  HistoryofOpera)ngSystems•  ComputerHardware•  TypesofOpera)ngSystems•  ProcessManagement•  MemoryManagement•  StorageManagement

28/10/15 OS Concepts 23

Page 25: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Processes•  Anabstrac)onofarunningprogram•  Everyprocess“thinks”thatitrunsalone

– Assumededicatedresources(addressspace,CPU)•  Hasasinglecontrolflow(programcounter)

– Whichopera)oniscurrentlyexecuted•  Programmer’srole

– Defineswhattheprocesswilldo•  Opera)ngsystemrole

–  Processmanagement28/10/15 OS Concepts 24

Page 26: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

ProcessManagement•  Processcrea)on

–  System(ini)aliza)on,systemcall)– User(executesanewprogram)

•  Processtermina)on– Normalexit–  Error(voluntary),Fatalerror(involuntary)–  Killedbyanotherprocess

•  ProcessScheduling– AssignCPUtotheprocesses– Determinewhichprocesswillexecutenext–  Switchbetweendifferentprocesses(contextswitch)

28/10/15 OS Concepts 25

Page 27: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

ProcessHierarchies

•  Oneprocessinvokesthecrea)onofanother– Parentprocess,ini)atedthecrea)on– Childprocess,thecreatedprocess

•  Canalsocreateprocesses•  Daemonprocess

– Runsinthebackground– Notcontrolledbytheuser– Crea)on

•  Createanewprocess(child)•  Killyourparent•  Con)nuewiththeexecu)on

28/10/15 OS Concepts 26

Page 28: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

ProcessStates

•  Running– CurrentlyusingtheCPU

•  Ready– Readytoexecute

•  Blocked– Unabletorun– Waitsun)l“something”externaltohappen

Running

Blocked Ready

28/10/15 OS Concepts 27

Page 29: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

ProcessScheduling

•  Holdprocessesinqueues–  jobqueue,allprocesses–  runningprocesses,abletorun– devicequeue,wai)ngforI/Ocomple)on

28/10/15 OS Concepts 28

Page 30: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

ProcessScheduling

•  Scheduler– Processthatmigratesprocessesbetweenqueues

•  PolicyConsidera)ons– Priori)za)on,whichwillexecutefirst– Fairness,everyprocessgetsafairamountofCPU– Starva)on,doesnotgetCPU)me– MaximizeCPUu)liza)on

28/10/15 OS Concepts 29

Page 31: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

ContextSwitch

•  SwitchtheCPUtoanotherprocess/thread– Saveprogram“context”

•  Registers•  Stack•  Memory

–  Impliesoverhead

28/10/15 OS Concepts 30

Page 32: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Threads

•  Whynothavingmorethanonecontrolflowinsideaprocess?– Sameproblemsolvedbymorethanone

•  Threadsare“mini”orlightweightprocesses

28/10/15 OS Concepts 31

Page 33: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Threadvs.Process•  Perthread

–  Stack–  Registers–  Privatecontrolflow(Programcounter)

•  Perprocess– Addressspace– Globalvariables–  Filedescriptors–  Childprocesses–  Signals,signalhandling– Accoun)nginforma)on

28/10/15 OS Concepts 32

Page 34: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Threadsconcurrency

•  Manythreadsrunninginparallel•  Cooperatetosolveasingleproblem

– Splittheprobleminsub-problems•  Requirecoordina)on/synchroniza)on

– ControlCPUusage– Controlaccesstosharedresources

28/10/15 OS Concepts 33

Page 35: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

ArrayMul)plica)on•  Assumethatwehavetomul)plytwoarrays•  Singlethreadedsolu)on

–  Startfromthebeginningofthematrixandcalculateeverycelloneata)me

•  Mul)threadedsolu)on–  Splitthearrayinsub-arrays–  Assigneachsub-arraytoadifferentthread–  Runthreadsinparallel– Waitun)lallthreadsfinishthecalcula)ons–  Outputmatrixisready

28/10/15 OS Concepts 34

Page 36: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Synchronous/Asynchronousexecu)on

•  Synchronousexecu)on–  Opera)onreturnswhentheexecu)onfinishes–  Example

•  Iwillcon)nuecookingwhenthewaterhasboiled•  Asynchronousexecu)on

–  Opera)onreturnsimmediatelyaderexecu)onini)aliza)on

–  Checklaterorno)fywhentheexecu)onfinishes–  Example

•  Iputthewatertoboilandcon)nuewiththerestoftherecipe

•  Ader5minutesIcheckifthewaterhasboiled

28/10/15 OS Concepts 35

Page 37: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Webserverexample•  Webservertasks

– Acceptsrequestsforawebpage–  Fetchesthedatafromthestoragesystem–  Repliesbysendingthedata

•  Singlethreadsolu)on–  Eachrequestisexecutedserially– Onlyasinglerequestisbeingprocessedata)me–  Everyrequesthastowaitfortheprevioustocompletealltasks

–  I/Oisslow,lotsof)mewai)ng–  Cannotu)lizemul)plecores

28/10/15 OS Concepts 36

Page 38: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Webserverexample•  Mul)-threaded

–  Createathreadforeachrequest– Mul)plerequestscanbeservedinparallel–  Threadexecu)on

•  Acceptrequest•  I/Orequest,fetchdatafromdisk•  Thisrequestcallcanbeasynchronous•  Replyrequest,senddata

– Mul)-coreu)liza)on– OverlapI/Owithcomputa)on

28/10/15 OS Concepts 37

Page 39: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Synchroniza)onissues•  Cri)calregion

–  Partoftheprogramthataccessessharedresources•  Globalvariables•  Sharedmemory•  Filedescriptors

–  Itissafetobeexecutedbyonlyoneprocess/threadata)me

•  Racecondi)on–  Thesuccessfulexecu)ondependsonthesequenceor)mingoftheotherthreads/processes

28/10/15 OS Concepts 38

Page 40: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Synchroniza)onissues•  Assumetwotasksruninparallel

•  Task1readsaglobalvariableandupdatesthevalue

•  Task2usesthesamevariableasTask1

28/10/15 OS Concepts 39

Page 41: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

MutualExclusion•  Preventparallelexecu)onsofthe“cri)calregion”

•  Basicmethodsformutualexclusion–  Sleepandwakeup

•  Onetaskexplicitlyputstheotheronetosleepwhenitentersthecri)calregion

•  Wakesitupwhenitexitsthecri)calregion–  Semaphores

•  Specialintegervariablestocountsleepsandwakeups– Mutex

•  Simplifiedsemaphoreonlytwostateslock,unlock

28/10/15 OS Concepts 40

Page 42: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Producer/Consumer

procedure producer() { while (true) { item = produceItem(); if (count == N) sleep(); insert(item); count = count + 1; if (count == 1) wakeup(consumer); } }

procedure consumer() { while (true) { if (count == 0) sleep(); item = remove(); itemCount = Count - 1; if (count == N - 1) wakeup(producer); consumeItem(item); } }

#define N 100 int count=0;

28/10/15 OS Concepts 41

Page 43: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Deadlock

•  Oneprocesswaitsfortheother•  Competeforresources

– P1needsresourcesfromP2– P2needsresourcesfromP1

•  Alwaysallocatewiththesameorder•  Hardtodebug

28/10/15 OS Concepts 42

Page 44: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Outline

•  WhatisanOpera)ngSystem•  HistoryofOpera)ngSystems•  ComputerHardware•  TypesofOpera)ngSystems•  ProcessManagement•  MemoryManagement•  StorageManagement

28/10/15 OS Concepts 43

Page 45: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

AccessPhysicalMemory

•  Useabsolutephysicaladdresses•  Nomemoryabstrac)on•  Runmul)pleprocesses

– OSsavestheen)rememory– OSloadsthenextprocess’smemory– Runsthenextprocess

28/10/15 OS Concepts 44

Page 46: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

MemoryAbstrac)on•  Allowmul)pleprocessestoexistinmemory•  Protec)on

–  Askforpermissiontoaccessanaddressinmemory•  Reloca)on

–  Allocatephysicalmemorydynamically–  Relocatetheprocesstoadifferentregion

•  Sharing–  Controlwhichdatawillbesharedbetweenprocesses

•  Dis)nguishphysicaltologicalmemory–  Managethememoryhierarchy

28/10/15 OS Concepts 45

Page 47: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

AddressSpace

•  Setofaddressthataprocesscanuse– Memoryabstrac)on– Mapeachprocess’saddressspaceintodifferentpartsofphysicalmemory

•  Useoftworegisters– Base,startaddressoftheprogram– Limit,lengthoftheprogram– OnlyOSmodifiestheseregisters

•  Processmemoryaccess– Logicaladdress+Baseregister

28/10/15 OS Concepts 46

Page 48: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Swapping

•  Ifmainmemoryisnotenough– Usedisktotemporarilystoreprocessdata

•  Movingfrommemorytodiskandviceversaiscalled“swapping”

•  Slowprocess–  InvolvesdiskI/O

28/10/15 OS Concepts 47

Page 49: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

VirtualMemory

•  Maplogicaladdressestophysicaladdresses•  Eachprocesshasaprivateaddressspace•  Addressspacedividedtopages•  Pagesmappedtophysicalmemory•  OSkeepsapagetable

– Transla)onfromvirtualtophysicalpages

28/10/15 OS Concepts 48

Page 50: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Outline

•  WhatisanOpera)ngSystem•  HistoryofOpera)ngSystems•  ComputerHardware•  TypesofOpera)ngSystems•  ProcessManagement•  MemoryManagement•  StorageManagement

28/10/15 OS Concepts 49

Page 51: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

StorageManagement

•  Applica)onsneedpermanentdatastorage– Persistency

•  Hardwareprovidesblocklevelaccesses– Usefixed-sizeblocks– Everyblockhasitsownaddress– Transfersinmul)plesofblocks– Seagateprovidesobjectbasedaccess(key/value)

•  OSprovidesmethodstostoreandretrievedatafromdisks

28/10/15 OS Concepts 50

Page 52: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

FileSystem•  Movedatafrommemorytodiskandviceversa•  Exportfilesabstrac)on

– Namedatacollec)onswithnames->filename– Maplogicalcon)nuousunitstoarbitrarydiskblocks– Accesstheminbytelevel

•  Exportfilesystemtree(hierarchy)– Groupfilescollec)onindirectories

28/10/15 OS Concepts 51

Page 53: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

FileSystem

•  Diskspacemanagement– Keepstrackofusedspace– Freespacethatisnotusedbytheusers

•  Holdsystemstate– Systemmightbeininconsistentstateduringanunexpectedfailure

•  Updatesystemvariables–  Journalusedtokeeppreviouslyconsistentstate– Recoverfromsystemcrash

28/10/15 OS Concepts 52

Page 54: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

FileSystem-Dataprotec)on

•  Eachusercontrolsfiles/directoriespermission•  Linuxpermissionthreegroups

– owner,thefile/directoryowner– group,thegroupthattheuserbelongs– allusers,therestoftheusers

•  Threebasicpermissiontypes–  read,canreadthefile– write,canmodifythefile– execute,canexecuteafile(denotesexecutables)

28/10/15 OS Concepts 53

Page 55: Operating System Concepts - uni-hamburg.de · 28/10/15 OS Concepts 1 . What is an OS • Hard to define • Abstracts a set of hardware resources – High level interface instead

Ques)ons?

Konstan)nosChasapis

Konstan)nos.chasapis@informa)k.uni-hamburg.de

OS Concepts 28/10/15 54