Concurrency and Synchronization: Semaphores in Action

Total Page:16

File Type:pdf, Size:1020Kb

Concurrency and Synchronization: Semaphores in Action CS-350: Fundamentals of Computing Systems Page 1 of 16 Lecture Notes Concurrency and Synchronization: Semaphores in Action In our coverage of semaphore functionality and implementation, we have seen a number of ways that semaphores could come in handy in managing concurrency amongst processes sharing resources or data structures. Broadly speaking, we have seen that semaphores could be used in the following ways: • A binary semaphore initialized to 1 could be used to ensure mutual exclusion, which allows a set of processes to correctly access shared variables such as counters. • A binary semaphore initialized to 0 could be used to force an instruction in one process to wait for the execution of an instruction in another process. This is an example of how semaphores can be used for signaling between processes. • A counting semaphore initialized to K could be used to enforce an upper limit on the number of concurrent uses of a given resource (or service or threads of execution). We will now consider a number of classical problems that are frequently encountered when building computing systems and we will see how semaphores could be used to manage the synchronization issues that arise. The Producer-Consumer Problem In many systems, it is often the case that one process (or more) will be consuming results from one other process (or more). The question is, what sort of synchronization do we need between a (set of) producer(s) and a (set of) consumer(s)? In the following, we will focus on one producer and one consumer, noting that our discussion applies to the general case in which multiple producers and/or consumers exist. First off, let us discuss how the producer and consumer might be communicating. We note that there must be a shared data structure—a buffer—in which the producer “puts” its output and from which the consumer “takes” its input. To that end, we ask the following questions: 1. Are there shared data structures that must be accessed in a mutually exclusive fashion? 2. Is it ever the case that a consumer will wait for a producer? If so, when? 3. Is it ever the case that a producer will wait for a consumer? If so, when? Regarding the first question, we note that the producer and consumer share access to the buffer data structure. Since we do not want this buffer to be left in an inconsistent state, we will require that any access to the buffer be in a mutually exclusive fashion. For that purpose, we will use a mutual exclusion semaphore—let’s call it mutex—which will be initialized to 1. Regarding the second question, we do not want a consumer to actively seek to consume results if there are none to consume. In other words, if there is nothing to consume, a consumer must © Azer Bestavros. All rights reserved. Reproduction or copying (electronic or otherwise) is expressly forbidden except for students enrolled in CS-350. CS-350: Fundamentals of Computing Systems Page 2 of 16 Lecture Notes sleep (or block). Thus, a consumer must wait for a producer “if there is nothing to consume in the buffer”. Regarding the third question, as long as a producer is able to deposit its output in the buffer (for consumers to consume) it does not have to wait. In other words, if the buffer is assumed to be infinite in size, then it will never be the case that a producer will have to wait. If the buffer is finite in size, then a producer must wait if the buffer is “full,” so as not to cause a buffer overflow (or overrun). Infinite Buffer Case: Consider the infinite buffer case. How do we ensure that a consumer will wait for a produced result? This is an instance of one process signaling another. If we use a semaphore out (initialized to 0) for that purpose, then upon producing an output, a producer will signal the out semaphore, and prior to consuming an output, a consumer must wait for the out semaphore. This suggests the code snippets shown in Figure 1. Initialization: sempahore mutex:=1; semaphore out:=0; Producer: Consumer: repeat repeat [produce v]; wait(out); wait(mutex); wait(mutex); put(v); w:=take(); signal(mutex); signal(mutex); signal(out); [consume(w)]; forever forever Figure 1 Producer-Consumer synchronization when buffer is infinite. Finite Buffer Case: With a finite buffer, we must introduce a mechanism that forces the producer to block if there is no space for it to put an item in the buffer. To that end, we use a counting semaphore space which we will use to keep track of available buffer space. Initially, this semaphore will be initialized to k, which is the initial size of the buffer. Before the producer adds an item to the buffer, it should wait on the space semaphore and after the consumer takes an item from the buffer, it should signal the space semaphore (signifying the addition of new space by virtue of the consumption of an item). This suggests the code snippets shown in Figure 2. © Azer Bestavros. All rights reserved. Reproduction or copying (electronic or otherwise) is expressly forbidden except for students enrolled in CS-350. CS-350: Fundamentals of Computing Systems Page 3 of 16 Lecture Notes Initialization: semaphore mutex:=1; semaphore out:=0; semaphore space:=k; Producer: Consumer: repeat repeat [produce v]; wait(out); wait(space); wait(mutex); wait(mutex); w:=take(); put(v); signal(mutex); signal(mutex); signal(space); signal(out); [consume(w)]; forever forever Figure 2 Producer-Consumer synchronization when buffer is finite of size k. [Exercise: Is it OK if we swap the two wait() instructions in the producer and/or consumer code? Is it OK to swap the signal() instructions in the producer and/or consumer code? Explain.] One detail which is not spelled out in the code snippets in Figure 1 and Figure 2 is the specific implementation of the buffer data structure, and thus the specification of the put() and take() functions. We note that this is straightforward. For instance, a finite buffer could be implemented with a circular buffer b[] with two pointers in and out, whereby in is a pointer to the location in b[] into which a new item may be inserted, and out is a pointer to the location in b[] from which a produced item may be consumed as illustrated in Figure 3 and as specified by the pseudo code implementation of put() and take() shown in Figure 4. Figure 3 Implementation of a circular buffer of size k with two pointers in and out. © Azer Bestavros. All rights reserved. Reproduction or copying (electronic or otherwise) is expressly forbidden except for students enrolled in CS-350. CS-350: Fundamentals of Computing Systems Page 4 of 16 Lecture Notes put(v): b[in]:=v; in:=(in+1)mod k; take(): w:=b[out]; out:=(out+1)mod k; return w; Figure 4 Implementation of the put() and take() functions on the circular buffer in Figure 3. It is important to note that our solution of the producer-consumer problem extends with little change to multiple producers and/or multiple consumers. The Readers-Writers Problem In the producer consumer problem, we dealt with a “consumable” data which is produced once and consumed once. We now turn our attention to questions of “access” to data. The simplest forms of access to data are the read and write access. A data item could be any set of bytes— for example a file in a file system, a record or a table in a database, or a page in main memory. Without loss of generality, we assume that we are interested in read/write operations on a file, where it should be understood that by “file” we mean the unit of access granularity. Before proceeding further, let us review what is meant by a read operation on a file, and what is meant by a write operation on a file. Basically, the difference between reading a file and writing a file is that reading a file does not change the content of the file, whereas writing a file does. The above distinction between reading a file and writing a file suggest that if we are keen on ensuring the consistency of the file, we should never allow two concurrent write operations on a file. In other words, we cannot allow two “writers” of the file to gain access to the file concurrently. On the other hand, there is no harm in letting two or more “readers” access the file concurrently. We now ask ourselves the following questions regarding how readers and writers should synchronize their access to a file. 1. When should a reader block? 2. When should a writer block? To answer the first question, we note that a reader should only block if a writer is currently accessing the file. To answer the second question, we note that a writer should block if either one or more readers are currently accessing the file, or if a writer is currently accessing the file. One possible solution for the readers/writers problem is to simply enforce a mutual exclusion policy on file access. Specifically, we use a single binary semaphore (call it “lock”) initialized © Azer Bestavros. All rights reserved. Reproduction or copying (electronic or otherwise) is expressly forbidden except for students enrolled in CS-350. CS-350: Fundamentals of Computing Systems Page 5 of 16 Lecture Notes to 1 and require that any reader and any writer wait on that semaphore before reading/writing the file. In addition, they must signal that semaphore upon completion of reading/writing.
Recommended publications
  • Static Analysis of a Concurrent Programming Language by Abstract Interpretation
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by Concordia University Research Repository STATIC ANALYSIS OF A CONCURRENT PROGRAMMING LANGUAGE BY ABSTRACT INTERPRETATION Maryam Zakeryfar A thesis in The Department of Computer Science and Software Engineering Presented in Partial Fulfillment of the Requirements For the Degree of Doctor of Philosophy (Computer Science) Concordia University Montreal,´ Quebec,´ Canada March 2014 © Maryam Zakeryfar, 2014 Concordia University School of Graduate Studies This is to certify that the thesis prepared By: Mrs. Maryam Zakeryfar Entitled: Static Analysis of a Concurrent Programming Language by Abstract Interpretation and submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy (Computer Science) complies with the regulations of this University and meets the accepted standards with respect to originality and quality. Signed by the final examining committee: Dr. Deborah Dysart-Gale Chair Dr. Weichang Du External Examiner Dr. Mourad Debbabi Examiner Dr. Olga Ormandjieva Examiner Dr. Joey Paquet Examiner Dr. Peter Grogono Supervisor Approved by Dr. V. Haarslev, Graduate Program Director Christopher W. Trueman, Dean Faculty of Engineering and Computer Science Abstract Static Analysis of a Concurrent Programming Language by Abstract Interpretation Maryam Zakeryfar, Ph.D. Concordia University, 2014 Static analysis is an approach to determine information about the program without actually executing it. There has been much research in the static analysis of concurrent programs. However, very little academic research has been done on the formal analysis of message passing or process-oriented languages. We currently miss formal analysis tools and tech- niques for concurrent process-oriented languages such as Erasmus .
    [Show full text]
  • Sleeping Barber
    Sleeping Barber CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. [email protected] Outline • Sleeping Barber USC CSCI 201L Sleeping Barber Overview ▪ The Sleeping Barber problem contains one barber and a number of customers ▪ There are a certain number of waiting seats › If a customer enters and there is a seat available, he will wait › If a customer enters and there is no seat available, he will leave ▪ When the barber isn’t cutting someone’s hair, he sits in his barber chair and sleeps › If the barber is sleeping when a customer enters, he must wake the barber up USC CSCI 201L 3/8 Program ▪ Write a solution to the Sleeping Barber problem. You will need to utilize synchronization and conditions. USC CSCI 201L 4/8 Program Steps – main Method ▪ The SleepingBarber will be the main class, so create the SleepingBarber class with a main method › The main method will instantiate the SleepingBarber › Then create a certain number of Customer threads that arrive at random times • Have the program sleep for a random amount of time between customer arrivals › Have the main method wait to finish executing until all of the Customer threads have finished › Print out that there are no more customers, then wake up the barber if he is sleeping so he can go home for the day USC CSCI 201L 5/8 Program Steps – SleepingBarber ▪ The SleepingBarber constructor will initialize some member variables › Total number of seats in the waiting room › Total number of customers who will be coming into the barber shop › A boolean variable indicating
    [Show full text]
  • Bounded Model Checking for Asynchronous Concurrent Systems
    Bounded Model Checking for Asynchronous Concurrent Systems Manitra Johanesa Rakotoarisoa Department of Computer Architecture Technical University of Catalonia Advisor: Enric Pastor Llorens Thesis submitted to obtain the qualification of Doctor from the Technical University of Catalonia To my mother Contents Abstract xvii Acknowledgments xix 1 Introduction1 1.1 Symbolic Model Checking...........................3 1.1.1 BDD-based approach..........................3 1.1.2 SAT-based Approach..........................6 1.2 Synchronous Versus Asynchronous Systems.................8 1.2.1 Synchronous systems..........................8 1.2.2 Asynchronous systems......................... 10 1.3 Scope of This Work.............................. 11 1.4 Structure of the Thesis............................. 12 2 Background 13 2.1 Transition Systems............................... 13 2.1.1 Definitions............................... 13 2.1.2 Symbolic Representation........................ 15 2.2 Other Models for Concurrent Systems.................... 17 2.2.1 Kripke Structure............................ 17 2.2.2 Petri Nets................................ 21 2.2.3 Automata................................ 22 2.3 Linear Temporal Logic............................. 24 2.4 Satisfiability Problem............................. 26 2.4.1 DPLL Algorithm............................ 27 2.4.2 Stålmarck’s Algorithm......................... 28 2.4.3 Other Methods for Solving SAT................... 32 2.5 Bounded Model Checking........................... 34 2.5.1 BMC Idea...............................
    [Show full text]
  • Using TOST in Teaching Operating Systems and Concurrent Programming Concepts
    Advances in Science, Technology and Engineering Systems Journal Vol. 5, No. 6, 96-107 (2020) ASTESJ www.astesj.com ISSN: 2415-6698 Special Issue on Multidisciplinary Innovation in Engineering Science & Technology Using TOST in Teaching Operating Systems and Concurrent Programming Concepts Tzanko Golemanov*, Emilia Golemanova Department of Computer Systems and Technologies, University of Ruse, Ruse, 7020, Bulgaria A R T I C L E I N F O A B S T R A C T Article history: The paper is aimed as a concise and relatively self-contained description of the educational Received: 30 July, 2020 environment TOST, used in teaching and learning Operating Systems basics such as Accepted: 15 October, 2020 Processes, Multiprogramming, Timesharing, Scheduling strategies, and Memory Online: 08 November, 2020 management. TOST also aids education in some important IT concepts such as Deadlock, Mutual exclusion, and Concurrent processes synchronization. The presented integrated Keywords: environment allows the students to develop and run programs in two simple programming Operating Systems languages, and at the same time, the data in the main system tables can be monitored. The Concurrent Programming paper consists of a description of TOST system, the features of the built-in programming Teaching Tools languages, and demonstrations of teaching the basic Operating Systems principles. In addition, some of the well-known concurrent processing problems are solved to illustrate TOST usage in parallel programming teaching. 1. Introduction • Visual OS simulators This paper is an extension of work originally presented in 29th The systems from the first group (MINIX [2], Nachos [3], Xinu Annual Conference of the European Association for Education in [4], Pintos [5], GeekOS [6]) run on real hardware and are too Electrical and Information Engineering (EAEEIE) [1].
    [Show full text]
  • 5 Classical IPC Problems
    5 Classical IPC Problems 2 The operating systems literature is full of interesting problems that have been widely discussed and analyzed using a variety of synchronization methods. In the following sections we will examine four of the better-known problems. OPERATING SYSTEMS CLASSICAL IPC PROBLEMS 5.1 The Dining Philosophers Problem 5.1 The Dining Philosophers Problem 3 4 Since 1965 (Dijkstra posed and solved this synchronization problem), everyone inventing a new synchronization primitive has tried to demonstrate its abilities by solving the dining philosophers problem. The problem can be stated quite simply as follows. Five philosophers are seated around a circular table. Each philosopher has a plate of spaghetti. The spaghetti is so slippery that a philosopher needs two forks to eat it. Between each pair of plates, there is only one fork. Philosophers eat/think, eating needs 2 forks, pick one fork at a time. How to prevent deadlock? 5.1 The Dining Philosophers Problem 5.1 The Dining Philosophers Problem 5 6 The life of a philosopher consists of alternate periods It has been pointed out that the two-fork requirement of eating and thinking. This is something of an is somewhat artificial; perhaps we should switch from abstraction, even for philosophers, but the other Italian food to Chinese food, replacing rice for activities are irrelevant here. When a philosopher spaghetti and chopsticks for forks. gets hungry, she tries to acquire her left and right forks, one at a time, in either order. If successful in The key question is: Can you write a program for each acquiring two forks, she eats for a while, then puts philosopher that does what it is supposed to do and down the forks, and continues to think.
    [Show full text]
  • Concurrent Programming CLASS NOTES
    COMP 409 Concurrent Programming CLASS NOTES Based on professor Clark Verbrugge's notes Format and figures by Gabriel Lemonde-Labrecque Contents 1 Lecture: January 4th, 2008 7 1.1 Final Exam . .7 1.2 Syllabus . .7 2 Lecture: January 7th, 2008 8 2.1 What is a thread (vs a process)? . .8 2.1.1 Properties of a process . .8 2.1.2 Properties of a thread . .8 2.2 Lifecycle of a process . .9 2.3 Achieving good performances . .9 2.3.1 What is speedup? . .9 2.3.2 What are threads good for then? . 10 2.4 Concurrent Hardware . 10 2.4.1 Basic Uniprocessor . 10 2.4.2 Multiprocessors . 10 3 Lecture: January 9th, 2008 11 3.1 Last Time . 11 3.2 Basic Hardware (continued) . 11 3.2.1 Cache Coherence Issue . 11 3.2.2 On-Chip Multiprocessing (multiprocessors) . 11 3.3 Granularity . 12 3.3.1 Coarse-grained multi-threading (CMT) . 12 3.3.2 Fine-grained multithreading (FMT) . 12 3.4 Simultaneous Multithreading (SMT) . 12 4 Lecture: January 11th, 2008 14 4.1 Last Time . 14 4.2 \replay architecture" . 14 4.3 Atomicity . 15 5 Lecture: January 14th, 2008 16 6 Lecture: January 16th, 2008 16 6.1 Last Time . 16 6.2 At-Most-Once (AMO) . 16 6.3 Race Conditions . 18 7 Lecture: January 18th, 2008 19 7.1 Last Time . 19 7.2 Mutual Exclusion . 19 8 Lecture: January 21st, 2008 21 8.1 Last Time . 21 8.2 Kessel's Algorithm . 22 8.3 Brief Interruption to Introduce Java and PThreads .
    [Show full text]
  • A Structured Programming Approach to Data Ebook
    A STRUCTURED PROGRAMMING APPROACH TO DATA PDF, EPUB, EBOOK Coleman | 222 pages | 27 Aug 2012 | Springer-Verlag New York Inc. | 9781468479874 | English | New York, NY, United States A Structured Programming Approach to Data PDF Book File globbing in Linux. It seems that you're in Germany. De Marco's approach [13] consists of the following objects see figure : [12]. Get print book. Bibliographic information. There is no reason to discard it. No Downloads. Programming is becoming a technology, a theory known as structured programming is developing. Visibility Others can see my Clipboard. From Wikipedia, the free encyclopedia. ALGOL 60 implementation Call stack Concurrency Concurrent programming Cooperating sequential processes Critical section Deadly embrace deadlock Dining philosophers problem Dutch national flag problem Fault-tolerant system Goto-less programming Guarded Command Language Layered structure in software architecture Levels of abstraction Multithreaded programming Mutual exclusion mutex Producer—consumer problem bounded buffer problem Program families Predicate transformer semantics Process synchronization Self-stabilizing distributed system Semaphore programming Separation of concerns Sleeping barber problem Software crisis Structured analysis Structured programming THE multiprogramming system Unbounded nondeterminism Weakest precondition calculus. Comments and Discussions. The code block runs at most once. Latest Articles. Show all. How any system is developed can be determined through a data flow diagram. The result of structured analysis is a set of related graphical diagrams, process descriptions, and data definitions. Therefore, when changes are made to that type of data, the corresponding change must be made at each location that acts on that type of data within the program. It means that the program uses single-entry and single-exit elements.
    [Show full text]
  • A Language-Independent Static Checking System for Coding Conventions
    A Language-Independent Static Checking System for Coding Conventions Sarah Mount A thesis submitted in partial fulfilment of the requirements of the University of Wolverhampton for the degree of Doctor of Philosophy 2013 This work or any part thereof has not previously been presented in any form to the University or to any other body whether for the purposes of as- sessment, publication or for any other purpose (unless otherwise indicated). Save for any express acknowledgements, references and/or bibliographies cited in the work, I confirm that the intellectual content of the work is the result of my own efforts and of no other person. The right of Sarah Mount to be identified as author of this work is asserted in accordance with ss.77 and 78 of the Copyright, Designs and Patents Act 1988. At this date copyright is owned by the author. Signature: . Date: . Abstract Despite decades of research aiming to ameliorate the difficulties of creat- ing software, programming still remains an error-prone task. Much work in Computer Science deals with the problem of specification, or writing the right program, rather than the complementary problem of implementation, or writing the program right. However, many desirable software properties (such as portability) are obtained via adherence to coding standards, and there- fore fall outside the remit of formal specification and automatic verification. Moreover, code inspections and manual detection of standards violations are time consuming. To address these issues, this thesis describes Exstatic, a novel framework for the static detection of coding standards violations. Unlike many other static checkers Exstatic can be used to examine code in a variety of lan- guages, including program code, in-line documentation, markup languages and so on.
    [Show full text]
  • Homework 3 Solutions ECE 426 Spring 2018 Gabriel Kuri
    Homework 3 Solutions ECE 426 Spring 2018 Gabriel Kuri 2 Problems - 50 pts total 1 (25 pts) The sleeping barber problem is a classic process synchronization problem, where a barber shop has one barber, one barber chair, and n chairs for waiting customers, if any, to sit and wait. If there are no customers present, the barber sits down in the barber chair and sleeps. When a customer arrives, he has to wake up the sleeping barber. If additional customers arrive while the barber is cutting a customer's hair, they either sit down (if there are empty chairs) or leave the shop (if all chairs are full). Consider a slight modification to the classic problem, where there are m barbers and m chairs at the barber shop, instead of just one. Write a program in C or pseudocode using semaphores to implement this problem (with m barbers and m barber chairs). 1 semaphore waiting room mutex = 1 ; 2 semaphore barber room mutex = 1 ; 3 semaphore barber c h a i r f r e e = k ; 4 semaphore sleepy b a r b e r s = 0 ; 5 semaphore barber c h a i r s [ k ] = f0 , 0 , 0 , . g ; 6 i n t barber c h a i r s t a t e s [ k ] = f0 , 0 , 0 , . g ; 7 i n t num w a i t i n g c h a i r s f r e e = N; 8 boolean customer entry ( ) f 9 // try to make it into waiting room 10 wait(waiting room mutex ) ; 11 i f (num w a i t i n g c h a i r s f r e e == 0) f 12 signal(waiting room mutex ) ; 13 r e t u r n false; 14 g 15 n u m w a i t i n g c h a i r s f r e e −−;// grabbeda chair 16 signal(waiting room mutex ) ; 17 // now, wait until there isa barber chair free 18 wait(barber c h
    [Show full text]
  • Copyright by Wei-Lun Hung 2016 the Dissertation Committee for Wei-Lun Hung Certifies That This Is the Approved Version of the Following Dissertation
    Copyright by Wei-Lun Hung 2016 The Dissertation Committee for Wei-Lun Hung certifies that this is the approved version of the following dissertation: Asynchronous Automatic-Signal Monitors with Multi-Object Synchronization Committee: Vijay K. Garg, Supervisor Christine Julien Sarfraz Khurshid Neeraj Mittal Dewayne E. Perry Keshav Pingali Asynchronous Automatic-Signal Monitors with Multi-Object Synchronization by Wei-Lun Hung, B.S.E., M.S. DISSERTATION Presented to the Faculty of the Graduate School of The University of Texas at Austin in Partial Fulfillment of the Requirements for the Degree of DOCTOR OF PHILOSOPHY THE UNIVERSITY OF TEXAS AT AUSTIN December 2016 Dedicated to my family. Acknowledgments I would like to express my deep appreciation and thanks to my advisor, Dr. Vijay Garg, for the patient guidance he provided to me. He is a wonderful mentor for me. I would also like to thank my dissertation committee members, Professor Christine Julien, Professor Sarfraz Khurshid, Professor Neeraj Mit- tal, Professor Dewayne E. Perry, and Professor Keshav Pingali for their valu- able suggestions and supports. I would like to thank my labmates, Yen-Jung Chang, Himanshu Chauhan, John Bridgman, and Bharath Balasubramanian, for their advices and help. I also want to thank my friends, Chun-Cheng Chou, Shih-Yen Chen, Chia-Tsen Chen, Tsung-Hsien Lee, Chih-Liang Wang, Jessie Chen, Chao-Yeh Chen, Chia-I Lin, Yi-Hung Wei, Kai-Yang Chiang, Cho-Jui Hsieh, and Si Si for their friendship and all the fun they bring to me during my long journey in finishing this doctoral program. The last word of acknowl- edgment I have saved for my family, my parents, Chi-Fu Hung and Tsai-Lien Tsai, and my younger brother, Wei-Shiang Hung, for their unconditional love.
    [Show full text]
  • Mutual Exclusion UC Santa Barbara
    UC Santa Barbara Operating Systems Christopher Kruegel Department of Computer Science UC Santa Barbara http://www.cs.ucsb.edu/~chris/ Inter-process Communication and Synchronization UC Santa Barbara • Processes/threads may need to exchange information • Processes/threads should not get in each other’s way • Processes/threads should access resources in the right sequence • Need to coordinate the activities of multiple threads • Need to introduce the notion of synchronization operations • These operations allow threads to control the timing of their events relative to events in other threads 2 Asynchrony and Race Conditions UC Santa Barbara • Threads need to deal with asynchrony • Asynchronous events occur arbitrarily during thread execution: – An interrupt causes transfer being taken away from the current thread to the interrupt handler – A timer interrupt causes one thread to be suspended and another one to be resumed – Two threads running on different CPUs read and write the same memory • Threads must be designed so that they can deal with such asynchrony • (If not, the code must be protected from asynchrony) 3 Race Conditions UC Santa Barbara • Two threads, A and B, need to insert objects into a list, so that it can be processed by a third thread, C • Both A and B – Check which is the first available slot in the list – Insert the object in the slot • Everything seems to run fine until... – Thread A finds an available slot but gets suspended by the scheduler – Thread B finds the same slot and inserts its object – Thread B is suspended
    [Show full text]
  • This Thesis Has Been Submitted in Fulfilment of the Requirements for a Postgraduate Degree (E.G
    This thesis has been submitted in fulfilment of the requirements for a postgraduate degree (e.g. PhD, MPhil, DClinPsychol) at the University of Edinburgh. Please note the following terms and conditions of use: • This work is protected by copyright and other intellectual property rights, which are retained by the thesis author, unless otherwise stated. • A copy can be downloaded for personal non-commercial research or study, without prior permission or charge. • This thesis cannot be reproduced or quoted extensively from without first obtaining permission in writing from the author. • The content must not be changed in any way or sold commercially in any format or medium without the formal permission of the author. • When referring to this work, full bibliographic details including the author, title, awarding institution and date of the thesis must be given. Type-parameterized Actors and Their Supervision Jiansen HE Master of Philosophy Department of Computer Science University of Edinburgh 2014 Acknowledgements This thesis is dedicated to my parents for their endless love and support. It is also dedicated to my wife, Shiye, for her continuous encouragement during my hard times. Meeting my wife and getting married are the best two things happened to me in the past 4 years. I want to thank my supervisors, Philip Wadler, Philip Trinder and Don Sannella, for their guidance over 4 years. I am fortunate to have been supervised by them. I want to thank my examiners, Ian Stark and Kevin Hammond, for their meticulous examination and detailed suggestions that contribute to the final version of this thesis. I gratefully acknowledge the substantial help that have received from many colleagues who have shared their related results and ideas over the long period during which this thesis was in preparation.
    [Show full text]