What is the output generated by this program? Please assume that each executed print statement completes, e.g., assume that each print is followed by an.

Slides:



Advertisements
Similar presentations
Operating Systems Semaphores II
Advertisements

HW/Study Guide. Synchronization Make sure you understand the HW problems!
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
Virtual Memory Management G. Anuradha Ref:- Galvin.
Operating Systems COMP 4850/CISG 5550 Processes Introduction to Threads Dr. James Money.
15-213/ Intro to Computer Systems by btan with reference to Spring 10’s slides.
Processes CSCI 444/544 Operating Systems Fall 2008.
Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 121 Today’s class Operating System Machine Level.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CSSE Operating Systems
7/3/20151 Announcement (No deadline extension for the rest of quarter) Project 2 final deadline is Tuesday midnight May 19 Project 0 resubmission for autograding.
The Programming Interface. Main Points Creating and managing processes – fork, exec, wait Performing I/O – open, read, write, close Communicating between.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
What is the output generated by this program? (Assume that there are no errors or failures.) [30 pts] CPS 310 final exam, 12/12/2014 Your name please:
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
(a) Alice and Bob are back together. Today Alice wants to send Bob a message that is secret and also authenticated, so that Bob "knows" the message came.
(a) What is the output generated by this program? In fact the output is not uniquely defined, i.e., it is not necessarily the same in each execution. What.
Introduction to Threads CS240 Programming in C. Introduction to Threads A thread is a path execution By default, a C/C++ program has one thread called.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Consider the Java code snippet below. Is it a legal use of Java synchronization? What happens if two threads A and B call get() on an object supporting.
Concurrent Programming. Concurrency  Concurrency means for a program to have multiple paths of execution running at (almost) the same time. Examples:
(a) What is the output generated by this program? In fact the output is not uniquely defined, i.e., it is not always the same. So please give three examples.
CS162B: Pipes Jacob T. Chan. Pipes  These allow output of one process to be the input of another process  One of the oldest and most basic forms of.
(a) What is the output generated by this program? In fact the output is not uniquely defined, i.e., it is not always the same. So please give three examples.
CPS110: Implementing threads Landon Cox. Recap and looking ahead Hardware OS Applications Where we’ve been Where we’re going.
CS 153 Design of Operating Systems Spring 2015 Lecture 5: Processes and Threads.
Consider the program fragment below left. Assume that the program containing this fragment executes t1() and t2() on separate threads running on separate.
Synchronization and semaphores Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Solutions for the First Quiz COSC 6360 Spring 2014.
(a) What is the output generated by this program? In fact the output is not uniquely defined, i.e., it is not necessarily the same in each execution. What.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 14 Threads 2 Read Ch.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
Project 2: User Programs Abdelmounaam Rezgui Acknowledgment: The content of some slides is partly taken from Josh Wiseman’s presentation.
Consider the Java code snippet below. Is it a legal use of Java synchronization? What happens if two threads A and B call get() on an object supporting.
Operating Systems CMPSC 473 Signals, Introduction to mutual exclusion September 28, Lecture 9 Instructor: Bhuvan Urgaonkar.
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
2.1 Processes  process = abstraction of a running program  multiprogramming = CPU switches from running program to running program  pseudoparallelism.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
/50 /60 /40 /30 A Tale of Two Clients
CPS 310 midterm exam #1, 2/19/2016 Your name please: ___________________ NetID:___________ /40 /40 /50.
Process Management Process Concept Why only the global variables?
Virtual Memory - Part II
Advanced OS Concepts (For OCR)
CS703 - Advanced Operating Systems
Chapter 9: Virtual Memory
Applied Operating System Concepts
Processes in Unix, Linux, and Windows
Chapter 9: Virtual-Memory Management
Recitation 14: Proxy Lab Part 2
Processes in Unix, Linux, and Windows
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process Creation Process Termination
Chapter 30 Condition Variables
Practical Session 9, Memory
Dr. Mustafa Cem Kasapbaşı
Tutorial: The Programming Interface
Semester Review Brian Kocoloski
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix, Linux, and Windows
CS510 Operating System Foundations
Processes Creation and Threads
CSE 153 Design of Operating Systems Winter 2019
Synchronization and semaphores
Presentation transcript:

