Software architecture and larger system design issues

Similar documents
INTER-PROCESS COMMUNICATION AND SYNCHRONISATION: Lesson-12: Signal Function

Solved MCQS From Midterm Papers. MIDTERM EXAMINATION Spring CS604 - Operating System

Solved MCQS From Midterm Papers. MIDTERM EXAMINATION Spring CS604 - Operating System

From Synchronous to Asynchronous Design

ENGR 1000, Introduction to Engineering Design

Digital Signal Processing

For an alphabet, we can make do with just { s, 0, 1 }, in which for typographic simplicity, s stands for the blank space.

MotionPro. Team 2. Delphine Mweze, Elizabeth Cole, Jinbang Fu, May Oo. Advisor: Professor Bardin. Midway Design Review

Last time, we saw how latches can be used as memory in a circuit

Tape. Tape head. Control Unit. Executes a finite set of instructions

Enhancing Performance in Multiple Execution Unit Architecture using Tomasulo Algorithm

REAL-TIME DIGITAL SIGNAL PROCESSING from MATLAB to C with the TMS320C6x DSK

Figure 1: segment of an unprogrammed and programmed PAL.

Lehrstuhl für Informatik 4 Kommunikation und verteilte Systeme

PROF. TAJANA SIMUNIC ROSING. Midterm. Problem Max. Points Points Total 150 INSTRUCTIONS:

DigiPoints Volume 2. Student Workbook. Module 1 Components of a Digital System

Chapter 4. Logic Design

The outputs are formed by a combinational logic function of the inputs to the circuit or the values stored in the flip-flops (or both).

Using the MAX3656 Laser Driver to Transmit Serial Digital Video with Pathological Patterns

Lab experience 1: Introduction to LabView

SPR-11P Portable Transport Stream Recorder and Player

THE LXI IVI PROGRAMMING MODEL FOR SYNCHRONIZATION AND TRIGGERING

ECE 4220 Real Time Embedded Systems Final Project Spectrum Analyzer

Impact of Intermittent Faults on Nanocomputing Devices

The RedRat-X. Integration Guide

Philosophers At Table On Food And Being Human

A Review of logic design

Microprocessor Design

Errata OPERATING SYSTEM CONCEPTS, FIFTH EDITION Silberschatz and Galvin September 9, 1998

Testing Sequential Circuits

Published in A R DIGITECH

Mauricio Álvarez-Mesa ; Chi Ching Chi ; Ben Juurlink ; Valeri George ; Thomas Schierl Parallel video decoding in the emerging HEVC standard

Dr.Mohamed Elmahdy Winter 2015 Eng.Yasmin Mohamed. Problem Set 6. Analysis and Design of Clocked Sequential Circuits. Discussion: 7/11/ /11/2015

Sapera LT 8.0 Acquisition Parameters Reference Manual

TABLE 3. MIB COUNTER INPUT Register (Write Only) TABLE 4. MIB STATUS Register (Read Only)

Parade Application. Overview

Digital Lock-In Amplifiers SR850 DSP lock-in amplifier with graphical display

Lecture 8: Sequential Logic

ITU-T Y Functional framework and capabilities of the Internet of things

A Symmetric Differential Clock Generator for Bit-Serial Hardware

HDMI Cross Converter

The word digital implies information in computers is represented by variables that take a limited number of discrete values.

Registers and Counters

IJMIE Volume 2, Issue 3 ISSN:

Slide Set Overview. Special Topics in Advanced Digital System Design. Embedded System Design. Embedded System Design. What does a digital camera do?

Lab 3c Fun with your LED cube. ENGR 40M Chuan-Zheng Lee Stanford University 19 May 2017

Flip-flop and Registers

CONTROL OF THE LOW LEVEL RF SYSTEM OF THE LARGE HADRON COLLIDER

AN ARTISTIC TECHNIQUE FOR AUDIO-TO-VIDEO TRANSLATION ON A MUSIC PERCEPTION STUDY

Dual Link DVI Receiver Implementation

Lab Assignment 5 I. THE 4-BIT CPU AND CONTROL

TEPZZ A_T EP A1 (19) (11) EP A1. (12) EUROPEAN PATENT APPLICATION published in accordance with Art.

Embedded System Design

18-551, Spring Group #4 Final Report. Get in the Game. Nick Lahr (nlahr) Bryan Murawski (bmurawsk) Chris Schnieder (cschneid)

VLSI Design: 3) Explain the various MOSFET Capacitances & their significance. 4) Draw a CMOS Inverter. Explain its transfer characteristics

