Locking allows different types of resources to be locked by a transaction.

learn more… | top users | synonyms (1)

1
vote
0answers
27 views

Reliability of flock mutex (LOCK_EX|LOCK_NB)

I would like to test reliability of system flock in a multi-threaded and concurrent environment as some suggest that they are not reliable (in comments). Thus I ...
9
votes
2answers
106 views

Is this use of a resource based on session ids thread safe?

Let me first describe the expected behavior of the code below: There will be one static SessionManager accessed by many threads. Multiple calls to ...
5
votes
3answers
111 views

Feedback on thread safety of the classes

I have following classes. Are they properly guarded for thread safety? Do you see any issues with any of the classes? ...
5
votes
1answer
52 views

Operations on files and their locks - code too bulky?

A couple of hours ago I asked a question on Stackoverflow to find out if there is a good way to delete files in a folder only if all files are indeed deletable and I got some good answers that led me ...
2
votes
0answers
87 views

Python app-level document/record locking (eg. for MongoDB)

Introduction MongoDB does not provide means to lock a document (like SELECT FOR UPDATE in RDBMS). There is recommended approach to Isolate Sequence of Operations, which is sometimes called ...
2
votes
1answer
107 views

RAII-Style Lockable Objects

TL;DR: Without the phrases "use Boost" and "use C++11", does the posted code for RAII-style locking of a resource look correct and safe, or is there something I've missed. Long Version: I am working ...
1
vote
1answer
90 views

C: File locking between server threads

I have written below code where the server is getting requests from clients on socket and creating a thread per client. Each client thread is then writing to a file which is common to all the threads. ...
3
votes
1answer
350 views

Locking during cache population

Here I want to lock when populating a particular cache object, without blocking other calls to the same method requesting Foos for other ...
1
vote
2answers
169 views

Loading data async with queue. Proper write only locking and scheduling

I have to store and return data on multitasking requests. If data is missing, I schedule loading and return null. I'm using some nubie scheduling by saving current jobs in a list. Also I need data ...
0
votes
2answers
79 views

Is this a good way of handling item reservations?

I have a site were we sell unique items. When a user clicks to buy an item we have to reserve it. This prevents other buyers from purchasing the item while the first buyer is checking out. When a ...
4
votes
1answer
118 views

Is this the best message delay algorithm?

In my application I am attempting to queue outgoing messages by the following rules By default they should be sent no less than messageDelay apart Some messages ...
1
vote
4answers
233 views

Simple multi-threading class: Does anybody spot potential lock-based concurrency issues?

Trying to write a multi-threaded utility that logs some audit trails to the DB every 30 minutes, or whenever my storage data structure (a list in this case) exceeds a certain limit. The code works ...
7
votes
3answers
4k views

Dining philosophers problem

Now I know this dining philosophers problem is researched a lot and there are resources everywhere. But I wrote a simple code to solve this problem with C and then turned to Internet to see if it's ...
1
vote
2answers
2k views

ThreadPool implementation

The following code is a self-implementation of the static class ThreadPool in C#, only the QueueUserWorkItem (the simpler method), written to practice multithreading in the .NET environment and ...
2
votes
4answers
2k views

Designing a better logger class

Could you please critisize the logger class below? Can it be used in a multi threaded web environment? If not how can I improve it? Is there anything wrong with locking in WriteToLog method or ...
1
vote
3answers
78 views

How to correctly get a IDisposeable when you need to lock the factory?

If I need to create a IDisposeable object from a factory, but if the factory object is not thread safe and requires me to lock on it is this the correct pattern to use? ...
4
votes
2answers
133 views

Getting a decryptor object

I need to lock on my AesManaged instance _Aes to call CreateDecryptor() however the CreateDecryptor() method is not thread safe and this function could be called by ...
7
votes
2answers
257 views

Synced/Atomic access

Forward I would love any comments you have, any ideas, any flaws you can find, and any suggestions you might have regarding the code below. If this is similar to other implementations, I would love ...
2
votes
1answer
987 views

Resource Pool implementation with ReentrantLock and Condition

The Resource Pool is similar to the implementation of a semaphore. It takes the class type of the resource and number of resource pools associated with it as the constructor parameters. There is a ...
1
vote
2answers
1k views

Multithreading concepts with Producer Consumer

I just wanted to confirm if this example I created would qualify as a good example of a multithreaded producer consumer. I would like any review changes on improving this example. I found that static ...
3
votes
4answers
810 views

Java Non Reentrant Lock Implementation

I have implemented a Non Reentrant Lock. I want to know if this has any mistakes, race conditions etc. I am aware of the fact that existing libraries have to be used (instead of writing our own), but ...
6
votes
0answers
146 views

Concurrency limit map in Go

Please someone who knows locks, mutexes, and Go, review the following code. Task: per host concurrency limits for web crawler (map[string]Semaphore). I considered chan struct{} (chan bool) approach, ...
4
votes
1answer
162 views

Improving handling of data structure used in parallel

I have a class extending the Dictionary class. This class is used for storing some information (modeled in CustomClass) and accessing it through an integer ID. To ...
10
votes
3answers
643 views

