Midterm Exam 1 Review - University Of Connecticut

1m ago
10 Views
0 Downloads
2.51 MB
90 Pages
Last View : 12d ago
Last Download : n/a
Upload by : Troy Oden
Share:
Transcription

Midterm Exam 1 ReviewOperating System Concepts – 9th Edition1.1Silberschatz, Galvin and Gagne 2013

Computer System StructureComputer system can be divided into four components:Hardware – provides basic computing resources CPU, memory, I/O devicesOperating system Controls and coordinates use of hardware among variousapplications and usersApplication programs – define the ways in which the systemresources are used to solve the computing problems of theusers Word processors, compilers, web browsers, databasesystems, video gamesUsers People, machines, other computersOperating System Concepts – 9th Edition1.2Silberschatz, Galvin and Gagne 2013

Four Components of a Computer SystemOperating System Concepts – 9th Edition1.3Silberschatz, Galvin and Gagne 2013

Operating System DefinitionOS is a resource allocatorManages all resourcesDecides between conflicting requests for efficient andfair resource useOS is a control programControls execution of programs to prevent errors andimproper use of the computerOperating System Concepts – 9th Edition1.4Silberschatz, Galvin and Gagne 2013

Computer System OrganizationComputer-system operationOne or more CPUs, device controllers connect through common busproviding access to shared memoryConcurrent execution of CPUs and devices competing for memorycycles. A memory controller synchronizes access to the memory.Operating System Concepts – 9th Edition1.5Silberschatz, Galvin and Gagne 2013

Common Functions of InterruptsInterrupt transfers control to the interrupt service routinegenerally, through the interrupt vector, which contains theaddresses of all the service routinesInterrupt architecture must save the address of theinterrupted instructionA trap or exception is a software-generated interruptcaused either by an error or a user requestAn operating system is interrupt drivenOperating System Concepts – 9th Edition1.6Silberschatz, Galvin and Gagne 2013

Interrupt TimelineOperating System Concepts – 9th Edition1.7Silberschatz, Galvin and Gagne 2013

Storage StructureMain memory – only large storage media that the CPU can accessdirectlyRandom accessTypically volatileSecondary storage – extension of main memory that provides largenonvolatile storage capacityHard disks – rigid metal or glass platters covered with magneticrecording materialDisk surface is logically divided into tracks, which are subdivided intosectorsThe disk controller determines the logical interaction between the deviceand the computerSolid-state disks – faster than hard disks, nonvolatileVarious technologiesBecoming more popularOperating System Concepts – 9th Edition1.8Silberschatz, Galvin and Gagne 2013

Storage HierarchyStorage systems organized in hierarchySpeedCostVolatilityCaching – copying information into faster storage system;main memory can be viewed as a cache for secondarystorageDevice Driver for each device controller to manage I/OProvides uniform interface between controller andkernelOperating System Concepts – 9th Edition1.9Silberschatz, Galvin and Gagne 2013

Storage-Device HierarchyOperating System Concepts – 9th Edition1.10Silberschatz, Galvin and Gagne 2013

CachingImportant principle, performed at many levels in a computer(in hardware, operating system, software)Information in use copied from slower to faster storagetemporarilyFaster storage (cache) checked first to determine ifinformation is thereIf it is, information used directly from the cache (fast)If not, data copied to cache and used thereCache smaller than storage being cachedCache management important design problemCache size and replacement policyOperating System Concepts – 9th Edition1.11Silberschatz, Galvin and Gagne 2013

Direct Memory Access StructureUsed for high-speed I/O devices able to transmitinformation at close to memory speedsDevice controller transfers blocks of data from bufferstorage directly to main memory without CPUinterventionOnly one interrupt is generated per block, rather thanthe one interrupt per byteOperating System Concepts – 9th Edition1.12Silberschatz, Galvin and Gagne 2013

How a Modern Computer WorksA von Neumann architectureOperating System Concepts – 9th Edition1.13Silberschatz, Galvin and Gagne 2013

Computer-System ArchitectureMost systems use a single general-purpose processorMost systems have special-purpose processors as well, like devicecontrollersMultiprocessors systems growing in use and importanceAlso known as parallel systems, tightly-coupled systemsAdvantages include:1.Increased throughput2.Economy of scale3.Increased reliability – graceful degradation or fault toleranceTwo types:1.Asymmetric Multiprocessing – each processor is assigned aspecific task: boss and worker processors.2.Symmetric Multiprocessing – each processor performs all tasksOperating System Concepts – 9th Edition1.14Silberschatz, Galvin and Gagne 2013

