CSE 451: Operating Systems Section 5 Midterm review.

Slides:



Advertisements
Similar presentations
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Chapter 3 Process Description and Control
Basic Operating System Concepts
CAS3SH3 Midterm Review. The midterm 50 min, Friday, Feb 27 th Materials through CPU scheduling closed book, closed note Types of questions: True & False,
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
CPSC 4650 Operating Systems Chapter 6 Deadlock and Starvation
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1 Concurrency: Deadlock and Starvation Chapter 6.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Process Description and Control A process is sometimes called a task, it is a program in execution.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Operating Systems CSE 411 CPU Management Sept Lecture 11 Instructor: Bhuvan Urgaonkar.
CS 153 Design of Operating Systems Spring 2015 Midterm Review.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Threads, Thread management & Resource Management.
CS 153 Design of Operating Systems Spring 2015 Lecture 11: Scheduling & Deadlock.
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Chapter 3 Process Description and Control
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Cpr E 308 Spring 2004 Real-time Scheduling Provide time guarantees Upper bound on response times –Programmer’s job! –Every level of the system Soft versus.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
Operating Systems Part III: Process Management (Deadlocks)
Copyright ©: University of Illinois CS 241 Staff1 Threads Systems Concepts.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Discussion Week 2 TA: Kyle Dewey. Overview Concurrency Process level Thread level MIPS - switch.s Project #1.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Processes & Threads Introduction to Operating Systems: Module 5.
Threads, Thread management & Resource Management.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program.
4.1 Introduction to Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Introduction to operating systems What is an operating system? An operating system is a program that, from a programmer’s perspective, adds a variety of.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Tutorial 2: Homework 1 and Project 1
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Processes and threads.
Process Management Process Concept Why only the global variables?
Background on the need for Synchronization
Section 10: Last section! Final review.
Real-time Software Design
HW & Systems: Operating Systems IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, October 22, 2013 Carolyn Seaman University of Maryland, Baltimore.
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Midterm review: closed book multiple choice chapters 1 to 9
Process Description and Control
Lecture 2 Part 2 Process Synchronization
CSE 451: Operating Systems
Threads Chapter 4.
February 5, 2004 Adrienne Noble
CS333 Intro to Operating Systems
CSE 153 Design of Operating Systems Winter 2019
EECE.4810/EECE.5730 Operating Systems
CSE 542: Operating Systems
CSE 542: Operating Systems
CS444/544 Operating Systems II Scheduler
Presentation transcript:

CSE 451: Operating Systems Section 5 Midterm review

Kernel/userspace separation  Userspace processes cannot interact directly with hardware (non-privileged mode)  Attempting to execute a system call instruction causes a trap to the kernel (privileged mode), which handles the request  Why is it necessary to have both privileged and non- privileged mode?  How is privileged mode enforced, and how do virtual machine monitors work inside this model? 5/2/132

IO from userspace  Userspace processes interact with disks and other devices via open(), read(), write(), and other system calls  Multiple levels of abstraction: kernel presents file system to userspace, and device drivers present a (mostly) unified interface to kernel code  What are the benefits and drawbacks of designing a system in this way? 5/2/133

Monolithic and microkernels  Monolithic kernels encapsulate all aspects of functionality aside from hardware and user programs  Pro: Low communication cost, since everything is in the kernel’s address space  Cons: Millions of lines of code, continually expanding, no isolation between modules, security  Microkernels separate functionality into separate modules that each expose an API  Services as servers  Why? How? 5/2/134

Processes versus threads  Processes have multiple pieces of state associated with them  Program counter, registers, virtual memory, open file handles, mutexes, registered signal handlers, the text and data segment of the program, and so on  Total isolation, mediated by the kernel  Threads are “lightweight” versions of processes  Which pieces of state listed above do threads not maintain individually? 5/2/135

Process creation  fork() : create and initialize a new process control block  Copy resources of current process but assign a new address space  Calls to fork() return twice—once to parent (with pid of child process) and once to child  What makes this system call fast even for large processes? vfork() versus copy-on-write  exec() : stop the current process and begin execution of a new one  Existing process image is overwritten  No new process is created  Is there a reason why fork() and exec() are separate system calls? 5/2/136

