Final Exam Review 15-213: Introduction to Computer Systems Recitation 15: Monday, Dec. 2nd, 2013 Marjorie Carlson Section A.

Slides:



Advertisements
Similar presentations
Recitation 8 (Nov. 1) Outline Process & job control Lab 5 Reminder Lab 5: Due Thursday Minglong Shao Office hours: Thursdays 5-6PM.
Advertisements

Recitation 8: 10/28/02 Outline Processes Signals –Racing Hazard –Reaping Children Annie Luo Office Hours: Thursday 6:00.
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.
HW/Study Guide. Synchronization Make sure you understand the HW problems!
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
CSCC69: Operating Systems
Final Exam Review Monday December 1, 2014 TJ O’Connor.
15-213, Fall 06 Outline Shell Lab Processes Signals.
COMP 3221: Microprocessors and Embedded Systems Lectures 27: Virtual Memory - III Lecturer: Hui Wu Session 2, 2005 Modified.
15-213/ Intro to Computer Systems by btan with reference to Spring 10’s slides.
Recitation 8 (Nov. 1) Outline Lab 5 hints Virtual Memory Reminder Shell Lab: Due THIS Thursday TA: Kun Gao Modified from Minglong Shao’s Recitation, Fall.
CSSE Operating Systems
Section A (March 14) Outline Exceptions Process Signals Non-local jumps Reminders Lab4: Due Next Thursday TA: Kun Gao Shamelessly Modified from Minglong.
CSE 451 Section 4 Project 2 Design Considerations.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Carnegie Mellon 1 Processes, Signals, I/O, Shell Lab : Introduction to Computer Systems Recitation 9: 10/21/2013 Tommy Klein Section B.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
Operating Systems ECE344 Ding Yuan Paging Lecture 8: Paging.
1 Carnegie Mellon Recitation : Introduction to Computer Systems Recitation 15: December 3, 2012 Daniel Sedra Section C.
Virtual Memory Expanding Memory Multiple Concurrent Processes.
Project 2: Initial Implementation Notes Tao Yang.
CSE 351 Virtual Memory. Agenda Today … Review on VM Example problems on VM accesses.
Operating Systems Process Creation
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Unix System Calls and Posix Threads.
Recitation: Signaling S04, Recitation, Section A Debug Multiple Processes using GDB Debug Multiple Processes using GDB Dup2 Dup2 Signaling Signaling.
Carnegie Mellon 1 Processes, Signals, I/O, Shell Lab : Introduction to Computer Systems Recitation 9: Monday, Oct. 21, 2013 Marjorie Carlson Section.
Virtual Memory : Introduction to Computer Systems Recitation 10: Oct. 28, 2013 Marjorie Carlson Recitation A.
Carnegie Mellon Introduction to Computer Systems / Spring 2009 March 23, 2009 Virtual Memory.
S -1 Processes. S -2 wait and waitpid (11.2) Recall from a previous slide: pid_t wait( int *status ) wait() can: (a) block; (b) return with status; (c)
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
MIDTERM REVIEW CSCC69 Winter 2016 Kanwar Gill. What is an OS? What are processes and threads? Process states? Diagram showing the state changes What data.
Recitation 7 (Oct. 25) Outline Minglong Shao Office hours: Reminders
Today topics: File System Implementation
CS161 – Design and Architecture of Computer
Virtual Memory: Systems
Today How was the midterm review? Lab4 due today.
Protection of System Resources
Virtual Memory : Introduction to Computer Systems Recitation 10: Nov. 2, 2015 Karthic Palaniappan.
Unix Process Management
Memory Hierarchy Virtual Memory, Address Translation
Processes in Unix, Linux, and Windows
UNIX PROCESSES.
Tarek Abdelzaher Vikram Adve Marco Caccamo
CSE 153 Design of Operating Systems Winter 2018
Processes in Unix, Linux, and Windows
Nikhil, Kashish, Krishanu, Stan
Virtual Memory: Systems
Virtual Memory: Systems
Virtual Memory S04, Recitation, Section A
Chapter 2: The Linux System Part 2
Processes in Unix, Linux, and Windows
Recitation 8 Processes, Signals, Tshlab
Page that info back into your memory!
Pentium/Linux Memory System
Recitation 9: Processes, Signals, TSHLab
Virtual Memory CSCI 380: Operating Systems Lecture #7 -- Review and Lab Suggestions William Killian.
Virtual Memory.
Virtual Memory Nov 27, 2007 Slide Source:
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Virtual Memory Prof. Eric Rotenberg
CSCI 380: Operating Systems William Killian
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
EECE.4810/EECE.5730 Operating Systems
Today’s agenda ~10min: file system (UNIX) ~1hr: final review + Q&A
CSE 153 Design of Operating Systems Winter 2019
Recitation 9: Processes, Signals, TSHLab
CS703 - Advanced Operating Systems
Presentation transcript:

