Operating Systems ECE344 Midterm review Ding Yuan

Slides:



Advertisements
Similar presentations
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.
Advertisements

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: Process Synchronization
Background Concurrent access to shared data can lead to inconsistencies Maintaining data consistency among cooperating processes is critical What is wrong.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
Cpr E 308 Spring 2004 Recap for Midterm Introductory Material What belongs in the OS, what doesn’t? Basic Understanding of Hardware, Memory Hierarchy.
The Kernel Abstraction. Challenge: Protection How do we execute code with restricted privileges? – Either because the code is buggy or if it might be.
Synchronization. Shared Memory Thread Synchronization Threads cooperate in multithreaded environments – User threads and kernel threads – Share resources.
Operating Systems ECE344 Ding Yuan Synchronization (I) -- Critical region and lock Lecture 5: Synchronization (I) -- Critical region and lock.
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.
CS444/CS544 Operating Systems Synchronization 2/16/2006 Prof. Searleman
CS533 Concepts of Operating Systems Class 3 Monitors.
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
CS533 Concepts of Operating Systems Class 3 Monitors.
Avishai Wool lecture Priority Scheduling Idea: Jobs are assigned priorities. Always, the job with the highest priority runs. Note: All scheduling.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Synchronization CSCI 444/544 Operating Systems Fall 2008.
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
CS252: Systems Programming Ninghui Li Final Exam Review.
CS 153 Design of Operating Systems Spring 2015 Midterm Review.
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.
Chapter 1 Computer System Overview Sections 1.1 to 1.6 Instruction exe cution Interrupt Memory hierarchy Cache memory Locality: spatial and temporal Problem.
CSE 451: Operating Systems Section 5 Midterm review.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 5: Process Synchronization.
CPS110: Implementing threads Landon Cox. Recap and looking ahead Hardware OS Applications Where we’ve been Where we’re going.
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.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
CSE 153 Design of Operating Systems Winter 2015 Lecture 5: Synchronization.
Operating Systems CMPSC 473 Signals, Introduction to mutual exclusion September 28, Lecture 9 Instructor: Bhuvan Urgaonkar.
CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
CPS110: Implementing threads on a uni-processor Landon Cox January 29, 2008.
Processes and threads.
CSE 120 Principles of Operating
CS 6560: Operating Systems Design
Sarah Diesburg Operating Systems COP 4610
CS703 – Advanced Operating Systems
Process Synchronization
Synchronization.
Section 10: Last section! Final review.
Chapter 5: Process Synchronization
Topic 6 (Textbook - Chapter 5) Process Synchronization
COMS Prelim 1 Review Session
Lecture 2 Part 2 Process Synchronization
Threads Chapter 5 2/17/2019 B.Ramamurthy.
Concurrency: Mutual Exclusion and Process Synchronization
Threads Chapter 5 2/23/2019 B.Ramamurthy.
CSE 451: Operating Systems Winter 2007 Module 6 Synchronization
February 5, 2004 Adrienne Noble
CSE 451: Operating Systems Autumn 2004 Module 6 Synchronization
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 451: Operating Systems Winter 2004 Module 6 Synchronization
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization
CS510 Operating System Foundations
CSE 153 Design of Operating Systems Winter 19
CSE 153 Design of Operating Systems Winter 2019
CS333 Intro to Operating Systems
Chapter 6: Synchronization Tools
CSE 451: Operating Systems Winter 2007 Module 6 Synchronization
CSE 451: Operating Systems Autumn 2009 Module 7 Synchronization
CS703 – Advanced Operating Systems
CSE 153 Design of Operating Systems Winter 2019
CSE 542: Operating Systems
CSE 542: Operating Systems
Sarah Diesburg Operating Systems CS 3430
Presentation transcript:

Operating Systems ECE344 Midterm review Ding Yuan Question: java thread? Ding Yuan

Ding Yuan, ECE344 Operating Systems Overview The midterm Architectural support for Oses Processes Threads Synchronization Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Midterm Date: Feb 24th, 2-4 PM Location: EX300 Covers material through synchronization Based upon lecture material and project No cheat sheets Please, do not cheat Do not copy from your neighbor You will be noticed No one involved will be happy, particularly the teaching staff Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Arch Support for OSes Why OS needs Arch support? Types of architecture support Manipulating privileged machine state Generating and handling events Events: Interrupts, exceptions, system calls, etc. Concurrency … Ding Yuan, ECE344 Operating Systems

