MODERN MULTITHREADING
|
|
- Regina Campbell
- 5 years ago
- Views:
Transcription
1 MODERN MULTITHREADING Implementing, Testing, and Debugging Multithreaded Java and C++/Pthreads/Win32 Programs RICHARD H. CARVER KUO-CHUNG TAI A JOHN WILEY & SONS, INC., PUBLICATION
2
3 MODERN MULTITHREADING
4
5 MODERN MULTITHREADING Implementing, Testing, and Debugging Multithreaded Java and C++/Pthreads/Win32 Programs RICHARD H. CARVER KUO-CHUNG TAI A JOHN WILEY & SONS, INC., PUBLICATION
6 Copyright 2006 by John Wiley & Sons, Inc. All rights reserved. Published by John Wiley & Sons, Inc., Hoboken, New Jersey. Published simultaneously in Canada. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) , fax (978) , or on the web at Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) , fax (201) , or online at Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages. For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) , outside the United States at (317) or fax (317) Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic formats. For more information about Wiley products, visit our web site at Library of Congress Cataloging-in-Publication Data: Carver, Richard H., 1960 Modern multithreading: implementing, testing, and debugging multithreaded Java and C++/Pthreads/Win32 programs / by Richard H. Carver and Kuo-Chung Tai. p. cm. Includes bibliographical references and index. ISBN (paper) ISBN (paper) 1. Parallel programming (Computer science) 2. Threads (Computer programs) I. Tai, Kuo-Chung. II. Title. QA C dc Printed in the United States of America
7 CONTENTS Preface xi 1 Introduction to Concurrent Programming Processes and Threads: An Operating System s View, Advantages of Multithreading, Threads in Java, Threads in Win32, Pthreads, C++ Thread Class, C++ Class Thread for Win32, C++ Class Thread for Pthreads, Thread Communication, Nondeterministic Execution Behavior, Atomic Actions, Testing and Debugging Multithreaded Programs, Problems and Issues, Class TDThread for Testing and Debugging, Tracing and Replaying Executions with Class Template sharedvariable<>, Thread Synchronization, 38 Further Reading, 38 References, 39 Exercises, 41 v
8 vi CONTENTS 2 The Critical Section Problem Software Solutions to the Two-Thread Critical Section Problem, Incorrect Solution 1, Incorrect Solution 2, Incorrect Solution 3, Peterson s Algorithm, Using the volatile Modifier, Ticket-Based Solutions to the n-thread Critical Section Problem, Ticket Algorithm, Bakery Algorithm, Hardware Solutions to the n-thread Critical Section Problem, Partial Solution, Complete Solution, Note on Busy-Waiting, Deadlock, Livelock, and Starvation, Deadlock, Livelock, Starvation, Tracing and Replay for Shared Variables, ReadWrite-Sequences, Alternative Definition of ReadWrite-Sequences, Tracing and Replaying ReadWrite-Sequences, Class Template sharedvariable<>, Putting It All Together, Note on Shared Memory Consistency, 74 Further Reading, 77 References, 78 Exercises, 79 3 Semaphores and Locks Counting Semaphores, Using Semaphores, Resource Allocation, More Semaphore Patterns, Binary Semaphores and Locks, Implementing Semaphores, Implementing P() and V(), VP() Operation, Semaphore-Based Solutions to Concurrent Programming Problems, Event Ordering, 96
9 CONTENTS vii Bounded Buffer, Dining Philosophers, Readers and Writers, Simulating Counting Semaphores, Semaphores and Locks in Java, Class countingsemaphore, Class mutexlock, Class Semaphore, Class ReentrantLock, Example: Java Bounded Buffer, Semaphores and Locks in Win32, CRITICAL SECTION, Mutex, Semaphore, Events, Other Synchronization Functions, Example: C++/Win32 Bounded Buffer, Semaphores and Locks in Pthreads, Mutex, Semaphore, Another Note on Shared Memory Consistency, Tracing, Testing, and Replay for Semaphores and Locks, Nondeterministic Testing with the Lockset Algorithm, Simple SYN-Sequences for Semaphores and Locks, Tracing and Replaying Simple PV-Sequences and LockUnlock-Sequences, Deadlock Detection, Reachability Testing for Semaphores and Locks, Putting It All Together, 160 Further Reading, 163 References, 164 Exercises, Monitors Definition of Monitors, Mutual Exclusion, Condition Variables and SC Signaling, Monitor-Based Solutions to Concurrent Programming Problems, Simulating Counting Semaphores, Simulating Binary Semaphores, Dining Philosophers, Readers and Writers, 187
10 viii CONTENTS 4.3 Monitors in Java, Better countingsemaphore, notify vs. notifyall, Simulating Multiple Condition Variables, Monitors in Pthreads, Pthreads Condition Variables, Condition Variables in J2SE 5.0, Signaling Disciplines, Signal-and-Urgent-Wait, Signal-and-Exit, Urgent-Signal-and-Continue, Comparing SU and SC Signals, Using Semaphores to Implement Monitors, SC Signaling, SU Signaling, Monitor Toolbox for Java, Toolbox for SC Signaling in Java, Toolbox for SU Signaling in Java, Monitor Toolbox for Win32/C++/Pthreads, Toolbox for SC Signaling in C++/Win32/Pthreads, Toolbox for SU Signaling in C++/Win32/Pthreads, Nested Monitor Calls, Tracing and Replay for Monitors, Simple M-Sequences, Tracing and Replaying Simple M-Sequences, Other Approaches to Program Replay, Testing Monitor-Based Programs, M-Sequences, Determining the Feasibility of an M-Sequence, Determining the Feasibility of a Communication-Sequence, Reachability Testing for Monitors, Putting It All Together, 235 Further Reading, 243 References, 243 Exercises, Message Passing Channel Objects, Channel Objects in Java, Channel Objects in C++/Win32, Rendezvous, Selective Wait, 272
11 CONTENTS ix 5.4 Message-Based Solutions to Concurrent Programming Problems, Readers and Writers, Resource Allocation, Simulating Counting Semaphores, Tracing, Testing, and Replay for Message-Passing Programs, SR-Sequences, Simple SR-Sequences, Determining the Feasibility of an SR-Sequence, Deterministic Testing, Reachability Testing for Message-Passing Programs, Putting It All Together, 299 Further Reading, 304 References, 304 Exercises, Message Passing in Distributed Programs TCP Sockets, Channel Reliability, TCP Sockets in Java, Java TCP Channel Classes, Classes TCPSender and TCPMailbox, Classes TCPSynchronousSender and TCPSynchronousMailbox, Class TCPSelectableSynchronousMailbox, Timestamps and Event Ordering, Event-Ordering Problems, Local Real-Time Clocks, Global Real-Time Clocks, Causality, Integer Timestamps, Vector Timestamps, Timestamps for Programs Using Messages and Shared Variables, Message-Based Solutions to Distributed Programming Problems, Distributed Mutual Exclusion, Distributed Readers and Writers, Alternating Bit Protocol, Testing and Debugging Distributed Programs, Object-Based Sequences, Simple Sequences, 362
12 x CONTENTS Tracing, Testing, and Replaying CARC-Sequences and CSC-Sequences, Putting It All Together, Other Approaches to Replaying Distributed Programs, 371 Further Reading, 374 References, 375 Exercises, Testing and Debugging Concurrent Programs Synchronization Sequences of Concurrent Programs, Complete Events vs. Simple Events, Total Ordering vs. Partial Ordering, Paths of Concurrent Programs, Defining a Path, Path-Based Testing and Coverage Criteria, Definitions of Correctness and Faults for Concurrent Programs, Defining Correctness for Concurrent Programs, Failures and Faults in Concurrent Programs, Deadlock, Livelock, and Starvation, Approaches to Testing Concurrent Programs, Nondeterministic Testing, Deterministic Testing, Combinations of Deterministic and Nondeterministic Testing, Reachability Testing, Reachability Testing Process, SYN-Sequences for Reachability Testing, Race Analysis of SYN-Sequences, Timestamp Assignment, Computing Race Variants, Reachability Testing Algorithm, Research Directions, 447 Further Reading, 449 References, 449 Exercises, 452 Index 457
13 PREFACE This is a textbook on multithreaded programming. The objective of this book is to teach students about languages and libraries for multithreaded programming, to help students develop problem-solving and programming skills, and to describe and demonstrate various testing and debugging techniques that have been developed for multithreaded programs over the past 20 years. It covers threads, semaphores, locks, monitors, message passing, and the relevant parts of Java, the POSIX Pthreads library, and the Windows Win32 Application Programming Interface (API). The book is unique in that it provides in-depth coverage on testing and debugging multithreaded programs, a topic that typically receives little attention. The title Modern Multithreading reflects the fact that there are effective and relatively new testing and debugging techniques for multithreaded programs. The material in this book was developed in concurrent programming courses that the authors have taught for 20 years. This material includes results from the authors research in concurrent programming, emphasizing tools and techniques that are of practical use. A class library has been implemented to provide working examples of all the material that is covered. Classroom Use In our experience, students have a hard time learning to write concurrent programs. If they manage to get their programs to run, they usually encounter deadlocks and other intermittent failures, and soon discover how difficult it is to reproduce the failures and locate the cause of the problem. Essentially, they have no way to check the correctness of their programs, which interferes with learning. Instructors face the same problem when grading multithreaded programs. It xi
14 xii PREFACE is tedious, time consuming, and often impossible to assess student programs by hand. The class libraries that we have developed, and the testing techniques they support, can be used to assess student programs. When we assign programming problems in our courses, we also provide test cases that the students must use to assess the correctness of their programs. This is very helpful for the students and the instructors. This book is designed for upper-level undergraduates and graduate students in computer science. It can be used as a main text in a concurrent programming course or could be used as a supplementary text for an operating systems course or a software engineering course. Since the text emphasizes practical material, provides working code, and addresses testing and debugging problems that receive little or no attention in many other books, we believe that it will also be helpful to programmers in industry. The text assumes that students have the following background: ž Programming experience as typically gained in CS 1 and CS 2 courses. ž Knowledge of elementary data structures as learned in a CS 2 course. ž An understanding of Java fundamentals. Students should be familiar with object-oriented programming in Java, but no advanced knowledge is necessary. ž An understanding of C++ fundamentals. We use only the basic objectoriented programming features of C++. ž A prior course on operating systems is helpful but not required. We have made an effort to minimize the differences between our Java and C++ programs. We use object-oriented features that are common to both languages, and the class library has been implemented in both languages. Although we don t illustrate every example in both Java and C++, the differences are very minor and it is easy to translate program examples from one language to the other. Content The book has seven chapters. Chapter 1 defines operating systems terms such as process, thread, andcontext switch. It then shows how to create threads, first in Java and then in C++ using both the POSIX Pthreads library and the Win32 API. A C++ Thread class is provided to hide the details of thread creation in Pthreads/Win32. C++ programs that use the Thread class look remarkably similar to multithreaded Java programs. Fundamental concepts, such as atomicity and nondeterminism, are described using simple program examples. Chapter 1 ends by listing the issues and problems that arise when testing and debugging multithreaded programs. To illustrate the interesting things to come, we present a simple multithreaded C++ program that is capable of tracing and replaying its own executions. Chapter 2 introduces concurrent programming by describing various solutions to the critical section problem. This problem is easy to understand but hard
15 PREFACE xiii to solve. The advantage of focusing on this problem is that it can be solved without introducing complicated new programming constructs. Students gain a quick appreciation for the programming skills that they need to acquire. Chapter 2 also demonstrates how to trace and replay Peterson s solution to the critical section problem, which offers a straightforward introduction to several testing and debugging issues. The synchronization library implements the various techniques that are described. Chapters 3, 4, and 5 cover semaphores, monitors and message passing, respectively. Each chapter describes one of these constructs and shows how to use it to solve programming problems. Semaphore and Lock classes for Java and C++/Win32/Pthreads are presented in Chapter 3. Chapter 4 presents monitor classes for Java and C++/Win32/Pthreads. Chapter 5 presents mailbox classes with send/receive methods and a selective wait statement. These chapters also cover the built-in support that Win32 and Pthreads provide for these constructs, as well as the support provided by J2SE 5.0 (Java 2 Platform, Standard Edition 5.0). Each chapter addresses a particular testing or debugging problem and shows how to solve it. The synchronization library implements the testing and debugging techniques so that students can apply them to their own programs. Chapter 6 covers message passing in a distributed environment. It presents several Java mailbox classes that hide the details of TCP message passing and shows how to solve several distributed programming problems in Java. It also shows how to test and debug programs in a distributed environment (e.g., accurately tracing program executions by using vector timestamps). This chapter by no means provides complete coverage of distributed programming. Rather, it is meant to introduce students to the difficulty of distributed programming and to show them that the testing and debugging techniques presented in earlier chapters can be extended to work in a distributed environment. The synchronization library implements the various techniques. Chapter 7 covers concepts that are fundamental to testing and debugging concurrent programs. It defines important terms, presents several test coverage criteria for concurrent programs, and describes the various approaches to testing concurrent programs. This chapter organizes and summarizes the testing and debugging material that is presented in depth in Chapters 2 to 6. This organization provides two paths through the text. Instructors can cover the testing and debugging material in the last sections of Chapters 2 to 6 as they go through those chapters, or they can cover those sections when they cover Chapter 7. Chapter 7 also discusses reachability testing, which offers a bridge between testing and verification, and is implemented in the synchronization library. Each chapter has exercises at the end. Some of the exercises explore the concepts covered in the chapter, whereas others require a program to be written. In our courses we cover all the chapters and give six homework assignments, two in-class exams, and a project. We usually supplement the text with readings on model checking, process algebra, specification languages, and other research topics.
Real-Time Optimization by Extremum-Seeking Control
Real-Time Optimization by Extremum-Seeking Control Real-Time Optimization by Extremum-Seeking Control KARTIK B. ARIYUR MIROSLAV KRSTIĆ A JOHN WILEY & SONS, INC., PUBLICATION Copyright 2003 by John Wiley
More informationCOMPONENT-ORIENTED PROGRAMMING
COMPONENT-ORIENTED PROGRAMMING COMPONENT-ORIENTED PROGRAMMING ANDY JU AN WANG KAI QIAN Southern Polytechnic State University Marietta, Georgia A JOHN WILEY & SONS, INC., PUBLICATION Copyright 2005 by John
More informationTASK SCHEDULING FOR PARALLEL SYSTEMS
TASK SCHEDULING FOR PARALLEL SYSTEMS Oliver Sinnen Department of Electrical and Computer Engineering The University of Aukland New Zealand TASK SCHEDULING FOR PARALLEL SYSTEMS TASK SCHEDULING FOR PARALLEL
More informationLEGITIMATE APPLICATIONS OF PEER-TO-PEER NETWORKS DINESH C. VERMA IBM T. J. Watson Research Center A JOHN WILEY & SONS, INC., PUBLICATION
LEGITIMATE APPLICATIONS OF PEER-TO-PEER NETWORKS DINESH C. VERMA IBM T. J. Watson Research Center A JOHN WILEY & SONS, INC., PUBLICATION LEGITIMATE APPLICATIONS OF PEER-TO-PEER NETWORKS LEGITIMATE APPLICATIONS
More informationRelational Database Index Design and the Optimizers
Relational Database Index Design and the Optimizers DB2, Oracle, SQL Server, et al. Tapio Lahdenmäki Michael Leach A JOHN WILEY & SONS, INC., PUBLICATION Relational Database Index Design and the Optimizers
More informationLEGITIMATE APPLICATIONS OF PEER-TO-PEER NETWORKS
LEGITIMATE APPLICATIONS OF PEER-TO-PEER NETWORKS DINESH C. VERMA IBM T. J. Watson Research Center A JOHN WILEY & SONS, INC., PUBLICATION LEGITIMATE APPLICATIONS OF PEER-TO-PEER NETWORKS LEGITIMATE APPLICATIONS
More informationMicroprocessor Theory
Microprocessor Theory and Applications with 68000/68020 and Pentium M. RAFIQUZZAMAN, Ph.D. Professor California State Polytechnic University Pomona, California and President Rafi Systems, Inc. WILEY A
More informationHASHING IN COMPUTER SCIENCE FIFTY YEARS OF SLICING AND DICING
HASHING IN COMPUTER SCIENCE FIFTY YEARS OF SLICING AND DICING Alan G. Konheim JOHN WILEY & SONS, INC., PUBLICATION HASHING IN COMPUTER SCIENCE HASHING IN COMPUTER SCIENCE FIFTY YEARS OF SLICING AND DICING
More informationDIFFERENTIAL EQUATION ANALYSIS IN BIOMEDICAL SCIENCE AND ENGINEERING
DIFFERENTIAL EQUATION ANALYSIS IN BIOMEDICAL SCIENCE AND ENGINEERING DIFFERENTIAL EQUATION ANALYSIS IN BIOMEDICAL SCIENCE AND ENGINEERING ORDINARY DIFFERENTIAL EQUATION APPLICATIONS WITH R William E. Schiesser
More informationCOSO Enterprise Risk Management
COSO Enterprise Risk Management COSO Enterprise Risk Management Establishing Effective Governance, Risk, and Compliance Processes Second Edition ROBERT R. MOELLER John Wiley & Sons, Inc. Copyright # 2007,
More informationModern Experimental Design
Modern Experimental Design THOMAS P. RYAN Acworth, GA Modern Experimental Design Modern Experimental Design THOMAS P. RYAN Acworth, GA Copyright C 2007 by John Wiley & Sons, Inc. All rights reserved.
More informationAlgorithms and Parallel Computing
Algorithms and Parallel Computing Algorithms and Parallel Computing Fayez Gebali University of Victoria, Victoria, BC A John Wiley & Sons, Inc., Publication Copyright 2011 by John Wiley & Sons, Inc. All
More informationPractical Database Programming with Visual Basic.NET
Practical Database Programming with Visual Basic.NET IEEE Press 445 Hoes Lane Piscataway, NJ 08854 IEEE Press Editorial Board Lajos Hanzo, Editor in Chief R. Abari M. El-Hawary S. Nahavandi J. Anderson
More informationMODERN MULTITHREADING
MODERN MULTITHREADING Implementing, Testing, and Debugging Multithreaded Java and C++/Pthreads/Win32 Programs RICHARD H. CARVER KUO-CHUNG TAI A JOHN WILEY & SONS, INC., PUBLICATION MODERN MULTITHREADING
More informationIP MULTICAST WITH APPLICATIONS TO IPTV AND MOBILE DVB-H
IP MULTICAST WITH APPLICATIONS TO IPTV AND MOBILE DVB-H Daniel Minoli A JOHN WILEY & SONS, INC., PUBLICATION IP MULTICAST WITH APPLICATIONS TO IPTV AND MOBILE DVB-H IP MULTICAST WITH APPLICATIONS TO
More informationRecall from Chapter 1 that a data race is a failure to correctly implement critical sections for non-atomic shared variable accesses.
3.10 Tracing, Testing, and Replay for Semaphores and Locks Outline: A technique for detecting violations of mutual exclusion. Tracing and replaying executions during debugging. Deadlock detection Reachability
More informationOVER 750 QUESTIONS AND 55 TASK-BASED SIMULATIONS! CPA EXAM REVIEW. Auditing and Attestation. O. Ray Whittington, CPA, PhD Patrick R.
OVER 750 QUESTIONS AND 55 TASK-BASED SIMULATIONS! 2012 CPA EXAM REVIEW Auditing and Attestation O. Ray Whittington, CPA, PhD Patrick R. Delaney, CPA, PhD WILEY CPA EXAM REVIEW WILEY EXAM REVIEW Auditing
More informationAgile Database Techniques Effective Strategies for the Agile Software Developer. Scott W. Ambler
Agile Database Techniques Effective Strategies for the Agile Software Developer Scott W. Ambler Agile Database Techniques Effective Strategies for the Agile Software Developer Agile Database Techniques
More information7 Windows Tweaks. A Comprehensive Guide to Customizing, Increasing Performance, and Securing Microsoft Windows 7. Steve Sinchak
Take control of Windows 7 Unlock hidden settings Rev up your network Disable features you hate, for good Fine-tune User Account control Turbocharge online speed Master the taskbar and start button Customize
More informationWIRELESS SENSOR NETWORKS A Networking Perspective Edited by Jun Zheng Abbas Jamalipour A JOHN WILEY & SONS, INC., PUBLICATION WIRELESS SENSOR NETWORKS IEEE Press 445 Hoes Lane Piscataway, NJ 08854 IEEE
More informationStudy Guide. Robert Schmidt Dane Charlton
Study Guide Study Guide Robert Schmidt Dane Charlton Senior Acquisitions Editor: Kenyon Brown Development Editor: Candace English Technical Editors: Eric Biller and Brian Atkinson Production Editor: Christine
More informationSynchronization. CS 475, Spring 2018 Concurrent & Distributed Systems
Synchronization CS 475, Spring 2018 Concurrent & Distributed Systems Review: Threads: Memory View code heap data files code heap data files stack stack stack stack m1 m1 a1 b1 m2 m2 a2 b2 m3 m3 a3 m4 m4
More informationLinux Command Line and Shell Scripting Bible. Third Edtion
Linux Command Line and Shell Scripting Bible Third Edtion Linux Command Line and Shell Scripting BIBLE Third Edition Richard Blum Christine Bresnahan Linux Command Line and Shell Scripting Bible, Third
More informationMulti-Core Programming
Multi-Core Programming Increasing Performance through Software Multi-threading Shameem Akhter Jason Roberts Intel PRESS Copyright 2006 Intel Corporation. All rights reserved. ISBN 0-9764832-4-6 No part
More informationCS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University
CS 571 Operating Systems Midterm Review Angelos Stavrou, George Mason University Class Midterm: Grading 2 Grading Midterm: 25% Theory Part 60% (1h 30m) Programming Part 40% (1h) Theory Part (Closed Books):
More informationMastering UNIX Shell Scripting
Mastering UNIX Shell Scripting Bash, Bourne, and Korn Shell Scripting for Programmers, System Administrators, and UNIX Gurus Second Edition Randal K. Michael Wiley Publishing, Inc. Mastering UNIX Shell
More informationRead & Download (PDF Kindle) Modern Multithreading: Implementing, Testing, And Debugging Multithreaded Java And C++/Pthreads/Win32 Programs
Read & Download (PDF Kindle) Modern Multithreading: Implementing, Testing, And Debugging Multithreaded Java And C++/Pthreads/Win32 Programs Master the essentials of concurrent programming,including testing
More informationPROCESSES & THREADS. Charles Abzug, Ph.D. Department of Computer Science James Madison University Harrisonburg, VA Charles Abzug
PROCESSES & THREADS Charles Abzug, Ph.D. Department of Computer Science James Madison University Harrisonburg, VA 22807 Voice Phone: 540-568-8746; Cell Phone: 443-956-9424 E-mail: abzugcx@jmu.edu OR CharlesAbzug@ACM.org
More informationOutline: SYN-sequences for distributed Java programs that use classes TCPSender and TCPMailbox tracing, replay and feasibility
6.5 Testing and Debugging Distributed Programs Outline: SYN-sequences for distributed Java programs that use classes TCPSender and TCPMailbox tracing, replay and feasibility Let DP be a distributed program:
More informationCSE Traditional Operating Systems deal with typical system software designed to be:
CSE 6431 Traditional Operating Systems deal with typical system software designed to be: general purpose running on single processor machines Advanced Operating Systems are designed for either a special
More informationTHE ARCHITECTURE OF COMPUTER HARDWARE, SYSTEM SOFTWARE, AND NETWORKING
FOURTH EDITION THE ARCHITECTURE OF COMPUTER HARDWARE, SYSTEM SOFTWARE, AND NETWORKING AN INFORMATION TECHNOLOGY APPROACH Irv Englander Bentley University John Wiley & Sons, Inc. Vice President & Executive
More informationChapter 5 Concurrency: Mutual Exclusion and Synchronization
Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent
More information1. Introduction to Concurrent Programming
1. Introduction to Concurrent Programming A concurrent program contains two or more threads that execute concurrently and work together to perform some task. When a program is executed, the operating system
More informationBeginning Transact-SQL with SQL Server 2000 and Paul Turley with Dan Wood
Beginning Transact-SQL with SQL Server 2000 and 2005 Paul Turley with Dan Wood Beginning Transact-SQL with SQL Server 2000 and 2005 Beginning Transact-SQL with SQL Server 2000 and 2005 Paul Turley with
More informationOracle PL/SQL. DUMmIES. by Michael Rosenblum and Dr. Paul Dorsey FOR
Oracle PL/SQL FOR DUMmIES by Michael Rosenblum and Dr. Paul Dorsey Oracle PL/SQL For Dummies Published by Wiley Publishing, Inc. 111 River Street Hoboken, NJ 07030-5774 www.wiley.com Copyright 2006 by
More informationOperating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy
Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference
More informationJoin the p2p.wrox.com. Wrox Programmer to Programmer. Beginning PHP 5.3. Matt Doyle
Join the discussion @ p2p.wrox.com Wrox Programmer to Programmer Beginning PHP 5.3 Matt Doyle Programmer to Programmer Get more out of WROX.com Interact Take an active role online by participating in our
More informationModule 6: Process Synchronization. Operating System Concepts with Java 8 th Edition
Module 6: Process Synchronization 6.1 Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores
More informationProfessional ASP.NET 2.0 Databases. Thiru Thangarathinam
Professional ASP.NET 2.0 Databases Thiru Thangarathinam Professional ASP.NET 2.0 Databases Professional ASP.NET 2.0 Databases Thiru Thangarathinam Professional ASP.NET 2.0 Databases Published by Wiley
More information4.10 Tracing and Replay for Monitors
4.10 Tracing and Replay for Monitors Outline: simple M-sequences of monitor-based programs tracing and replaying simple M-sequences during debugging modifying the SC and SU monitor toolboxes to support
More informationMagical Math G ROOVY G EOMETRY. Games and Activities That Make Math Easy and Fun. Lynette Long. John Wiley & Sons, Inc.
Magical Math G ROOVY G EOMETRY Games and Activities That Make Math Easy and Fun Lynette Long John Wiley & Sons, Inc. G ROOVY G EOMETRY Also in the Magical Math series Dazzling Division Delightful Decimals
More informationLinux Command Line and Shell Scripting Bible
Linux Command Line and Shell Scripting Bible Richard Blum Wiley Publishing, Inc. Linux Command Line and Shell Scripting Bible Linux Command Line and Shell Scripting Bible Richard Blum Wiley Publishing,
More informationChapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles
Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent
More informationBeginning Web Programming with HTML, XHTML, and CSS. Second Edition. Jon Duckett
Beginning Web Programming with HTML, XHTML, and CSS Second Edition Jon Duckett Beginning Web Programming with HTML, XHTML, and CSS Introduction............................................... xxiii Chapter
More informationLet M be a monitor that is implemented using one of the monitor toolboxes.
4.10 Tracing and Replay for Monitors Outline: simple M-sequences of monitor-based programs tracing and replaying simple M-sequences during debugging modifying the SC and SU monitor toolboxes to support
More informationENGR 3950U / CSCI 3020U UOIT, Fall 2012 Quiz on Process Synchronization SOLUTIONS
Name: Student Number: SOLUTIONS ENGR 3950U / CSCI 3020U (Operating Systems) Quiz on Process Synchronization November 13, 2012, Duration: 40 Minutes (10 questions and 8 pages, 45 Marks) Instructor: Dr.
More informationSynchronization COMPSCI 386
Synchronization COMPSCI 386 Obvious? // push an item onto the stack while (top == SIZE) ; stack[top++] = item; // pop an item off the stack while (top == 0) ; item = stack[top--]; PRODUCER CONSUMER Suppose
More informationMore Synchronization; Concurrency in Java. CS 475, Spring 2018 Concurrent & Distributed Systems
More Synchronization; Concurrency in Java CS 475, Spring 2018 Concurrent & Distributed Systems Review: Semaphores Synchronization tool that provides more sophisticated ways (than Mutex locks) for process
More informationFUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE Mostafa Abd-El-Barr King Fahd University of Petroleum & Minerals (KFUPM) Hesham El-Rewini Southern Methodist University A JOHN WILEY & SONS, INC PUBLICATION
More informationChapter 2 Processes and Threads
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 2 Processes and Threads The Process Model Figure 2-1. (a) Multiprogramming of four programs. (b) Conceptual model of four independent,
More informationConcurrency. Chapter 5
Concurrency 1 Chapter 5 2 Concurrency Is a fundamental concept in operating system design Processes execute interleaved in time on a single processor Creates the illusion of simultaneous execution Benefits
More informationEI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)
EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture) Dept. of Computer Science & Engineering Chentao Wu wuct@cs.sjtu.edu.cn Download lectures ftp://public.sjtu.edu.cn User:
More informationSynchronization for Concurrent Tasks
Synchronization for Concurrent Tasks Minsoo Ryu Department of Computer Science and Engineering 2 1 Race Condition and Critical Section Page X 2 Algorithmic Approaches Page X 3 Hardware Support Page X 4
More informationProcess Synchronization
CSC 4103 - Operating Systems Spring 2007 Lecture - VI Process Synchronization Tevfik Koşar Louisiana State University February 6 th, 2007 1 Roadmap Process Synchronization The Critical-Section Problem
More informationConcurrent & Distributed Systems Supervision Exercises
Concurrent & Distributed Systems Supervision Exercises Stephen Kell Stephen.Kell@cl.cam.ac.uk November 9, 2009 These exercises are intended to cover all the main points of understanding in the lecture
More informationLecture Topics. Announcements. Today: Concurrency (Stallings, chapter , 5.7) Next: Exam #1. Self-Study Exercise #5. Project #3 (due 9/28)
Lecture Topics Today: Concurrency (Stallings, chapter 5.1-5.4, 5.7) Next: Exam #1 1 Announcements Self-Study Exercise #5 Project #3 (due 9/28) Project #4 (due 10/12) 2 Exam #1 Tuesday, 10/3 during lecture
More informationSynchronization Principles
Synchronization Principles Gordon College Stephen Brinton The Problem with Concurrency Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms
More informationConcurrency: Mutual Exclusion and
Concurrency: Mutual Exclusion and Synchronization 1 Needs of Processes Allocation of processor time Allocation and sharing resources Communication among processes Synchronization of multiple processes
More informationDATABASE DESIGN AND DEVELOPMENT
DATABASE DESIGN AND DEVELOPMENT DATABASE DESIGN AND DEVELOPMENT An Essential Guide for IT Professionals PAULRAJ PONNIAH A JOHN WILEY & SONS, INC., PUBLICATION Copyright 2003 by John Wiley & Sons, Inc.
More information7. Testing and Debugging Concurrent Programs
7. Testing and Debugging Concurrent Programs The purpose of testing is to find program failures => A successful test is a test that causes a program to fail. Ideally, tests are designed before the program
More informationCOMPUTING FOR NUMERICAL METHODS USING VISUAL C++
COMPUTING FOR NUMERICAL METHODS USING VISUAL C++ COMPUTING FOR NUMERICAL METHODS USING VISUAL C++ Shaharuddin Salleh Universiti Teknologi Malaysia Skudai, Johor, Malaysia Albert Y. Zomaya University of
More informationImplementing Security and Tokens: Current Standards, Tools, and Practices
Implementing Email Security and Tokens: Current Standards, Tools, and Practices Sean Turner Russ Housley Wiley Publishing, Inc. Implementing Email Security and Tokens: Current Standards, Tools, and Practices
More informationConcept of a process
Concept of a process In the context of this course a process is a program whose execution is in progress States of a process: running, ready, blocked Submit Ready Running Completion Blocked Concurrent
More informationIntroduction to Parallel Programming Part 4 Confronting Race Conditions
Introduction to Parallel Programming Part 4 Confronting Race Conditions Intel Software College Objectives At the end of this module you should be able to: Give practical examples of ways that threads may
More informationProcess Synchronization: Semaphores. CSSE 332 Operating Systems Rose-Hulman Institute of Technology
Process Synchronization: Semaphores CSSE 332 Operating Systems Rose-Hulman Institute of Technology Critical-section problem solution 1. Mutual Exclusion - If process Pi is executing in its critical section,
More informationProcess Synchronization. Mehdi Kargahi School of ECE University of Tehran Spring 2008
Process Synchronization Mehdi Kargahi School of ECE University of Tehran Spring 2008 Producer-Consumer (Bounded Buffer) Producer Consumer Race Condition Producer Consumer Critical Sections Structure of
More informationSemaphore. Originally called P() and V() wait (S) { while S <= 0 ; // no-op S--; } signal (S) { S++; }
Semaphore Semaphore S integer variable Two standard operations modify S: wait() and signal() Originally called P() and V() Can only be accessed via two indivisible (atomic) operations wait (S) { while
More informationProcess Synchronization(2)
CSE 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Computer Science and Engineering York University Semaphores Problems with the software solutions. Not easy
More informationProcess Synchronization
Process Synchronization Concurrent access to shared data in the data section of a multi-thread process, in the shared memory of multiple processes, or in a shared file Although every example in this chapter
More informationApplication Programming
Multicore Application Programming For Windows, Linux, and Oracle Solaris Darryl Gove AAddison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris
More informationDeadlock. Concurrency: Deadlock and Starvation. Reusable Resources
Concurrency: Deadlock and Starvation Chapter 6 Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other No efficient solution Involve conflicting
More informationIT 540 Operating Systems ECE519 Advanced Operating Systems
IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (5 th Week) (Advanced) Operating Systems 5. Concurrency: Mutual Exclusion and Synchronization 5. Outline Principles
More informationCOMPUTATIONAL DYNAMICS
COMPUTATIONAL DYNAMICS THIRD EDITION AHMED A. SHABANA Richard and Loan Hill Professor of Engineering University of Illinois at Chicago A John Wiley and Sons, Ltd., Publication COMPUTATIONAL DYNAMICS COMPUTATIONAL
More informationNetworking. 11th Edition. by Doug Lowe
Networking 11th Edition by Doug Lowe Networking For Dummies, 11th Edition Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com Copyright 2016 by John Wiley & Sons,
More informationProcess Synchronization(2)
EECS 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Semaphores Problems with the software solutions.
More informationConcurrent, Real-Time and Distributed Programming in Java
Concurrent, Real-Time and Distributed Programming in Java FOCUS SERIES Jean-Charles Pomerol Concurrent, Real-Time and Distributed Programming in Java Threads, RTSJ and RMI Badr Benmammar First published
More informationJ2EE TM Best Practices Java TM Design Patterns, Automation, and Performance
J2EE TM Best Practices Java TM Design Patterns, Automation, and Performance Darren Broemmer Wiley Publishing, Inc. Dear Valued Customer, The WILEY advantage We realize you re a busy professional with
More informationCSI3131 Final Exam Review
CSI3131 Final Exam Review Final Exam: When: April 24, 2015 2:00 PM Where: SMD 425 File Systems I/O Hard Drive Virtual Memory Swap Memory Storage and I/O Introduction CSI3131 Topics Process Computing Systems
More informationSynchronization Possibilities and Features in Java
Abstract Synchronization Possibilities and Features in Java Beqir Hamidi Lindita Hamidi ILIRIA College Bregu i Diellit, st. Gazmend Zajmi, no. 75 p.n., 10 000 Prishtine-Kosove -Prishtine beqirhamidi@hotmail.com,
More informationDeadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1
Deadlock Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1 Recap: Synchronization Race condition A situation when two or more threads read and write shared
More informationConcurrency pros and cons. Concurrent Programming Problems. Linked list example. Linked list example. Mutual Exclusion. Concurrency is good for users
Concurrency pros and cons Con Programming Problems OS Spring 2011 Concurrency is good for users One of the reasons for multiprogramming Working on the same problem, simultaneous execution of programs,
More informationInterprocess Communication By: Kaushik Vaghani
Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the
More informationSyllabus CSCI 405 Operating Systems Fall 2018
Syllabus CSCI 405 Operating Systems Fall 2018 1.0 General Information Class Time: Monday/Wednesday/Friday 11:00 AM - 11:50 AM Class Location: 317 Thompson Instructor: Dr. Deepti Joshi; Office: 224 Thompson;
More informationModels of concurrency & synchronization algorithms
Models of concurrency & synchronization algorithms Lecture 3 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu
More informationOperating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017
Operating Systems Lecture 4 - Concurrency and Synchronization Adrien Krähenbühl Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Mutual exclusion Hardware solutions Semaphores IPC: Message passing
More informationExploiting Distributed Resources in Wireless, Mobile and Social Networks Frank H. P. Fitzek and Marcos D. Katz
MOBILE CLOUDS Exploiting Distributed Resources in Wireless, Mobile and Social Networks Frank H. P. Fitzek and Marcos D. Katz MOBILE CLOUDS MOBILE CLOUDS EXPLOITING DISTRIBUTED RESOURCES IN WIRELESS,
More informationChapter 6: Synchronization. Operating System Concepts 8 th Edition,
Chapter 6: Synchronization, Silberschatz, Galvin and Gagne 2009 Outline Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization
More informationFundamentals of Operating Systems. Fifth Edition
Fundamentals of Operating Systems Fifth Edition Fundamentals of Operating Systems A.M. Lister University of Queensland R. D. Eager University of Kent at Canterbury Fifth Edition Springer Science+Business
More informationMidterm Exam. October 20th, Thursday NSC
CSE 421/521 - Operating Systems Fall 2011 Lecture - XIV Midterm Review Tevfik Koşar University at Buffalo October 18 th, 2011 1 Midterm Exam October 20th, Thursday 9:30am-10:50am @215 NSC Chapters included
More informationPHP & MySQL. Learn to: Janet Valade. Making Everything Easier! 4th Edition. Create well-formed PHP code that s compliant with PHP 4, 5, and 6
Making Everything Easier! 4th Edition PHP & MySQL Learn to: Create well-formed PHP code that s compliant with PHP 4, 5, and 6 Easily install and set up PHP and MySQL using XAMPP Choose a Web host and secure
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationTo Everyone... iii To Educators... v To Students... vi Acknowledgments... vii Final Words... ix References... x. 1 ADialogueontheBook 1
Contents To Everyone.............................. iii To Educators.............................. v To Students............................... vi Acknowledgments........................... vii Final Words..............................
More informationThe Internet of Things
The Internet of Things The Internet of Things Connecting Objects to the Web Edited by Hakima Chaouchi First published 2010 in Great Britain and the United States by ISTE Ltd and John Wiley & Sons, Inc.
More informationOS06: Monitors in Java
OS06: Monitors in Java Based on Chapter 4 of [Hai17] Jens Lechtenbörger Computer Structures and Operating Systems 2018 1 Introduction 1.1 OS Plan ˆ OS Motivation (Wk 23) ˆ OS Introduction (Wk 23) ˆ Interrupts
More informationLesson 6: Process Synchronization
Lesson 6: Process Synchronization Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization
More information1 OBJECT-ORIENTED PROGRAMMING 1
PREFACE xvii 1 OBJECT-ORIENTED PROGRAMMING 1 1.1 Object-Oriented and Procedural Programming 2 Top-Down Design and Procedural Programming, 3 Problems with Top-Down Design, 3 Classes and Objects, 4 Fields
More informationWhat is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?
What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular
More informationCloud Phone Systems. Andrew Moore. Making Everything Easier! Nextiva Special Edition. Learn:
Making Everything Easier! Nextiva Special Edition Cloud Phone Systems Learn: What cloud phone systems are and how they can benefit your company About the many advantages a cloud phone system offers Features
More informationProcess Synchronization(2)
EECS 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Semaphores Problems with the software solutions.
More informationiwork DUMmIES 2ND EDITION FOR
iwork FOR DUMmIES 2ND EDITION iwork FOR DUMmIES 2ND EDITION by Jesse Feiler iwork For Dummies, 2nd Edition Published by John Wiley & Sons, Inc. 111 River Street Hoboken, NJ 07030-5774 www.wiley.com Copyright
More information