Final Exam Review 15-213: Introduction to Computer Systems Recitation 15: Monday, Dec. 2nd, 2013 Marjorie Carlson Section A

Agenda News & Exam Information Brief Review of Topics Important System Calls Virtual Address Translation Threading vs. Forking Practice Questions

News Proxylab is due Thursday Dec. 5th at 11:59 PM Last day to submit late is Sunday Dec. 8th Make sure you’ve downloaded the tarball since your “Thanksgiving gift” from Dr. O’Hallaron.

Exam Information Monday December 9th – Thursday December 12th Online, like the midterm. Exact times will be sent out in an email and updated on the website later this week. You can bring 2 double-sided sheets of notes. No pre-worked problems. Must be your own work. What to study: Chapters 8-12 + everything from the first half! How to study: Read each chapter 3 (more?) times. Work practice problems from the book. Do problems from previous exams (including newly posted finals).

Agenda News & Exam Information Brief Review of Topics Important System Calls Virtual Address Translation Threading vs. Forking Practice Questions

Important System Calls fork Called once, returns twice (unless it fails) Returns 0 in the child process Returns the pid of the child in the parent process Returns -1 on failure Makes an exact copy of the entire address space Processes get unique copies of file descriptors, but share open files Execution order of parent and child is arbitrary execve Called once, doesn’t return (unless it fails) Replaces the currently running process with the specified program

Important System Calls wait/waitpid Reaps one child process By default, blocks until a child process can be reaped wait will wait for any child waitpid waits for the specified child process Returns the pid of the child that was reaped, or -1 on error waitpid can be passed additional arguments to modify its behavior WNOHANG will prevent waitpid from blocking WUNTRACED will report stopped children signal A simplified (but easier to understand) interface to sigaction Installs a signal handler that is run when the specified signal is triggered

Important System Calls sigprocmask Can block signals, unblock signals, or set the signal mask SIG_BLOCK adds the given signals to the set of blocked signals SIG_UNBLOCK removes the given signals SIG_SETMASK replaces the blocked signals with the given signals sigsuspend Replaces the signal mask with the specified mask Blocks until one signal that isn’t masked is handled After the one signal is handled, the signal mask is restored

Agenda News & Exam Information Brief Review of Topics Important System Calls Virtual Address Translation Threading vs. Forking Practice Questions

Virtual Address Translation Translates a process’s virtual address into a physical address in main memory. Page tables store mappings from virtual addresses to physical addresses. Page directories store mappings from virtual addresses to page table addresses, adding an additional layer of indirection. Address translation is like cache lookup: Split up the binary representation of a virtual address. Use the parts as indices into pages, page tables, or the TLB.

Virtual Address Translation Know your acronyms (there are probably more in the book) TLB Translation lookaside buffer TLBI TLB Index TLBT TLB Tag VPO Virtual page offset VPN Virtual page number PPO Physical page offset PPN Physical page number PTBE Page table base address PTE Page table entry PDE Page directory entry CI Cache index CT Cache tag

Virtual Address Translation Refer to this diagram, blatantly copied from recitation 10 TLBT TLBI 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 1 VPN VPO