Vignana Bharathi Institute of Technology UNIT 4 DLD

User Manual. Multi-Screen Splicing Processor J6

Jam Tomorrow: Collaborative Music Generation in Croquet Using OpenAL

Model 4455 ASI Serial Digital Protection Switch Data Pack

When to use External Trigger vs. External Clock

The Pathway To Ultrabroadband Networks: Lessons From Consumer Behavior

Electrical and Telecommunications Engineering Technology_TCET3122/TC520. NEW YORK CITY COLLEGE OF TECHNOLOGY The City University of New York

DLC SPY maintainance tool User manual

J6 User Manual. User Manual. Multi-Screen Splicing Processor J6. Xi an NovaStar Tech Co., Ltd. Rev1.0.1 NS

Processor time 9 Used memory 9. Lost video frames 11 Storage buffer 11 Received rate 11

Production Automation To Add Rich Media Content To Your Broadcasts VIDIGO VISUAL RADIO PRODUCT INFORMATION SHEET

Video Output and Graphics Acceleration

Research on Applying Digital Audio Technology to Movie Sound Production

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

Registers and Counters

Chapter Contents. Appendix A: Digital Logic. Some Definitions

Major Differences Between the DT9847 Series Modules

DIGITAL CIRCUIT LOGIC UNIT 9: MULTIPLEXERS, DECODERS, AND PROGRAMMABLE LOGIC DEVICES

Linux-based Mobile Phone Middleware. Application Programming Interface. Circuit-Switched Communication Service. Document: CELF_MPP_CS_D_FR4

Chapter 3 Instruction-Level Parallelism and its Exploitation (Part 1)

Tempo Estimation and Manipulation

Sequential Logic. Analysis and Synthesis. Joseph Cavahagh Santa Clara University. r & Francis. TaylonSi Francis Group. , Boca.Raton London New York \

IE1204 Digital Design F11: Programmable Logic, VHDL for Sequential Circuits

Physics 120 Lab 10 (2018): Flip-flops and Registers

Student resource files

1Chapter INTRODUCTION. This chapter describes the CST-5000 C-Band satellite terminal, referred to in this manual as the CST-5000 (Figure 1-1).

Chapter 10 Exercise Solutions

A summary of scan conversion architectures supported by the SPx Development software

Chapter 5 Sequential Circuits

GUIX Synergy Port Framework Module Guide

KM-H Series. Multi-format digital production switchers KM-H3000E KM-H3000U KM-H2500E KM-H2500U

for Digital IC's Design-for-Test and Embedded Core Systems Alfred L. Crouch Prentice Hall PTR Upper Saddle River, NJ

The SMC-4AV incorporates in 1-RU chassis multiple switches for remote switch scheduling and control over TCP/IP Networks with front panel independent

(CSC-3501) Lecture 7 (07 Feb 2008) Seung-Jong Park (Jay) CSC S.J. Park. Announcement


Sequential Logic. Introduction to Computer Yung-Yu Chuang

COMP sequential logic 1 Jan. 25, 2016

INTRODUCTION AND FEATURES

Synchronous Sequential Logic

DNA-STP-SYNC Synchronization and Screw Terminal Panel. User Manual

Pitch correction on the human voice

TR 038 SUBJECTIVE EVALUATION OF HYBRID LOG GAMMA (HLG) FOR HDR AND SDR DISTRIBUTION

The experience of RAI DigiMaster Project, in progress..

Instruction Level Parallelism Part III

Fig. 1. The Front Panel (Graphical User Interface)

Transcription:

Software architecture and larger system design issues ecture 3: Monitor synchonization Topics: Programming language specifics (ACE) More on monitor synchronization More problems with concurrent software

Programming anguage Specifics C++: ibraries POSIX Threads (Pthreads) C library (see pthreads.h) ACE Portability layer on top of PThreads Adds some C++ niceties Boost Makes use of more advanced C++ features Java: First-class language features Monitor oriented synchronized keyword Thread class and Runnable interface provided

ACE Classes A ACE_Thread_Mutex: Mutex class acquire and release methods ACE_Condition_Thread_Mutex: Condition class constructor takes an ACE_Thread_Mutex wait, signal, and broadcast methods ACE_Thread_Manager singleton (has instance method) spawn method, which takes function pointer: void*(thread_root*)(void*) void pointer to arguments to pass to function spawn_n: like spawn but takes an additional int wait: block until all spawned threads are terminated

