First slide Rest of project 2 due next Friday Today:

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

CAS3SH3 Midterm Review. The midterm 50 min, Friday, Feb 27 th Materials through CPU scheduling closed book, closed note Types of questions: True & False,
Ch 7 B.
Operating Systems Review.
CSCC69: Operating Systems
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.
CSE 451: Operating Systems Section 6 Project 2b; Midterm Review.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
1 CSE451 – Section 5. 2 Reminders/Overview Rest of project 2 due Monday February 13 Turnin code + writeup Midterm Wednesday the 8th Today: Project 2 parts.
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
CS444/CS544 Operating Systems Synchronization 2/21/2007 Prof. Searleman
OS Spring’03 Introduction Operating Systems Spring 2003.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
OS Spring’04 Introduction Operating Systems Spring 2004.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
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:
Deadlocks Silberschatz Ch. 7 and Priority Inversion Problems.
Solutions to Second 4330/6310 Quiz Spring First question Which of the following statements are true or false (2 points) and why? (3 points)
Threads & Networking C# offers facilities for multi threading and network programming an application roughly corresponds to a process, handled by the OS.
CSE 451: Operating Systems Section 5 Midterm review.
Kernel Locking Techniques by Robert Love presented by Scott Price.
1 Some usual stuff Today’s office hours in 006 at 4:30 Grading Homework 2 back today (average: 45/50) I have old HW1/project 1/midterms, pick up at the.
Deadlock Detection and Recovery
Problems with Semaphores Used for 2 independent purposes –Mutual exclusion –Condition synchronization Hard to get right –Small mistake easily leads to.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
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.
What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program.
CSE 451: Operating Systems Section 6 Project 2b. Midterm  Scores will be on Catalyst and midterms were handed back on Friday(?) in class  Talk to Ed,
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
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.
1 Section 5 Synchronization primitives (Many slides taken from Winter 2006)
1.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 1: Introduction What Operating Systems Do √ Computer-System Organization.
Module 12: I/O Systems I/O hardware Application I/O Interface
Processes and threads.
RTOS Scheduling 2.0 Problems - Solutions
Scheduling Review FIFO: RR: + simple
Process Management Process Concept Why only the global variables?
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
Advanced Topics in Concurrency and Reactive Programming: Asynchronous Programming Majeed Kassis.
Preemption Set timer interrupts But now, must synchronize Two tools:
Winter 2k7 Kurtis Heimerl Aaron Kimball
CS703 - Advanced Operating Systems
Section 10: Last section! Final review.
Process management Information maintained by OS for process management
Concurrency: Mutual Exclusion and Synchronization
Operating Systems Review.
Andy Wang Operating Systems COP 4610 / CGS 5765
Midterm review: closed book multiple choice chapters 1 to 9
CSE451 – Section 6.
COT 4600 Operating Systems Spring 2011
CPU scheduling decisions may take place when a process:
Reminders Homework 4 & project 2 Midterm on Monday, November 8
CSE451 – Section 5.
Computer Science & Engineering Electrical Engineering
Major Topics in Operating Systems
February 5, 2004 Adrienne Noble
Reminders Homework 4 due next Friday Rest of project 2 due next Friday
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization
CSE 153 Design of Operating Systems Winter 2019
CS333 Intro to Operating Systems
Project 2, part 4 - web server
CSE 153 Design of Operating Systems Winter 2019
CSE 451 Section 1/27/2000.
CSE 153 Design of Operating Systems Winter 2019
EECE.4810/EECE.5730 Operating Systems
Chapter 3: Process Management
Presentation transcript:

First slide Rest of project 2 due next Friday Today: Turnin code + writeup Today: Project 2 parts 4-6 (quick) Midterm sample questions & review

Project 2 – web server web/sioux.c – singlethreaded web server Read in command line args, run the web server loop web/sioux_run.c – the webserver loop Open a socket to listen for connections (listen) Wait for a connection (accept) Handle it Parse the HTTP request Find and read the requested file (www root is ./docs) Send the file back Close the connection web/web_queue.c – an empty file for your use

What you need to do Make the web server multithreaded Create a thread pool A bunch of threads waiting for work Number of threads = command-line arg Wait for a connection Find an available thread to handle connection Current request waits if all threads busy Once a thread grabs onto connection, it uses the same processing code as before.

Hints Each connection is identified by a socket returned by accept Which is just an int Simple management of connections among threads Threads should sleep while waiting for a new connection Condition variables are perfect for this Don’t forget to protect any global variables Use part 2 mutexes, CVs Develop + test with pthreads initially Mostly modify sioux_run.c and/or your own files Stick to the sthread.h interface!