Virtual Address Translation A simplified overview of the translation process Write out the virtual address in binary; divide it up into the relevant offset, indexes and tags. Check the TLB (if there is one) to see if the page is in memory. If there’s a TLB miss, check the top level page directory to see if the page is in memory. If the top level page directory entry is present, continue following to the next page table. If not, a page fault is triggered. If you make it all the way down to the deepest page table without triggering a page fault, you will get a physical address. After you have a physical address, you may have to check a cache to see if the requested data is already available.

Agenda News & Exam Information Brief Review of Topics Important System Calls Virtual Address Translation Threading vs. Forking Practice Questions

Threading vs. Forking How they’re the same How they’re different Both allow you to run code concurrently How they’re different Threads in the same process share memory Threads share file descriptors If you close a file descriptor in one thread, it’s closed for all of the threads in the same process Threads share signal handlers and masks If you install one signal handler in one thread, and a different one in another, the most recent one will be the one that is called.

Agenda News & Exam Information Brief Review of Topics Important System Calls Virtual Address Translation Threading vs. Forking Practice Questions

Process Control What are the possible outputs for this program? int main() { if (fork() == 0) { printf("a"); } else { printf("b"); waitpid(-1, NULL, 0); printf("c"); exit(0);

File I/O int main() { char buf[3] = "ab"; int r = open("file.txt", O_RDONLY); int r1, pid; r1 = dup(r); read(r, buf, 1); if((pid=fork())==0) r1 = open("file.txt", O_RDONLY); else waitpid(pid, NULL, 0); read(r1, buf+1, 1); printf("%s", buf); return 0; } Assume that file.txt contains the string of bytes 15213. Also assume that all system calls succeed. What will be the output when this code is compiled and run?

Code Snippet 1 Code Snippet 3 int i = 0; void handler(int sig) { i = 0; } int main() { int main () { int j; signal(SIGINT, handler); sigset_t s; for (j=0; j < 100; j++) { i++; /* Assume that s has been sleep(1); initialized and declared properly for SIGINT */ printf("i = %d\n", i); exit(0); sigprocmask(SIG_BLOCK, &s, 0); sigprocmask(SIG_UNBLOCK, &s, 0); For each of the above code snippets, assume an arbitrary number of SIGINTs—and only SIGINTs—are sent to the process. What are the possible values of i that are printed out?

Processes vs. Threads What is the output? Procs: cnt = ___ int main() { int i; pthread_t tid[2]; sem_init(&mutex, 0, 1); /* mutex=1 */ /* Processes */ cnt = 0; for (i=0; i<2; i++) { incr(NULL); if (fork() == 0) { exit(0); } for (i=0; i<2; i++) wait(NULL); printf("Procs: cnt = %d\n", cnt); /* Threads */ pthread_create(&tid[i], NULL, incr, NULL); pthread_join(tid[i], NULL); printf("Threads: cnt = %d\n", cnt); #include "csapp.h" /* Global variables */ int cnt; sem_t mutex; * Helper function */ void *incr(void *vargp) { P(&mutex); cnt++; V(&mutex); return NULL; } What is the output? Procs: cnt = ___ Threads: cnt = ___

Address Translation 32-bit machine; 4-byte words. Memory is byte-addressable. 4 GB of virtual address space. 64 MB of physical memory. 4 KB page size. Two-level page tables. Tables at both levels are 4096 bytes (one page) and entries in both tables are 4 bytes, as shown to the right. The page table base address for process 1 is 0x0021A000. Translate virtual address 0xBFCF0145 into a physical address. The page table base address for process 2 is 0x0021B000. Translate virtual address 0x0804A1F0 into a physical address.

Synchronization A producer/consumer system with a FIFO queue of 10 data items. Producer threads call insert to add to the rear of the queue; consumer threads call remove to put something at the front. The system uses three semaphores: mutex, items, and slots. Your task is to use P and V semaphore operations to correctly synchronize access to the queue. What is the initial value of each semaphore? mutex = ______ items = _______ slots = _______ Write the pseudocode: void insert(int item) { add_item(item) } void remove() { item = remove_item() return(item) }

Questions? Good luck on proxy lab, and on your final exam! I hope you have learned half as much from me as I have from TAing you. 