COMP 3000 Essay 2 2010 Question 7: Difference between revisions

From Soma-notes
Smcilroy (talk | contribs)
Added Related Work and similar tools section with references
Smcilroy (talk | contribs)
Added Background Concepts Section
Line 18: Line 18:
==Background Concepts==
==Background Concepts==
===Race conditions, deadlocks===
===Race conditions, deadlocks===
Race conditions are an unintended side-effects of programming in concurrent systems, they occur when two or more processes have access to a shared resource and at least one of them have write privilege. This leads to processes modifying the data that all processes share as other may be reading them and results in the reading of stale/incorrect data. They will occur during the execution of the program and often times very difficult to detect or manipulate data in subtle ways.
Deadlock is when two or more processes share a resource and each process is waiting on the other processes to unlock the resource. It becomes a circular chain and no process can continue.
Both these issues occur in concurrent programming and although there are no general solutions for deadlock<sup>[[#Foot9|9]]</sup>, there are suitable methods for dealing with them, and in the case of race conditions, using mutual exclusion locks and synchronization primitives can prevent race conditions. But no programmer is infallible and so there is always the issue of race conditions and deadlocks present in production code.
===Ad Hoc Synchronization===
===Ad Hoc Synchronization===
Ad hoc synchronizations are loops called sync loops that continue until certain conditions are met via outside variables called sync variables. They are designed to control the flow of thread execution much like locking and unlocking of resources. There can be multiple sync variables in a sync loop and they can have multiple exit conditions and dependencies. The diversity of the sync loops, their dependencies and execution paths leads to difficulty in finding them.
===Synchronization primitives===
===Synchronization primitives===
Synchronization variables act as barriers to memory that prevent threads from accessing the same shared resource concurrently<sup>[[#Foot8|8]]</sup>. They come in many forms such as mutexes and condition variables.
Mutexes are mutual exclusive locks that threads employ to lock a resource that they need. No other threads can access them at that point. Once they are finished, they release the lock and the other threads can then lock and access the resource.
Condition variables are variables that will block the thread until a certain condition is met. This allows the thread to only execute when it is safe to perform its operation.


==Contribution==
==Contribution==
Line 88: Line 97:


<span id="Foot7"><sup>7</sup> Author, 2010. Title. [online] Company(optional) Available at: <[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.121.1203&amp;rep=rep1&amp;type=pdf]> [Accessed 23 November 2010].</span>
<span id="Foot7"><sup>7</sup> Author, 2010. Title. [online] Company(optional) Available at: <[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.121.1203&amp;rep=rep1&amp;type=pdf]> [Accessed 23 November 2010].</span>
<span id="Foot8"><sup>8</sup> Author, 2010. Title. [online] Company(optional) Available at: <[http://www.usenix.org/events/bsdcon/full_papers/baldwin/baldwin_html/node5.html]> [Accessed 23 November 2010].</span>
<span id="Foot9"><sup>9</sup> Author, 2010. Title. [online] Company(optional) Available at: <http://homeostasis.scs.carleton.ca/wiki/index.php/Basic_Synchronization_Principles> [Accessed 23 November 2010].</span>

Revision as of 21:53, 23 November 2010

Paper

Ad Hoc Synchronization Considered Harmful

Weiwei Xiong University of California, San Diego

Soyeon Park, Jiaqi Zhang, Yuanyuan Zhou University of Illinois at Urbana-Champaign

Zhiqiang Ma Intel

Research Problem

As the computer industry continues to shift towards multicore processors, concurrent programming and the use of multithreaded designs has increased to keep up with this growing trend. Multithreaded applications can be found in a variety of popular applications today as they take advantage of the multithreaded approach. However, the concepts behind concurrent programming bring with them a host of potential dangers in the form of race conditions and deadlocks resulting from bad programming design and threads accessing shared memory. Fortunately, there are well known and standard methods for dealing with these problems, i.e synchronization primitives. But in real world situations, due to a variety of reasons, as we shall see, programmers often implement their own "ad hoc" synchronizations that eschew common design standards. Ad hoc synchronizations are not well documented and are not discovered by traditional tools for race conditions that look for standard synchronization primitives.

This paper addresses these concerns in two regards, first it details a thorough study of ad hoc synchronizations. It details their nature, dangers, impact on bug detection tools and prevalence in several major open-source applications. Secondly, it introduces SyncFinder, a program that detects all ad hoc synchronizations and automatically annotates the source code where ad hoc sychnronizations are found. This can see use in conjunction with other data race checkers to improve accuracy and to build custom tools for finding deadlocks and bad programming practices.

With detailed analysis of ad hoc synchronization and study of their occurrences in several applications, the research ultimately concludes that they are harmful and should be removed. At the same time, SyncFinder detects and documents ad hoc synchronizations in the source code enabling programmers for the first time to easily track and remove them.

Background Concepts

Race conditions, deadlocks

Race conditions are an unintended side-effects of programming in concurrent systems, they occur when two or more processes have access to a shared resource and at least one of them have write privilege. This leads to processes modifying the data that all processes share as other may be reading them and results in the reading of stale/incorrect data. They will occur during the execution of the program and often times very difficult to detect or manipulate data in subtle ways.

Deadlock is when two or more processes share a resource and each process is waiting on the other processes to unlock the resource. It becomes a circular chain and no process can continue.

Both these issues occur in concurrent programming and although there are no general solutions for deadlock9, there are suitable methods for dealing with them, and in the case of race conditions, using mutual exclusion locks and synchronization primitives can prevent race conditions. But no programmer is infallible and so there is always the issue of race conditions and deadlocks present in production code.

Ad Hoc Synchronization

Ad hoc synchronizations are loops called sync loops that continue until certain conditions are met via outside variables called sync variables. They are designed to control the flow of thread execution much like locking and unlocking of resources. There can be multiple sync variables in a sync loop and they can have multiple exit conditions and dependencies. The diversity of the sync loops, their dependencies and execution paths leads to difficulty in finding them.

Synchronization primitives

Synchronization variables act as barriers to memory that prevent threads from accessing the same shared resource concurrently8. They come in many forms such as mutexes and condition variables. Mutexes are mutual exclusive locks that threads employ to lock a resource that they need. No other threads can access them at that point. Once they are finished, they release the lock and the other threads can then lock and access the resource. Condition variables are variables that will block the thread until a certain condition is met. This allows the thread to only execute when it is safe to perform its operation.

Contribution

Intro to the study of the major applications and what they found

Findings

1.they are prevalent, all applications had them

2. hard to find

3. error prone

4.effect other bug detection

5. They are diverse. Different forms, multiple exits and dependencies

Reasons behind why people use ad hoc synchronization and possible improvements over them ie Synchronization primitives

SyncFinder

Intro to what it is and what it does

How it works

1. find loops

2. identify sync loops

3. EDV analysis

4. Pruning

5. Annotation of found sync

Uses

1. A tool to detect bad practices

2. Extensions to data race detection

Accuracy

Related Work and similar tools

There has been attempts to remove synchronization issues entirely from concurrent programming, such as transactional memory1, a lock-free synchronization that does not require mutexes, and avoids having to use lock, unlock operations. Other attempts have been made to remove bugs that would otherwise be safe from data races but are are still at risk of unintended effects from thread interactions, such as Atomizer2, a dynamic atomicity checker.

There are tools that detect data races such as CHESS3, a dynamic data race checker that runs through all possible thread execution paths and CTrigger4, a tool that checks for atomicity violations. The problem with these programs is that they only look for standard synchronization methods and structures, such as lock() and cond_wait(). They are not looking for ad hoc synchronizations.

A similar tool to SyncFinder exists that can detect simple spinning, also an ad hoc synchronization5, but it only detects simple spinning and not the more complicated ad hoc variations.

Several studies on bug characteristics6 and concurrency bugs7 have been composed. This paper complements these studies to better understand the nature of ad hoc synchronizations and their occurrence in concurrent programs.

Critique

1. Uses static approach, dynamic would be better

  • As stated in the paper, dynamic introduces run-time overhead and is not guaranteed to find if not executed in the test cases

2. not entirely accurate, some false positives.

3. In terms of style, lots of unnecessary repetition

References

1 Author, 2010. Title. [online] Company(optional) Available at: <http://www.cs.brown.edu/~mph/HerlihyM93/herlihy93transactional.pdf> [Accessed 23 November 2010].

2 Author, 2010. Title. [online] Company(optional) Available at: <http://www.cs.williams.edu/~freund/papers/atomizer-padtad.pdf> [Accessed 23 November 2010].

3 Author, 2010. Title. [online] Company(optional) Available at: <http://research.microsoft.com/pubs/70509/tr-2007-149.pdf> [Accessed 23 November 2010].

4 Author, 2010. Title. [online] Company(optional) Available at: <http://pages.cs.wisc.edu/~shanlu/paper/asplos092-zhou.pdf> [Accessed 23 November 2010].

5 LI, T., LEBECK, A. R., AND SORIN, D. J. Spin detection hardware for improved management of multithreaded systems. IEEE Transactions on Parallel and Distributed Systems PDS-17, 6 (June 2006), 508–521.

6 Author, 2010. Title. [online] Company(optional) Available at: <http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.121.1203&rep=rep1&type=pdf> [Accessed 23 November 2010].

7 Author, 2010. Title. [online] Company(optional) Available at: <[1]> [Accessed 23 November 2010].

8 Author, 2010. Title. [online] Company(optional) Available at: <[2]> [Accessed 23 November 2010].

9 Author, 2010. Title. [online] Company(optional) Available at: <http://homeostasis.scs.carleton.ca/wiki/index.php/Basic_Synchronization_Principles> [Accessed 23 November 2010].