Symmetric Multiprocessing ArchitectureOperating System Concepts – 9th Edition1.15Silberschatz, Galvin and Gagne 2013

A Dual-Core DesignMulti-chip and multicoreMulticore system is more efficient than multi-chip systemOn-chip communication is faster than between-chipcommunication.Operating System Concepts – 9th Edition1.16Silberschatz, Galvin and Gagne 2013

Clustered SystemsLike multiprocessor systems, but multiple systems working togetherUsually sharing storage via a storage-area network (SAN)Provides a high-availability service which survives failures Asymmetric clustering has one machine in hot-standby mode Symmetric clustering has multiple nodes running applications,monitoring each otherSome clusters are for high-performance computing (HPC) Applications must be written to use parallelizationOperating System Concepts – 9th Edition1.17Silberschatz, Galvin and Gagne 2013

Operating System StructureMultiprogramming (Batch system) needed for efficiencySingle user cannot keep CPU and I/O devices busy at all timesMultiprogramming organizes jobs (code and data) so CPU always has oneto executeA subset of total jobs in system is kept in memoryOne job selected and run via job schedulingWhen it has to wait (for I/O for example), OS switches to another jobTimesharing (multitasking) is logical extension in which CPU switches jobsso frequently that users can interact with each job while it is running, creatinginteractive computingResponse time should be 1 secondEach user has at least one program executing in memory processIf several jobs ready to run at the same time CPU schedulingIf processes don’t fit in memory, swapping moves them in and out to runVirtual memory allows execution of processes not completely in memoryOperating System Concepts – 9th Edition1.18Silberschatz, Galvin and Gagne 2013

Operating-System Operations (cont.)Dual-mode operation allows OS to protect itself and other systemcomponentsUser mode and kernel modeMode bit provided by hardware (e.g., CS register in CPU) Provides ability to distinguish when system is running user code orkernel code Some instructions designated as privileged, only executable in kernelmode System call changes mode to kernel, return from call resets it to userOperating System Concepts – 9th Edition1.19Silberschatz, Galvin and Gagne 2013

Operating System ServicesOperating systems provide an environment for execution of programsand services to programs and usersOne set of operating-system services provides functions that arehelpful to the user:User interface - Almost all operating systems have a userinterface (UI). Varies between Command-Line (CLI), Graphics UserInterface (GUI), BatchProgram execution - The system must be able to load aprogram into memory and to run that program, end execution,either normally or abnormally (indicating error)I/O operations - A running program may require I/O, which mayinvolve a file or an I/O deviceOperating System Concepts – 9th Edition1.20Silberschatz, Galvin and Gagne 2013

Operating System Services (Cont.)One set of operating-system services provides functions that are helpful tothe user (Cont.):File-system manipulation - The file system is of particular interest.Programs need to read and write files and directories, create and deletethem, search them, list file Information, permission management.Communications – Processes may exchange information, on the samecomputer or between computers over a network Communications may be via shared memory or through messagepassing (packets moved by the OS)Error detection – OS needs to be constantly aware of possible errors May occur in the CPU and memory hardware, in I/O devices, in userprogram For each type of error, OS should take the appropriate action toensure correct and consistent computing Debugging facilities can greatly enhance the user’s andprogrammer’s abilities to efficiently use the systemOperating System Concepts – 9th Edition1.21Silberschatz, Galvin and Gagne 2013

Operating System Services (Cont.)Another set of OS functions exists for ensuring the efficient operation of thesystem itself via resource sharingResource allocation - When multiple users or multiple jobs runningconcurrently, resources must be allocated to each of them Many types of resources - CPU cycles, main memory, file storage,I/O devices.Accounting - To keep track of which users use how much and whatkinds of computer resourcesProtection and security - The owners of information stored in amultiuser or networked computer system may want to control use ofthat information, concurrent processes should not interfere with eachother Protection involves ensuring that all access to system resources iscontrolled Security of the system from outsiders requires user authentication,extends to defending external I/O devices from invalid accessattemptsOperating System Concepts – 9th Edition1.22Silberschatz, Galvin and Gagne 2013

A View of Operating System ServicesOperating System Concepts – 9th Edition1.23Silberschatz, Galvin and Gagne 2013