Part 6 – Report Design discussion & functionality Results Make it short Results Run a few experiments with the new webserver Use given web benchmark: /cse451/projects/webclient Present results in a graphical easy-to-understand form. Explain Are the results what you expected? Try to justify any discrepancies you see Answer a few of our questions

Project 2 questions?

Midterm – top 3 topics Scheduling Synchronization Virtual Memory

Scheduling review FIFO: RR: SJF: Multi-level feedback: + simple - short jobs can get stuck behind long ones; poor I/O device utilization RR: + better for short jobs - hard to select right time slice - poor turnaround time when jobs are the same length SJF: + optimal (ave. waiting time, ave. time-to-completion) - hard to predict the future - unfair Multi-level feedback: + approximate SJF - unfair to long running jobs Ex, for RR same length: P1, P2 – 100 time units, time slice=1 time unit (199+200)/2 = 199.5 (100+200)/2 = 150

A simple scheduling problem Thread Arrival Time Burst Time A 10 B 1 5 C 3 2 FIFO Turnaround time: FIFO Waiting Time:

A simple scheduling problem Thread Arrival Time Burst Time A 10 B 1 5 C 3 2 FIFO Turnaround Time: A: (10-0) = 10 B: (15-1) = 14 C: (17-3) = 14 (10+14+14)/3 = 12.66 FIFO Waiting Time: A: 0 B: (10-1) = 9 C: (15-3) = 12 (10+9+12)/3 = 10.33

A simple scheduling problem What about SJF with 1 unit delay? Thread Arrival Time Burst Time A 10 B 1 5 C 3 2 Ave Turnaround Time: B: 5 C: 7-3 = 4 A: 1+5+2+10 = 18 (17+4+5)/3 = 8.67 Ave Waiting Time: B: 0 C: 5-2 = 3 A: 1+5+2 = 8 (0+3+8)/3 = 3.67 1 5 (B) 2 (C) 10 (A) A B C

Priority Inversion Have three processes Have this code: P1:Highest priority; P2:Medium; P3:Lowest Have this code: P(mutex); critical section; V(mutex); P3 acquires mutex; preempted P1 tries to acquire mutex; blocks P2 enters the system at medium priority; runs P3 never gets to run; P1 never gets to run!! This happened on Mars Pathfinder in 1997! Solutions? a thread’s importance should increase with the importance of those that depend on it Pathfinder contained an "information bus", which you can think of as a shared memory area used for passing information between different components of the spacecraft. A bus management task ran frequently with high priority to move certain kinds of data in and out of the information bus. Access to the bus was synchronized with mutual exclusion locks (mutexes). The meteorological data gathering task ran as an infrequent, low priority thread, and used the information bus to publish its data. When publishing its data, it would acquire a mutex, do writes to the bus, and release the mutex. If an interrupt caused the information bus thread to be scheduled while this mutex was held, and if the information bus thread then attempted to acquire this same mutex in order to retrieve published data, this would cause it to block on the mutex, waiting until the meteorological thread released the mutex before it could continue. The spacecraft also contained a communications task that ran with medium priority. More at http://www.time-rover.com/Priority.html

Deadlock-related questions Can there be a deadlock with only one process? Given two threads, what sequence of calls to transfer(...) causes the following to deadlock? /* transfer x dollars from a to b */ void transfer(account *a, account *b, int x) P(a->sema); P(b->sema); a->balance += x; b->balance -= x; V(b->sema); V(a->sema); T1 T2 Transfer( ); Transfer( );

Some synchronization issues Monitors How should we use them? Why is this weird inside a monitor? P(mutex); account+=balance; V(mutex); General notes Always init your semaphores! Say which variables are in shared state

Another synchronization problem File sharing problem Processes can share a file as long as ∑pid < n Write a monitor to coordinate the processes If => while

File sharing – (almost) correct solution type file = monitor    var space_available: condition        total: integer   procedure file_open(id)    begin      if (total + id >= n)        space_available.wait();      total = total + id;    end    procedure file_close(id)    begin     total = total - id;      space_available.signal(); Find the bugs!

File sharing – correct solution type file = monitor    var space_available: conditional_wait        total: integer   procedure file_open(id)    begin      while (total + id >= n)        space_available.wait(id);      total = total + id;      if (total < n - 1)        space_available.signal();    end    procedure file_close(id)    begin     total = total - id;      space_available.signal();

Quick VM exercise Consider a virtual address space of 8 pages of 512 bytes each, mapped onto a physical memory of 32 frames Virtual address size (in bits): Physical address size (in bits):

Another VM sample question Given: 32-bit architecture Architecture only supports 30-bit physical addresses 4K pages Master page table has 4K entries Maps 4K 2nd level page tables Draw a picture of virtual address structure and how it gets translated…