Locks are a synchronization mechanism for enforcing limits on access to a resource.

learn more… | top users | synonyms

-1
votes
0answers
25 views

Best practice to lock write to resource [on hold]

I'm writing a little Python script that do some writes on files. I want to exclude the possibilities that the execution of two instances of the same script will write on the same resource. So I'm ...
1
vote
1answer
48 views

Does ReaderWriterLockSlim provide thread safety and speed efficiency (compared to a traditional lock) when using a List?

I have a list, to which I write once in every update Loop and then I spawn some tasks which create read that List and create a duplicate to manipulate that data. More or less it's List.ToList() call ...
1
vote
3answers
94 views

Reading file during write on linux

As I understand, when a file is being written, the process writing to the file obtains an exclusive lock. So other processes cannot access this file for read. With the above knowledge, I'm unable ...
25
votes
3answers
3k views

How much work should I place inside a lock statement?

I am a junior developer working on writing an update for software that receives data from a third-party solution, stores it in a database, and then conditions the data for use by another third-party ...
2
votes
3answers
314 views

Accessing shared data without blocking in TPL

I am writing a class that contains data. It exposes methods that allow to query the data, while the data is also being updated from an external source (web service, for example). All the methods ...
1
vote
2answers
233 views

Why don't we see (more) widespread adoption of lock-free dynamic memory allocators? [closed]

In a multithreaded programming environment, lock contention on the heap is often enough a performance bottleneck. Theoretically at least, the cream-of-the-crop solution for this problem is to have ...
1
vote
2answers
191 views

Scaling locks in high concurrency web apps [closed]

Our web application has a certain resource type that is shared accross multiple users, and may thus be read and written by anyone at anytime. We resorted to the usual suspects, database transactions ...
2
votes
2answers
125 views

Shared & exclusive locking

I need a "lock" that can be either shared or held exclusively, that will provide the following behavior for the following sequence of events: Process A: Requests and is granted a shared lock Process ...
2
votes
2answers
182 views

Alternative locking strategies

I'm having a problem with the design of my application, that neither optimistic nor pessimistic locking tends to solve. Here is a simplified/altered version of the problem that describes the ...
2
votes
1answer
39 views

performance issues when synchronizing on an interned String

I want to lock a remote file with the string "ip + filename" using java. public boolean execCmd(String ip,String filename, String command) { String file = ip + filename; String lock = ...
6
votes
6answers
1k views

What is the actual reason that locks (sentinels) in OO are hard to reason about? [closed]

In this talk, Rich Hickey introduces Clojure. He gives an Ants demo and talks about his motivations for implementing a Software Transactional Memory (STM) system. His reasoning for STM is that ...
1
vote
0answers
118 views

Is this synchronization required in service onCreate method?

Below is a sample code i captured from android doc Per service instance onCreate will be called only once. Ref: here and here The synchronization and singleton doesn't make any sense to me in this ...
1
vote
1answer
154 views

Synchronized access to network industrial equipment

I have an industrial equipment which is controlled by a software. The software connects to it using sockets, and keeps the connection all the time alive, while from time to time sending commands to ...
2
votes
1answer
98 views

How do I handle online payment for items with single quantity? [duplicate]

I would like to implement a robust way to handle ecommerce payment for items with limited quantity, like for example exclusive paintings. Payment would ideally be accepted via PayPal and credit ...
0
votes
1answer
104 views

Locking database records

What I have right now: A table with lot of records. About 200 users can select a record according to some rules based on the data in each record. There is a high chance that 2 or more users will ...
20
votes
4answers
3k views

What prevents a race condition on a lock?

I understand the basics of what data races are, and how locks/mutexes/semaphores help prevent them. But what happens if you have a "race condition" on the lock itself? For example, two different ...
1
vote
3answers
277 views

Is it possible to perform mutual exclusion of threads without OS support?

I suppose you could adapt distributed mutual exclusion algorithms (Ricart/Agrawala, etc), but aside from these more exotic approaches, are you required to use primitives provided by the OS in order to ...
0
votes
1answer
327 views

Design pattern for locking asynchronous operations in Objective-C

I'm writing my first Objective-C Class. It's responsible for interaction with an HTTP SSO authentication service. The process requires multiple HTTP transactions in order to complete. The Class acts ...
3
votes
1answer
124 views

Are mutexes assigned to specific regions of memory?

I'm currently reading C++ Concurrency in Action by Anthony Williams and I'm facing an obstacle in thought. First he describes deadlocks as when two threads lock simultaneously (at least, that's how I ...
1
vote
2answers
222 views

How do I find a good middle way to make this library safe for concurrent operations

I've made a little library called SignalR.EventAggregatorProxy Before I push it into 1.0 state I need to fix so it works safely with concurrent operations. Easiest way is lock all operations but ...
1
vote
1answer
549 views

Handling or preventing conflicts in a multi-user system

I have a web application that is accessed by multiple users from different locations worldwide. Let's say I have an "edit" form for a specific document and two (or more) users are editing the document ...
1
vote
1answer
147 views

How to implement a distributed proxy with quotas?

I'm in the process of developing a scalable proxy (Linux/C/C++, Nginx modules or custom HTTP server) handling incoming HTTP requests, and re-routing them to others locations based on parameters ...
13
votes
1answer
1k views

Best practise is not to poll…but isn't polling happening internally anyway when a thread calls wait()?

Say we have some thread that wants to check when another thread is finished its task. I have read that we should call a wait() type function that will make this thread wait until it receives a ...
4
votes
4answers
795 views

Is Using Locking/Unlocking in Version Control an Anti-Pattern?

Recently I've started using Git at work. Previously I've only ever used VSS (which has some problems) and so far, Git is orders of magnitude better. The key differences here is that Git is ...
2
votes
1answer
115 views

Object locking over Internet

I am building a tutoring application that can be used to draw objects and then one is able to drag them around. I would like to know what is the best thing to do when someone clicks on an object and ...
5
votes
2answers
7k views

PHP file_put_contents File Locking

The Senario: You have a file with a string (average sentence worth) on each line. For arguments sake lets say this file is 1Mb in size (thousands of lines). You have a script that reads the file, ...
26
votes
5answers
3k views

Does immutability entirely eliminate the need for locks in multi-processor programming?

Part 1 Clearly Immutability minimizes the need for locks in multi-processor programming, but does it eliminate that need, or are there instances where immutability alone is not enough? It seems to ...
4
votes
1answer
510 views

Reading and conditionally updating N rows, where N > 100,000 for DNA Sequence processing

I have a proof of concept application that uses Azure tables to associate DNA sequences to "something". Table 1 is the master table. It uniquely lists every DNA sequence. The PK is a load balanced ...
1
vote
1answer
346 views

Implementing Bulk Update feature and its trade offs

The feature to implement is to allow a user to select items and apply data update in bulk. It is very similar to JIRA's ability to bulk update a list of selected issues. In my case: I iterate over ...
8
votes
5answers
2k views

Best-practice to manage concurrency into a basket in a e-commerce website

What is the best practice to manage the case where two customers add in the same time a product whose the stock was only 1 ? Must there be a check in the code of the basket to avoid one of these 2 ...