New version page

CORNELL CS 414 - CS 414 Review

Documents in this Course
Security

Security

49 pages

Processes

Processes

24 pages

Deadlocks

Deadlocks

57 pages

Threads

Threads

5 pages

Threads

Threads

29 pages

Deadlocks

Deadlocks

36 pages

Load more
Upgrade to remove ads

This preview shows page 1-2-3-4-25-26-27-51-52-53-54 out of 54 pages.

Save
View Full Document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience

Upgrade to remove ads
Unformatted text preview:

CS 414 ReviewGoals for TodayOperating System: DefinitionWhat is in an OS?Crossing Protection BoundariesWhat is a process?Process State TransitionsContext SwitchThreads and ProcessesSchedulersCPU Scheduling AlgorithmsCPU Scheduling MetricsRace conditionsThe Fundamental Issue: AtomicityCritical Section ProblemSolution StructureSolution RequirementsSemaphoresSemaphore TypesMutexes and SynchronizationMonitorsSynchronization Using MonitorsTypes of MonitorsDeadlocksFour Conditions for DeadlockDealing with DeadlocksSafe StateBanker’s AlgorithmBasic AlgorithmMemory Management IssuesScheme 1: Load-time LinkingScheme 2: Execution-time LinkingSegmentationMapping SegmentsFragmentationPagingMapping PagesPaging + SegmentationWhat is virtual memory?Virtual MemoryPage FaultsPage Replacement AlgorithmsThrashingApproach 1: Working SetWorking SetsApproach 2: Page Fault FrequencyAllocation and deallocationMemory AllocatorWhat happens on free?Design featuresMalloc & OS memory managementAnnouncementsGrade distributionHand back prelimsCS 414 Review2Goals for Today•Review half the book–Make sure intuition is clear–Ask questions•For more detailed information–Use past slides, “redo” homework and prelims3Operating System: DefinitionDefinitionAn Operating System (OS) provides a virtual machine on top of the real hardware, whose interface is more convenient than the raw hardware interface.HardwareApplicationsOperating SystemOS interfacePhysical machine interfaceAdvantagesEasy to use, simpler to code, more reliable, more secure, …You can say: “I want to write XYZ into file ABC”4What is in an OS?Operating System ServicesInterrupts, Cache, Physical Memory, TLB, Hardware DevicesGeneric I/O File SystemMemory ManagementProcess ManagementVirtual MemoryNetworkingNamingAccess ControlWindowing & graphicsWindowing & GfxApplicationsOS InterfacePhysical m/c IntfDevice DriversShellsSystem UtilsQuake Sql ServerLogical OS Structure5Crossing Protection Boundaries•User calls OS procedure for “privileged” operations•Calling a kernel mode service from user mode program:–Using System Calls–System Calls switches execution to kernel modeUser process System CallTrapMode bit = 0Save Caller’s state Execute system call Restore stateReturnMode bit = 1Resume processUser ModeMode bit = 1Kernel ModeMode bit = 06What is a process?•The unit of execution•The unit of scheduling•Thread of execution + address space•Is a program in execution–Sequential, instruction-at-a-time execution of a program.The same as “job” or “task” or “sequential process”7Process State TransitionsNewReady RunningExitWaitingadmittedinterruptI/O or event waitI/O or event completiondispatchdoneProcesses hop across states as a result of:• Actions they perform, e.g. system calls• Actions performed by OS, e.g. rescheduling• External actions, e.g. I/O8Context Switch•For a running process–All registers are loaded in CPU and modified•E.g. Program Counter, Stack Pointer, General Purpose Registers•When process relinquishes the CPU, the OS–Saves register values to the PCB of that process•To execute another process, the OS–Loads register values from PCB of that processContext SwitchProcess of switching CPU from one process to anotherVery machine dependent for types of registers9Threads and Processes•Most operating systems therefore support two entities:–the process, •which defines the address space and general process attributes–the thread, •which defines a sequential execution stream within a process•A thread is bound to a single process. –For each process, however, there may be many threads.•Threads are the unit of scheduling •Processes are containers in which threads execute10Schedulers•Process migrates among several queues–Device queue, job queue, ready queue•Scheduler selects a process to run from these queues•Long-term scheduler: –load a job in memory–Runs infrequently•Short-term scheduler:–Select ready process to run on CPU–Should be fast•Middle-term scheduler–Reduce multiprogramming or memory consumption11CPU Scheduling Algorithms•FCFS•LIFO•SJF•SRTF•Priority Scheduling•Round Robin•Multi-level Queue•Multi-level Feedback Queue12CPU Scheduling Metrics•CPU utilization: percentage of time the CPU is not idle•Throughput: completed processes per time unit•Turnaround time: submission to completion•Waiting time: time spent on the ready queue•Response time: response latencyRace conditions•Definition: timing dependent error involving shared state –Whether it happens depends on how threads scheduled•Hard to detect:–All possible schedules have to be safe •Number of possible schedule permutations is huge•Some bad schedules? Some that will work sometimes?–they are intermittent•Timing dependent = small changes can hide bug14The Fundamental Issue: Atomicity•Our atomic operation is not done atomically by machine–E.g. incrementing a variable by one (i++) is three machine instructions (load, increment, store).–Process can be interrupted between any machine instruction•Atomic Unit: instruction sequence guaranteed to execute indivisibly–Also called “critical section” (CS)When 2 processes want to execute their Critical Section,–One process finishes its CS before other is allowed to enter15Critical Section Problem•Problem: Design a protocol for processes to cooperate, such that only one process is in its critical section–How to make multiple instructions seem like one?Processes progress with non-zero speed, no assumption on clock speedUsed extensively in operating systems:Queues, shared variables, interrupt handlers, etc.Process 1Process 2CS1Time CS216Solution StructureShared vars: Initialization:Process:. . . . . . Entry SectionCritical SectionExit SectionAdded to solve the CS problem17Solution Requirements•Mutual Exclusion–Only one process can be in the critical section at any time•Progress–Decision on who enters CS cannot be indefinitely postponed•No deadlock•Bounded Waiting–Bound on #times others can enter CS, while I am waiting•No livelock•Also efficient (no extra resources), fair, simple, …18Semaphores•Non-negative integer with atomic increment and decrement•Integer ‘S’ that (besides init) can only be modified by:–P(S) or S.wait(): decrement or block if already 0–V(S) or S.signal(): increment and wake up process if any•These operations are atomicsemaphore


View Full Document
Download CS 414 Review
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CS 414 Review and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CS 414 Review 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?