Threads  How is a kernel thread different from a userspace thread?  Kernel thread: managed by OS, can run on a different CPU core than parent process  Userspace thread: managed by process/thread library, provides concurrency but no parallelism (can’t have two userspace threads within a process executing instructions at the same time)  CPU sharing  Threads share CPU either implicitly (via preemption) or explicitly via calls to yield()  What happens when a userspace thread blocks on IO? 5/2/137

Synchronization  Critical sections are sequences of instructions that may produce incorrect behavior if two threads interleave or execute them at the same time  E.g. the banking example that everyone loves to use  Mutexes are constructs that enforce mutual exclusion  mutex.lock()/acquire() : wait until no other thread holds the lock and then acquire it  mutex.unlock()/release() : release the Locken!  Mutexes rely on hardware support such as an atomic test- and-set instruction or being able to disable interrupts (why?) 5/2/138

Synchronization constructs  Spinlocks are mutexes where lock() spins in a loop until the lock can be acquired  High CPU overhead, but no expensive context switches are necessary  In what type of scenario are spinlocks useful?  Semaphores are counters that support atomic increments and decrements  P(sem) : block until semaphore count is positive, then decrement and continue  V(sem) : increment semaphore count  How are semaphores different from spinlocks? 5/2/139

Synchronization constructs  Condition variables associated with mutexes allow threads to wait for events and to signal when they have occurred  cv.wait(mutex* m) : release mutex m and block until the condition variable cv is signaled. m will be held when wait() returns  cv.signal() : unblock one of the waiting threads. m must be held during the call but released sometime afterward  Why is it necessary to associate a mutex with a condition variable?  What happens if signal() is invoked before a call to wait() ? 5/2/1310

Monitors  Monitors are souped-up condition variables that support enter(), exit(), wait(), signal(),broadcast() routines  When one thread enters a monitor, no other thread can enter until the first thread exits  The exception is that a thread can wait on a condition after entering a monitor, permitting another thread to enter (which will potentially signal and unblock the first thread)  Hoare monitors: signal() causes a waiting thread to run immediately  Mesa monitors: signal() returns to the caller and a waiting thread will unblock some time later 5/2/1311

Deadlock  Is this deadlock? How do we fix it? Thread 1:Thread 2:Thread 3: lock(A)lock(B)lock(C) lock(B)lock(C)lock(A) Do_thing1()Do_thing2() Do_thing3() unlock(B)unlock(C)unlock(A) unlock(A)unlock(B)unlock(C) 5/2/1312

Deadlock  What is an example of deadlock?  Methods for preventing and avoiding deadlock  Have threads block until all required locks are available  Have all threads acquire locks in the same global ordering  Run banker’s algorithm to simulate what would happen if this thread and others made maximum requests: no deadlock = continue, deadlock = block and check again later  Can resolve deadlock by breaking cycles in the dependency graph: choose a thread, kill it, and release its locks  What are the potential problems related to doing this? 5/2/1313

Scheduling  Operating systems share CPU time between processes by context-switching between them  In systems that support preemption, each process runs for a certain quantum (time slice) before the OS switches contexts to another process  Which process runs next depends on the scheduling policy  Scheduling policies can attempt to maximize CPU utilization or throughput or minimize response time, for example  There are always tradeoffs between performance and fairness 5/2/1314

Scheduling laws  Utilization law: utilization is constant regardless of scheduling policy as long as the workload can be processed  Little’s law: the better the average response time, the fewer processes there will be in the scheduling system  Kleinrock’s conservation law: improving the response time of one class of task by increasing its priority hurts the response time of at least one other class of task 5/2/1315

Scheduling policies  FIFO: first in first out  SPT: shortest processing time first  RR: round robin  Any of these can be combined with a notion of Priority  How to avoid starvation? Lottery is one option  What are the benefits and drawbacks of each type of scheduling policy? 5/2/1316