Protected (privileged) Instructions What are protected instructions? Who gets to execute them? How does the CPU know whether they can be executed? Difference between user and kernel mode Why do they need to be privileged? What do they manipulate? Protected control registers Memory management I/O devices Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Q1 from midterm@2013W For each instruction below, is it a protected instruction? load instruction (read a value from memory into a register) (2 marks) (B) modify the PC register (program counter) (2 marks) (C) modify the SP register (stack pointer) (2 marks) (D) modify the register that controls kernel/user mode (2 marks) (E) direct access I/O device (2 marks) Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Events Events Synchronous: fault (exceptions), system calls Asynchronous: interrupts, software interrupt What are faults, and how are they handled? What are system calls, and how are they handled? What are interrupts, and how are they handled? How do I/O devices use interrupts? Timer interrupt, why? Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Processes What is a process? What is the difference between a process and a program? What is contained in a process? Ding Yuan, ECE344 Operating Systems

Process Data Structures Process Control Blocks (PCBs) What information does it contain? How is it used in a context switch? State queues What are process states? What is the process state graph? When does a process change state? How does the OS use queues to keep track of processes? Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Process Manipulation What does CreateProcess on NT do? What does fork() on Unix do? What does it mean for it to “return twice”? What does exec() on Unix do? How is it different from fork? How are fork and exec used to implement shells? Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Q4 from midterm@2013W You write a UNIX shell, but instead of calling fork() then exec() to launch a new job, you instead insert a subtle difference: the code first calls exec() and then calls fork() like the following: shell (..) { .. .. exec (cmd, args); fork(); } Does it work? What is the impact of this change to the shell, if any? (Explain) Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Threads What is a thread? What is the difference between a thread and a process? How are they related? Why are threads useful? What is the difference between user-level and kernel-level threads? What are the advantages/disadvantages of one over another? Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Q6 from midterm@2013W Assume you want to implement a web-server for YouTube by using multithreading, where each thread serves one incoming request by loading a video file from the disk. Assume the OS only provides the normal blocking read system call for disk reads, do you think user-level threads or kernel-level threads should be used? Why? Ding Yuan, ECE344 Operating Systems

Thread Implementation How are threads managed by the run-time system? Thread control blocks, thread queues What operations do threads support? Fork, yield, sleep, etc. What does thread_yield do? What is a context switch? What is the difference between non-preemptive scheduling and preemptive thread scheduling? Voluntary and involuntary context switches Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Synchronization Why do we need synchronization? Coordinate concurrent access to shared data structures Coordinate thread/process execution What can happen to shared data structures if synchronization is not used? Race condition Bank account example When are resources shared? Global variables, static objects Heap objects Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Mutual Exclusion What is mutual exclusion? What is a critical region? What guarantees do critical region provide? What are the requirements of critical regions? Mutual exclusion (safety) Progress (liveness) Bounded waiting (no starvation: liveness) No assumption of the CPU speed/number What are the mechanisms for building critical regions? Locks, semaphores, monitors, condition variables Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Locks What does Acquire do? What does Release do? What does it mean for Acquire/Release to be atomic? How can locks be implemented? Spinlocks Disable/enable interrupts Blocking (OS161) How does test-and-set work? What kind of lock does it implement? What are the limitations of using spinlocks, interrupts? Inefficient, interrupts turned off too long Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Q7 from midterm@2013W A spin lock acquire() can be implemented with a test-and-set instruction as follows: while (test-and-set(&lock->held) == 1) ; // spin Now a new lock acquire() is implemented as follows: 1: while (1) { 2: while (lock->held > 0) 3: ; // spin 4: if (test-and-set(&lock->held) == 0) 5: return; 6: } Does it work? How does it change the behavior of the lock compared to the first implementation? Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Semaphores What is a semaphore? What does P do? What does V do? How does a semaphore differ from a lock? What is the difference between a binary semaphore and a counting semaphore? When do threads block on semaphores? When are they woken up again? Using semaphores to solve synchronization problems Readers/Writers problem Bounded Buffers problem Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Monitors What is a monitor? Shared data Procedures Synchronization In what way does a monitor provide mutual exclusion? To what extent is it provided? How does a monitor differ from a semaphore? How does a monitor differ from a lock? What kind of support do monitors require? Language, run-time support Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems Condition Variables What is a condition variable used for? Coordinating the execution of threads Not mutual exclusion Operations What are the semantics of Wait? What are the semantics of Signal? What are the semantics of Broadcast? How are condition variables different from semaphores? Ding Yuan, ECE344 Operating Systems

Ding Yuan, ECE344 Operating Systems