Recall: Multithreaded Server Design istener 1 1..* <<monitor>> 1 Buffer 1 put(c:connection) ():Connection Handler

Handout Figure 1: Buffer Class Definition 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 class Buffer public: Buffer(); Connection* (); void put(connection* conn); private: // Circular-array data structure Connection* carray[bufsiz]; int begin; int size; ACE_Thread_Mutex lock; // The monitor lock ACE_Condition_Thread_Mutex nonempty; ACE_Condition_Thread_Mutex nonfull; ;

Handout Figure 2: Buffer Method Definitions 21 22 23 Buffer::Buffer() : begin(0), size(0), nonempty(lock), nonfull(lock) 42 43 44 45 46 47 48 49 50 51 52 53 54 void Buffer::put(Connection* conn) carray[(begin + size) % BUFSIZ] = conn; ++size;

Handout Figure 2: Buffer Method Definitions 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 Connection* Buffer::() result = carray[begin]; ++begin; begin %= BUFSIZ; --size;

Handout Figure 3: Thread Root Functions 55 56 // Global shared connection fer Buffer ; 59 60 61 62 63 64 65 66 void* listener(void*) for (;;).put(accept_connection()); return 0; 67 68 69 70 71 72 73 74 void* handler(void*) for (;;) service_connection(.()); return 0;

Handout Figure 4: Main Function 76 77 78 79 80 81 82 83 int main(int, char*[]) ACE_Thread_Manager::instance()->spawn_n(1, listener, 0); ACE_Thread_Manager::instance()->spawn_n(4, handler, 0); ACE_Thread_Manager::instance()->wait(); return 0;

c nonempty = nonfull = data = ( c ) lock = (, )... Buffer::() in the lock fer, = (, and two ) handlers ( and ) concurrently invoke () on the fer lock = (, ) nonempty = Imagine a scenario where there is one connection (c)

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, ) is scheduled first...... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, ) Then, is preempted by... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

c nonempty = nonfull = data = ( c ) lock = (, )... Buffer::() enters lock the = (, blocking ) state, and is scheduled lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, ) Then, is preempted by... Buffer::() c lock = (, ) nonempty =

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, )

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, )

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, )

nonempty = nonfull = data = ( c ) lock = (, ) lock = (, )... Buffer::() c lock = (, ) nonempty =

put(d) nonempty = nonfull = lock = (, ) data = ( d )... Buffer::() put() nonempty the = fer while is waiting lock = (, ) d Now, imagine a listener thread invokes

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d )... Buffer::() the lock nonempty before = it can return from wait(). In the lock = (, ) d is no longer blocking, but it still must acquire meantime, continues running

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) Then, is preempted by nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, )

put(d) nonempty = nonfull = lock = (, ) data = ( d ) nonempty =... Buffer::() lock = (, ) d

In-Class Exercise: Draw a Sequence Diagram Assume: a listener thread,, and two handler threads, and, and the fer is empty, and all the threads are at the beginning of their respective control loops. Scenario: (1) calls and calls wait on the nonempty condition (does not return from wait yet). (2) calls and calls wait on the nonempty condition (does not return from wait yet). (3) calls put, adds a connection c to the fer, calls signal on the nonempty condition, and returns from put. (4) returns from wait, removes a c from the fer, and returns from.

Exercise: Solution Pt. 1 nonempty = nonfull = () lock = (, ) nonempty = () lock = (, ) nonempty =,

Exercise: Solution Pt. 2 put(c) lock = (, ) data = ( c ) nonempty = lock = (, ) c

More Problems with Concurrent Programs Previously introduced problems: Nondeterministic scheduling makes comprehension difficult Race conditions (data races) Need to structure design differently for concurrency New problems: Deadlock: All threads transition to the blocked state Components do not compose cleanly (hidden dependences)

Variant Server Design: Array of Buffers istener 1 1 <<monitor>> Buffer_Manager <<monitor>> Buffer put(c:connection) ():Connection 0..1 put_in_(c:connection, i:integer) _from_(i:integer):connection 1..* Handler 1 index: Integer 1 See the problem with this design?

mgr data = (0, 1) 0 nonempty = nonfull = _from_(0) lock = (, ) lock = (, ) nonempty = Scenario: Deadlock DEADOCK!

Still More Problems ivelock: ike deadlock, only with busy waiting Starvation: A thread cannot access to a resource Unfairness: Some threads have greater access to resources than others Priority inversion: Threads with higher scheduling priority make slower progress than lower priority threads Poor performance: Multithreaded program performs worse than sequential equivalent