When writing multi-threaded applications, one of the most common problems experienced are race conditions.
My question to the community, is:
What is a race condition? How do you detect them? How do you handle them? And finally, how do you prevent them from occurring?
...
I've seen there are some race condition analysis tools for C++, C and Java. Anyone know of any static analysis tools that do the same for .NET?
...
Is there a way to make awk (gawk) ignore or skip missing files? That is, files passed on the command line that no longer exist in the file system (e.g. rapidly appearing/disappearing files under /proc/[1-9]*).
By default, a missing file is a fatal error :-(
I would like to be able to do the equivalent of something like this:
BEGIN { M...
How do you stop race conditions in MySQL? the problem at hand is caused by a simple algorithm:
select a row from table
if it doesn't exist, insert it
and then either you get a duplicate row, or if you prevent it via unique/primary keys, an error.
Now normally I'd think transactions help here, but because the row doesn't exist, the t...
I'm trying to implement (what I think is) a pretty simple data model for a counter:
class VisitorDayTypeCounter(models.Model):
visitType = models.CharField(max_length=60)
visitDate = models.DateField('Visit Date')
counter = models.IntegerField()
When someone comes through, it will look for a row that matches the visitType ...
In Flex I have a lot of Move effects and AnimateProperty effects.
What I have found in several different places in my code is that far too frequently the effect stops halfway through for no apparent reason.
I have found this in numerous places in my application and it occurs whether or not I am doin something particularly complicated.
...
Here's the scenario:
My users are presented a grid, basically, a stripped down version of a spreadsheet. There are textboxes in each row in the grid. When they change a value in a textbox, I'm performing validation on their input, updating the collection that's driving the grid, and redrawing the subtotals on the page. This is all ha...
I'd like to use POSIX semaphores to manage atomic get and put from a file representing a queue. I want the flexibility of having something named in the filesystem, so that completely unrelated processes can share a queue. I think this plan rules out pthreads. The named posix semaphores are great for putting something in the filesystem...
We are experiencing an exceedingly hard to track down issue where we are seeing ClassCastExceptions sometimes when trying to iterate over a list of unmarshalled objects. The important bit is sometimes, after a reboot the particular code works fine. This seems to point in the direction of concurrency/timing/race condition. I can confirm t...
I have a website with a contact form. User submits name, email and message and the site emails me the details.
Very occasionally my server has a problem with it's email system and so the user gets an error and those contact details are lost. (Don't say: get a better server, any server can have email go down now and then and we do get a ...
I wrote a multi-threaded windows application where thread:
A – is a windows form that handles user interaction and process the data from B.
B – occasionally generates data and passes it two A.
A thread safe queue is used to pass the data from thread B to A. The enqueue and dequeue functions are guarded using a windows critica...
I'm designing a client-server chat application (in fact I'm not, but let's pretend I am:)), and I'm a bit puzzled by some race conditions I've experienced.
Let's say I've got the following code:
public interface IServer
{
[OperationContract(IsOneWay = false)]
[FaultContract(typeof(ChatException))]
void BroadcastMessage(string msg...
I was worrying about race conditions in an application I'm designing, when I was wondering about this question.
Let's say I have a large array or collection of some sort that is managed by one component of my program, let's call that component Monitor. Its job is to regularly check if the collection is "dirty", i. e. has changed recentl...
How long will a thread wait for a race condition in the following scenario?
A file is added to a collection:
lock(mylock)
{
// add to collection
}
It is then removed from the collection in a similiar manner.
If a thread is trying to add to the collection while the service is removing it from the collection, who wins?
Or is...
I have an ASP.NET application with a lot of dynamic content. The content is the same for all users belonging to a particular client. To reduce the number of database hits required per request, I decided to cache client-level data. I created a static class ("ClientCache") to hold the data.
The most-often used method of the class is by ...
Hey guys,
So I'm seeing some strange issues in ie8 with jquery, and assorted javascript files. These errors are not occurring in Firefox, Safari, or previous versions of IE. The main thing that's happening are variable undefined, mismatched bracket errors, etc... but the error changes each time you force-refresh the page. Checking the c...
Does this cause a race condition with MySQL (InnoDB):
Start Transaction.
Try to get record.
If record doesn't exist, return.
If record exists, delete it and add a log entry saying that is was deleted.
End Transaction (commit/rollback).
Is it possible for another process to start just before the delete step in 2b, detect the presence ...
Hi everybody,
I have recently been learning the Apple SDK (for iPhone, etc) and came across something I can't understand. In the docs for "Using NSURLConnection" from http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html
I found a strange piece of explanation and example code. Firs...
Here is my desired transaction order:
User1 select field, perform operation, update with new value.
User2 select field, perform operation, update with new value.
User3 select field, perform operation, update with new value.
From what I understand the first select only perform a write-lock while the second one perform read and write l...
I have here what I understand to be a relatively simple OpenMP construct. The issue is that the program runs about 100-300x faster with 1 thread when compared to 2 threads. 87% of the program is spent in gomp_send_wait() and another 9.5% in gomp_send_post.
The program gives correct results, but I wonder if there is a flaw in the cod...