Force locking for thread-safety

After reading Herb Sutter's Associate Mutexes with Data to Prevent Races, I found that my solution was superior in several aspects, least important first: The code is cleaner, without macros No ...
2
votes
1answer
385 views

Mutex implementation for uniprocessor bare metal embedded OS

I wrote this recently for one of my projects, any error you guys can spot or a feature which could be implemented without eating up resources or some optimisations ? Oh and it isn't meant for Multi ...
3
votes
4answers
213 views

Configurable synchronization approach in Java

I am interested in the community opinion about the following approach for the synchronization. Generally it is based on the idea to have a configurable way to apply locking on some logic parts. Any ...
1
vote
2answers
893 views

ReentrantReadWriteLock lock upgrade method

I have a question about lock upgrading.Specifically what bothers me is between readlock.unlock() and following writelock.lock()... I am providing a nearly complete implementation for a sample cache.I ...
2
votes
1answer
259 views

std::lock implementation in C with pthreads

I messed a little bit with pthreads and needed an alternative to the C++11 function std::lock (2 args are enough), and this is what I came up with: ...
2
votes
1answer
734 views

ReentrantLock with priorities for waiting threads

I am trying to have a ReentrantLock with another way to determinate which thread will have the lock in the waiting queue. ...
4
votes
2answers
3k views

Did I need to use lock to ensure that Queue.Dequeue is Thread Safe in this case on .NET 2.0?

Is this ok? I am using C# and .NET 2.0 I have this Queue declared in my class : ...
1
vote
1answer
393 views

Read-write lock implementation for Ruby, new version

I recently discovered that there is no free read-write lock implementation for Ruby available on the Internet, so I built one myself. The intention is to keep it posted on GitHub indefinitely for the ...
14
votes
2answers
717 views

Lock-free cache oblivious n-body algorithm

I'm currently looking at, from a rather high level, the parallelization of the gravity calculation in an N-body simulation for approximating a solution to the N-body problem. The simple form of the ...
7
votes
1answer
2k views

“Fast” Read/Write Lock

I need a Read-Write lock that is fast and generally portable on Windows machines (including XP, otherwise I'd just use the SRWLock that was introduced with Vista). I've written this custom ...
3
votes
2answers
154 views

Review a newbie's pthread code

I'm a pthread newbie and I've been giving myself a challenge: I want to have a resource that multiple threads can access at the same time as read. However, if a ...
4
votes
1answer
397 views

Single word CAS tagged pointer for algorithms susceptible to the ABA problem

I've been looking for a solution to the ABA problem for a lock-free stack. Searching the Web revealed patented and complicated hazard pointers and tagged pointers using double compare-and-swap (DCAS, ...
0
votes
1answer
97 views

Security concerns with locking files

I'm writing a perl script which reads logs from a file and looks for matches from another file before sending the matches off by email. The problem is, I'm dealing with files which could be changed (a ...
4
votes
2answers
7k views

Using Timer with Backgroundworker to ensure the doWork method is called

I have a windows forms application in which a backgroundworker is called again and again. I need to avoid concurrent access of the code in dowork method for the backgroundWorker; but also need to ...
5
votes
4answers
665 views

Associating a lock/mutex with the data it protects

I've recently come across some areas of code in our solution that have a few thread-safety problems. Thread-safety is a minefield at best so I thought I'd have an attempt at writing a few little ...
6
votes
1answer
973 views

Waiting for a lock to release with ManualResetEvent and Quartz

Follow-up to: Waiting for a lock to release with Thread.Sleep()? I've found the time I tried to rewrite my WaitForLock-Method to utilize the Quartz.NET ...
9
votes
3answers
2k views

Waiting for a lock to release with Thread.Sleep()?

There's a follow-up: Waiting for a lock to release with ManualResetEvent and Quartz. I've written a simple Lock-Mechanism which is saving the states of the locks in a database. Now I need to wait ...
4
votes
1answer
1k views

Transactions and Locking in Rails 3

I am new to Rails and have a system that needs to process transactions. A user can enter a transaction to which one more users are tied. These users owe some amount of money to the person making the ...
5
votes
1answer
2k views

C++ critical section with timeout

NOTE: My implementation is based on codeproject article by Vladislav Gelfer. Based on valdok's codes, I rewrote the critical section class. The difference is that my implementation integrated ...
2
votes
2answers
428 views

Composable Locks using LINQ. Can anyone see any problem with this ?

I was playing around with LINQ and I came up with the following idea for composing locks taking advantage of C# Monadic syntax. It seems too simple, so I thought let me post it on StackExchange and ...
5
votes
1answer
414 views
11
votes
6answers
10k views

A custom thread-pool/queue class

I wanted a class which executes any number of tasks but only a certain amount at the same time (e.g. to download various internet content and keep the overall download speed at a good level). The ...
26
votes
5answers
5k views

Is this (Lock-Free) Queue Implementation Thread-Safe?

I was trying to create a lock-free queue implementation in Java, mainly for personal learning. The queue should be a general one, allowing any number of readers and/or writers concurrently. Would you ...