What is the output generated by this program? Please assume that each executed print statement completes, e.g., assume that each print is followed by an “fflush(stdout)”. Be sure to consider whether the output is uniquely defined. You should presume that no errors occur. [30 points] CPS 310 first midterm exam, 10/6/2014 Your name please: Part 1. More fun with fork and exec* Optional: explain. I will consider your explanation for partial credit if you need it. main(int argc, char * argv[]) { printf(“0”); fork(); printf(“1”); execvp(argv[0], argv); printf(“2”); } /30 /40 /60 /40 /200

synchronized void PingPong() { while(true) { computeSomething(); notify(); wait(); } These questions deal with the “ping pong” example discussed in class. PingPong is implemented in Java roughly like the code on the right: CPS 310 first midterm exam, 10/6/2014, page 2 of 5 Part 2. Ping Pong (a) Suppose that multiple threads call this PingPong method on the same object concurrently. Describe the resulting behavior. I am looking for 1-3 sentences summarizing any constraints on the execution ordering. [15 points] (b) Does it matter if we change the order of the statements in the loop? What if computeSomething() is between the notify and the wait, or after the wait? What if we change the order of the notify and wait? [15 points]

Part 3. Servers and threads and events Answer each of these short questions using a word, or a phrase, or a sentence, or maybe two. [10 points each] (a) It has been said that an event-driven design pattern is better than using multiple threads to structure a server. I have argued in class that it is best to use both models together. Why is it important for a server to have multiple threads, even in a system with full support for event-driven programming (e.g., with non-blocking system calls)? (b) In a ThreadPool implementation, how does a sleeping worker thread "know" that it has been selected to handle the next request or event? What wakes it up? (c) The main thread of an Android application runs an event-driven pattern. If the app has a task to perform that is long-running or that must block, the main thread can start an AsyncTask to do the work. In this case, how does the AsyncTask report its progress back to the main thread? (d) An atomic instruction performs an indivisible read-modify-write on memory: in particular a thread can use an atomic instruction to set a lock variable safely, indicating that the lock is busy. In this case, how does a thread “know” if it lost the race and the lock is already busy? What should the thread do if the lock is busy? CPS 310 first midterm exam, 10/6/2014, page 3 of 5

Part 4. dsh These questions pertain to your shell project code (dsh). If you don’t remember the details of what your group did then make something up that sounds good. Please confine your answers to the space provided. [12 points each] (a)What would happen if you type the command “dsh” to your dsh, i.e., to “run dsh under itself”? Will it work? What could go wrong? (b) Briefly summarize how your dsh implemented input/output redirection (<>). What system calls did you call from the parent for this purpose? What system calls did you call from the child for this purpose? (c) For pipeline jobs like cat | cat | cat, what would happen if a child writes into a pipe before the next downstream child (the process that is supposed to read from that pipe) has started? Can this scenario ever occur? (d) For pipeline jobs like cat | cat | cat, what would happen if a child reads from a pipe before the next upstream child (the process that is supposed to write to that pipe) has started? Can this scenario ever occur? (e) For pipeline jobs like cat | cat | cat, how does a middle child’s setup differ from the processes at the ends of the pipeline? How does a process “know” that it is the middle child? CPS 310 first midterm exam, 10/6/2014, page 4 of 5

Part 5. Maps These questions pertain to a “classic” 32-bit virtual memory system, with linear page tables and 4KB pages. Answer each question with an ordered sequence of events. Feel free to draw on the back page: otherwise, I am looking for as much significant detail as you can fit in the space provided. [10 points each] (a)Suppose that a running thread issues a load instruction on the following 32-bit virtual address: 0x Suppose that the address misses in the TLB. How does the hardware locate the page table entry for the page? Please show your math. (b) Suppose further that the page table entry is “empty”: it does not contain a valid translation. The hardware cannot complete the requested virtual memory reference. What does it do? (c) How does the operating system determine if the reference is legal, i.e., how does it determine whether or not the reference results from an error in the program? (d) If the reference is legal, how does the operating system find the data for the page? Is it possible that the page already resides in memory? (Why or why not?) You may presume that the requested virtual page has never been modified. CPS 310 first midterm exam, 10/6/2014, page 5 of 5