System CallsProgramming interface to the services provided by the OSTypically written in a high-level language (C or C )Mostly accessed by programs via a high-levelApplication Programming Interface (API) rather thandirect system call useThree most common APIs are Windows API for Windows,POSIX API for POSIX-based systems (including virtuallyall versions of UNIX, Linux, and Mac OS X), and Java APIfor the Java virtual machine (JVM)Operating System Concepts – 9th Edition1.24Silberschatz, Galvin and Gagne 2013

Example of System CallsSystem call sequence to copy the contents of one file to another fileOperating System Concepts – 9th Edition1.25Silberschatz, Galvin and Gagne 2013

System Call ImplementationTypically, a number associated with each system callSystem-call interface maintains a table indexed according tothese numbersThe system call interface invokes the intended system call in OSkernel and returns status of the system call and any return valuesThe caller need know nothing about how the system call isimplementedJust needs to obey API and understand what OS will do as aresult callMost details of OS interface hidden from programmer by API Managed by run-time support library (set of functions builtinto libraries included with compiler)Operating System Concepts – 9th Edition1.26Silberschatz, Galvin and Gagne 2013

API – System Call – OS RelationshipOperating System Concepts – 9th Edition1.27Silberschatz, Galvin and Gagne 2013

Operating System Design and ImplementationDesign and Implementation of OS not “solvable”, but someapproaches have proven successfulInternal structure of different Operating Systems can vary widelyStart the design by defining goals and specificationsHighest level: affected by choice of hardware, type of systemThe requirements can be divided into User and System goalsUser goals – operating system should be convenient to use,easy to learn, reliable, safe, and fastSystem goals – operating system should be easy to design,implement, and maintain, as well as flexible, reliable, error-free,and efficientOperating System Concepts – 9th Edition1.28Silberschatz, Galvin and Gagne 2013

Operating System Design and Implementation (Cont.)Important principle to separatePolicy: What will be done?Mechanism: How to do it?Mechanisms determine how to do something, policies decidewhat will be doneThe separation of policy from mechanism is a very importantprinciple, it allows maximum flexibility if policy decisions are tobe changed later (example – timer)Specifying and designing an OS is highly creative task ofsoftware engineeringOperating System Concepts – 9th Edition1.29Silberschatz, Galvin and Gagne 2013

Operating System StructureGeneral-purpose OS is very large programVarious ways to structure onesSimple structure – MS-DOSMore complex -- UNIXLayered – an abstrcationMicrokernel -MachOperating System Concepts – 9th Edition1.30Silberschatz, Galvin and Gagne 2013

Traditional UNIX System StructureBeyond simple but not fully layeredOperating System Concepts – 9th Edition1.31Silberschatz, Galvin and Gagne 2013

Microkernel System dwareOperating System Concepts – 9th Edition1.32Silberschatz, Galvin and Gagne 2013

Process ConceptAn operating system executes a variety of programs:Batch system – jobsTime-shared systems – user programs or tasksTextbook uses the terms job and process almost interchangeablyProcess – a program in execution; process execution mustprogress in sequential fashionMultiple partsThe program code, also called text sectionCurrent activity including program counter, processorregistersStack containing temporary data Function parameters, return addresses, local variablesData section containing global variablesHeap containing memory dynamically allocated during run timeOperating System Concepts – 9th Edition1.33Silberschatz, Galvin and Gagne 2013

Process Concept (Cont.)Program is passive entity stored on disk (executable file),process is activeProgram becomes process when executable file loaded intomemoryExecution of program started via GUI mouse clicks, commandline entry of its name, etcOne program can be several processesConsider multiple users executing the same programOperating System Concepts – 9th Edition1.34Silberschatz, Galvin and Gagne 2013

Process StateAs a process executes, it changes statenew: The process is being createdrunning: Instructions are being executedwaiting: The process is waiting for some event to occurready: The process is waiting to be assigned to a processorterminated: The process has finished executionOperating System Concepts – 9th Edition1.35Silberschatz, Galvin and Gagne 2013

Diagram of Process StateOperating System Concepts – 9th Edition1.36Silberschatz, Galvin and Gagne 2013

Process Control Block (PCB)Information associated with each process(also called task control block)Process state – running, waiting, etcProgram counter – location ofinstruction to next executeCPU registers – contents of all processcentric registersCPU scheduling information- priorities,scheduling queue pointersMemory-management information –memory allocated to the processAccounting information – CPU used,clock time elapsed since start, timelimitsI/O status information – I/O devicesallocated to process, list of open filesOperating System Concepts – 9th Edition1.37Silberschatz, Galvin and Gagne 2013

