1 / 10

Midterm Review

Midterm Review . 4:00pm – 5:20pm, 11/10/11 Open book and notes Four problems. Midterm Review - 1. Overview

huslu
Download Presentation

Midterm Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Midterm Review • 4:00pm – 5:20pm, 11/10/11 • Open book and notes • Four problems Advanced Topics in Software Engineering 1

  2. Midterm Review - 1 • Overview • What, why, concurrent vs sequential computation, models of concurrency (interleaving-based/true concurrency), semantics of correctness (safety & liveness), unique challenges in testing and debugging • Shared variables • The CS problem, correctness requirements, Peterson’s algorithm, Bakery algorithm, synchronization operation, SYN-sequence, RW-sequence, version-based tracing & replay Advanced Topics in Software Engineering 2

  3. Midterm Review - 2 • Semaphore & Locks • Binary semaphore, counting semaphore, lock, semaphores in Java, common patterns in semaphore-based programming, semaphore-based solutions to classical synchronization problems, fine-grained locking, PV-sequence, Lock/Unlock-sequence, permission-based tracing & replay Advanced Topics in Software Engineering 3

  4. Midterm Review - 3 • Monitor • Graphic representation, different signaling disciplines, monitor implementation, Java monitors, monitor-based solutions (dinning philosophers, bounded buffer, reader/writers), tracing/replay monitors (entry-based execution, simple and complete M-sequence) • Message Passing • Link/port/mailbox, synchronous vs asynchronous, rendezvous, selective wait, happened-before relation, integer/vector timestamps Advanced Topics in Software Engineering 4

  5. Homework Problems • Exercises 3.5 • Exercises 4.4, 4.11b., 4.18b, 4.24 • Exercises 6.6 Advanced Topics in Software Engineering 5

  6. Simulating Counting Semaphores • public final classCountingSemaphore { • privateint permits = 0; • BinarySemaphore mutex (1); • BinarySemaphore delayQ (0); • publicCoutingSemaphore (int initialPermits) { • permits = initialPermits; • } • public void P () { • mutex.P (); (1) • -- permits; (2) • if (permits < 0) { (3) • mutex.V (); (4) • delayQ.P (); (5) • } • else • mutex.V (); (6) • } • public void V () { • mutex.P (); (7) • ++ permits; (8) • if (permits <= 0) { (9) • delayQ.V (); (10) • } • mutex.V (); (11) • } • } Advanced Topics in Software Engineering 6

  7. A scenario • T1T2T3T4 (1) (2) (3) (4) (1) (2) (3) (4) (7) (8) (9) (10) (7) (8) (9) *(10) (5) *(10) (5) Advanced Topics in Software Engineering 7

  8. Exercise 4.4 public void waitC() { ++numWaitingThreads; threadQueue.VP(mutex); mutex.P(); --numWaitingThreads; } public void signalC() { if (numWaitingThreads > 0) threadQueue.V(); // continue in the monitor; perhaps send more signals } Advanced Topics in Software Engineering 8

  9. Exercises 3.5 • public final classCountingSemaphore { • privateint permits = 0; • BinarySemaphore mutex (1); • BinarySemaphore delayQ (0); • publicCoutingSemaphore (int initialPermits) { • permits = initialPermits; • } • public void P () { • mutex.P (); (1) • -- permits; (2) • if (permits < 0) { (3) • mutex.V (); (4) • delayQ.P (); (5) • } • else • mutex.V (); (6) • } • public void V () { • mutex.P (); (7) • ++ permits; (8) • if (permits <= 0) { (9) • delayQ.V (); (10) • } • mutex.V (); (11) • } • } Advanced Topics in Software Engineering 9

  10. Questions? Advanced Topics in Software Engineering 10

More Related