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:

Slides:



Advertisements
Similar presentations
1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Advertisements

Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
Part IV: Memory Management
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.
Lab 9 CIS 370 Umass Dartmouth.  A pipe is typically used as a one-way communications channel which couples one related process to another.  UNIX deals.
HW/Study Guide. Synchronization Make sure you understand the HW problems!
Ch 7 B.
CSCC69: Operating Systems
Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
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 ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
A certain Duke professor likes to sleep in the Perfect Chair TM in his office when there are no students around. The professor wakes up when students visit.
CS 162 Discussion Section Week 3. Who am I? Mosharaf Chowdhury Office 651 Soda 4-5PM.
1 Processes and Pipes COS 217 Professor Jennifer Rexford.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Operating Systems Final Exam Review. Topics F Virtual Memory F File Systems F I/O Devices F Project 3: Macro Shell.
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 121 Today’s class Operating System Machine Level.
CS-3013 & CS-502, Summer 2006 Review Topics1 CS-3013 & CS-502 Operating Systems.
OS Spring’03 Introduction Operating Systems Spring 2003.
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.
Operating Systems Final Exam Review. Topics Paging Virtual Memory File Systems I/O Devices Project 3: Macro Shell.
CS533 - Concepts of Operating Systems
CS 603 Threads, Processes, and Agents March 18, 2002.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
CS 333 Introduction to Operating Systems Class 13 - Virtual Memory (3) Jonathan Walpole Computer Science Portland State University.
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.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 11 Case Study 2: Windows Vista Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
(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.
Consider the short (and useless) C program off to the right. Each of the variables {a, b, c} references an integer value that occupies some memory at runtime.
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.
(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.
30 October Agenda for Today Introduction and purpose of the course Introduction and purpose of the course Organization of a computer system Organization.
(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.
CE Operating Systems Lecture 10 Processes and process management in Linux.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
IPC Programming. Process Model Processes can be organized into a parent-child hierarchy. Consider the following example code: /* */
Consider the program fragment below left. Assume that the program containing this fragment executes t1() and t2() on separate threads running on separate.
This exam has six parts, each of which contains five short questions. All questions are equally weighted at 10 points each (300 points total). Please write.
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.
Operating Systems Process Creation
(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.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
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.
Consider the short (and useless) C program off to the right. Each of the variables {a, b, c} references an integer value that occupies some memory at runtime.
Week 10 March 10, 2004 Adrienne Noble. Important Dates Project 4 due tomorrow (Friday) Final Exam on Tuesday, March 16, 2:30- 4:20pm.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Threads prepared and instructed by Shmuel Wimer Eng. Faculty, Bar-Ilan University 1July 2016Processes.
Operating Systems Review ENCE 360.
/50 /60 /40 /30 A Tale of Two Clients
CPS 310 midterm exam #1, 2/19/2016 Your name please: ___________________ NetID:___________ /40 /40 /50.
Chapter 3: Process Concept
Processes Overview: Process Concept Process Scheduling
Section 10: Last section! Final review.
Applied Operating System Concepts
Chapter 4: Processes Process Concept Process Scheduling
CGS 3763 Operating Systems Concepts Spring 2013
Processes in Unix, Linux, and Windows
CS510 Operating System Foundations
Operating Systems Lecture 1.
First slide Rest of project 2 due next Friday Today:
CS510 Operating System Foundations
Today’s agenda ~10min: file system (UNIX) ~1hr: final review + Q&A
CSE 153 Design of Operating Systems Winter 2019
Presentation transcript:

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: Part 1. Fun with forks Optional: briefly justify/explain your answer (for partial credit if your answer is wrong). int main() { int i = 1; if (fork() != 0) { i = i + 1; if (fork() != 0) exit(0); } fork(); printf("%d\n", i); } /40 /30 To celebrate completing my five straight semesters of CPS 310, and in keeping with the holiday spirit, the theme of today’s exam is A Few of My Favorite Things. These are some of my favorite problems from recent exams. So if you studied the recent exams, then you hit the jackpot. (Of course I may have changed them slightly here and there.) / 300 /50 /60

Part 2. Fixing the plumbing For some command lines the shell (e.g., dsh) spawns two child processes connected by a pipe. The following pseudocode proposes sequences of system calls for the parent shell and for each child to set up the pipe. Naturally, the sequences are incorrect. Point out three key errors in the sequences. For each error, write a sentence or two explaining why it is wrong and how to fix it. [30 points] Extra credit: estimate how many hours of sleep each error will cost you. Justify your answer without reference to “tcsetpgrp” or “setpgid”. parent fork(); wait*(…); fork(); wait*(…); left child pipe(); close(…); dup2(…); exec*(…); right child close(…); dup2(…); exec*(…); CPS 310 final exam, 12/12/2014, page 2 of 8

semaphore mutex(0); /* init 0 */ semaphore condition(0); /* init 0 */ acquire() { mutex.p(); } release() { mutex.v(); } wait() { condition.p(); } signal() { condition.v(); } A few weeks ago someone on Piazza asked me to explain the difference between monitors (mutexes and CVs/condition variables) and semaphores. One way to understand the difference is to implement each abstraction in terms of the other. We did that for one direction in class. Let’s try the other direction. The pseudocode on the right is a “first cut” implementation of monitors using semaphores. What’s wrong with it? Write a list of three distinct correctness properties that this solution violates even when used correctly. Outline a fix for each one. Feel free to mark the code. [30 points] Part 3. You tell me CPS 310 final exam, 12/12/2014, page 3 of 8

A certain Duke professor likes to sleep in the Perfect Chair TM in his office when there are no students around. The professor wakes up when students visit the office to ask questions. Write two procedures to synchronize threads for the professor and students. When the professor thread has nothing to do, it calls IdleProf(). IdleProf sleeps if there are no students waiting, otherwise it signals one student to enter the office, and returns. A student with a question to ask calls ArrivingStudent(), which waits until the professor is idle; if no students are waiting, then the student wakes up the sleeping professor. The idea is that the professor and exactly one student will return from their procedures “at the same time”. (They then discuss a topic of mutual interest, then the student goes back to studying and the professor calls IdleProf again.) Implement IdleProf and ArrivingStudent using monitors or semaphores: your choice. [40 points] Part 4. Sleeping Professor IdleProf() { } ArrivingStudent() { } CPS 310 final exam, 12/12/2014, page 4 of 8

(a)Why is it important to not write code that blocks the UI/main thread? When the UI thread does block, what does it wait for? (a)How does Android determine the user ID for an app process? How is this different from Unix/Linux? (a)What does Android do if an app fires an intent at an app or component that is not active? (You may assume that the sender has permission to fire the intent.) (a)A binder call executes stub methods on each side of the process boundary. How does the system “know” which stub methods to execute? (Or: where do they come from?) (a)Android maintains a reference count for each component. What does Android do if a reference count transitions to zero? Part 5. Android These questions pertain to concepts of Android as discussed in class. Answer each question in the space available, focusing on the high points. Use the “lingo”. Please keep it short! [50 points] CPS 310 final exam, 12/12/2014, page 5 of 8

(a)Why are file block maps skewed? By “skewed” I just mean that the maps form a tree that is unbalanced, in contrast to a hierarchical page table, which is balanced. (a)Why might an interrupt handler wake up a thread? (Give three examples.) (a)Sometimes a page fault handler installs a zero-filled page rather than reading a missing page from disk. Under what conditions does the system do this? (a)Why does mirroring (RAID-1) improve throughput for random block reads but not for writes? (a)Why does striping-with-parity (RAID-5) have lower throughput for random block writes than pure striping (RAID-0) does? Part 6. File/storage systems These questions pertain to the nexus of file systems and virtual memory. Answer each question in the space available, focusing on the high points. Use the “lingo”. Please keep it short! [50 points] CPS 310 final exam, 12/12/2014, page 6 of 8

(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 from Alice. Alice and Bob have keypairs and each knows the other's public key. How should Alice send the message? How should Bob validate the message? Briefly explain why your scheme works, and note any additional assumptions. Part 7. Cryptosystems [60 points] (b) One-way hash functions are fast and cheap. But what are they good for? I am looking for two specific examples of how they are used in practice, explaining how their properties are useful for those examples. (c) Often a server returns a certificate in response to a connect request. The certificate contains the server’s public key. Presuming that the certificate is valid, what does the client do with the server’s public key? CPS 310 final exam, 12/12/2014, page 7 of 8

Part 8. Extra credit (a)Did you fill out an online course evaluation? (b) What is an abstraction? Feel free to illustrate with a picture and/or examples from the class. CPS 310 final exam, 12/12/2014, page 8 of 8

Consider the short (and useless) C program off to the right. Each of the variables {a, b, c} references an integer value that occupies some space in memory at runtime. Answer the following questions for each of the integer values referenced by {a, b, c}. [60 points] Where are {a, b, c} stored in virtual memory? (i.e., what segment) How/when is the memory space for {a, b, c} allocated? How/when is it released? When the main thread accesses {a, b, c}, how is the virtual address computed or determined? When the main thread accesses {a, b, c}, how is the machine address computed or determined? CPS 310 final exam, 12/12/2014 Not Used. Get with the program int a = 0; int main() { int b = a; return p(); } int p() { int* c = (int*)malloc(4); return *c; }