CPU Switch From Process to ProcessOperating System Concepts – 9th Edition1.38Silberschatz, Galvin and Gagne 2013

Process SchedulingMaximize CPU use, quickly switch processes onto CPU fortime sharingProcess scheduler selects among available processes fornext execution on CPUMaintains scheduling queues of processesJob queue – set of all processes in the systemReady queue – set of all processes residing in mainmemory, ready and waiting to executeDevice queues – set of processes waiting for an I/O deviceProcesses migrate among the various queuesOperating System Concepts – 9th Edition1.39Silberschatz, Galvin and Gagne 2013

Ready Queue And Various I/O Device QueuesOperating System Concepts – 9th Edition1.40Silberschatz, Galvin and Gagne 2013

Representation of Process SchedulingQueueing diagram represents queues, resources, flowsOperating System Concepts – 9th Edition1.41Silberschatz, Galvin and Gagne 2013

SchedulersShort-term scheduler (or CPU scheduler) – selects which process shouldbe executed next and allocates CPUSometimes the only scheduler in a systemShort-term scheduler is invoked frequently (milliseconds) (must befast)Long-term scheduler (or job scheduler) – selects which processes shouldbe brought into the ready queueLong-term scheduler is invoked infrequently (seconds, minutes) (may be slow)The long-term scheduler controls the degree of multiprogrammingProcesses can be described as either:I/O-bound process – spends more time doing I/O than computations,many short CPU burstsCPU-bound process – spends more time doing computations; few verylong CPU burstsLong-term scheduler strives for good process mixOperating System Concepts – 9th Edition1.42Silberschatz, Galvin and Gagne 2013

Context SwitchWhen CPU switches to another process, the system must savethe state of the old process and load the saved state for thenew process via a context switchContext of a process represented in the PCBContext-switch time is overhead; the system does no usefulwork while switchingThe more complex the OS and the PCB the longer thecontext switchTime dependent on hardware supportSome hardware provides multiple sets of registers per CPU multiple contexts loaded at onceOperating System Concepts – 9th Edition1.43Silberschatz, Galvin and Gagne 2013

Operations on ProcessesSystem must provide mechanisms for:process creation,process termination,and so on as detailed nextOperating System Concepts – 9th Edition1.44Silberschatz, Galvin and Gagne 2013

Process CreationParent process create children processes, which, in turncreate other processes, forming a tree of processesGenerally, process identified and managed via a processidentifier (pid)Resource sharing optionsParent and children share all resourcesChildren share subset of parent’s resourcesParent and child share no resourcesExecution optionsParent and children execute concurrentlyParent waits until children terminateOperating System Concepts – 9th Edition1.45Silberschatz, Galvin and Gagne 2013

Process Creation (Cont.)Address spaceChild duplicate of parent (has the same program as theparent)Child has a program loaded into itUNIX examplesfork() system call creates new process. The new processconsists of a copy of the address space of the originalprocess.exec() system call used after a fork() to replace theprocess’ memory space with a new programmove itself off the ready queue until the termination of the childOperating System Concepts – 9th Edition1.46Silberschatz, Galvin and Gagne 2013

C Program Forking Separate ProcessThe only difference isthat the value of pid forthe child process iszero, while that for theparent is the actual pidof the child process.Operating System Concepts – 9th Edition1.47Silberschatz, Galvin and Gagne 2013

Process TerminationProcess executes last statement and then asks the operatingsystem to delete it using the exit() system call.Returns status data from child to parent (via wait())Process’ resources are deallocated by operating systemParent may terminate the execution of children processes usingthe abort() system call. Some reasons for doing so:Child has exceeded allocated resourcesTask assigned to child is no longer requiredThe parent is exiting and the operating systems does notallow a child to continue if its parent terminatesOperating System Concepts – 9th Edition1.48Silberschatz, Galvin and Gagne 2013

Process TerminationSome operating systems do not allow child to exist if its parent hasterminated.

Operating System Concepts –9thEdition 1.14 Silberschatz, Galvin and Gagne ©2013 Computer-System Architecture Most systems use a single general-purpose processor Most systems have special-purpose processors as well, like device controllers Multiprocessorssystems growing in use and importanc