locking

How are mutex and lock structures implemented?

I understand the concept of locks, mutex and other synchronization structures, but how are they implemented? Are they provided by the OS, or are these structures dependent on special CPU instructions for the CPUs MMU? ...

What is Distributed Lock Server

What is Distributed Lock Service (or Server)? When it needs to be used? ...

mySQL - Apply a row level lock using mysqli

Using PHP's mysqli how do you apply a row level lock? Row level locks stop anyone editing currently present rows that match your criteria right? but do they stop a user inserting a row which matches your criteria? Thanks ...

Threading and un-safe variables

I have code listed here: Threading and Sockets. The answer to that question was to modify isListening with volatile. As I remarked, that modifier allowed me to access the variable from another thread. After reading MSDN, I realized that I was reading isListening from the following newly created thread process. So, my questions now: ...

Why would this SELECT statement lock up on SQL Server?

I have a simple query like this SELECT * FROM MY_TABLE; When I run it, SQL Server Management Studio hangs. Other tables and views are working fine. What can cause this? I've had locks while running UPDATE statements before, and I know how to approach those. But what could cause a SELECT to lock? I have run the "All Blocking Trans...

Locking a queue while re-ordering it in Coldfusion

Hi all, please consider the following: I have a queue of objects represented as an array. I process them off the top of the array (at position 1) before calling arrayDeleteAt() to remove it from the array. I add new queue item at the top of the array using arrayAppend(). This works fine. However, I now wish to re-order the array im...

IllegalMonitorStateException raised with explicit lock/condition

I want to have such kind of work flow using explicit lock/condition variables (It's a course project which mandates this style.): A is the main class, it asks B to do some job from time to time. B has a worker class C which constantly queries B about new jobs to do and do it. After C finishes, it will call A's callback function to notify...

iPhone app running while screen locked

Here is something I am trying desperately to get to work: I have an app that polls the GPS module in specified intervals and then sends out coords out to a server using Unix calls such as write(); It works fine when the app is active, but once the screen locks itself, reporting stops. I have found this: [UIApplication sharedApplication...

Can address space be recycled for multiple calls to MapViewOfFileEx without chance of failure?

Consider a complex, memory hungry, multi threaded application running within a 32bit address space on windows XP. Certain operations require n large buffers of fixed size, where only one buffer needs to be accessed at a time. The application uses a pattern where some address space the size of one buffer is reserved early and is used to...

Ensuring certain private functions can only be called from a locked state

Say I have a class A: class A { public: A(); void fetch_data() { return 1; } void write_x_data() { // lock this instance of A private_function1_which_assumes_locked(); private_function2_which_assumes_locked(); // unlock this instance of A } void write_y_data() { // lock this instance of A pr...

Is it possible to have more than 32 locks in ConcurrentHashMap

I read ConcurrentHashMap works better in multi threading than Hashtable due to having locks at bucket level rather than map wide lock. It is at max 32 locks possible per map. Want to know why 32 and why not more than 32 locks. ...

Using LockFileEX in C#

Background I'm trying to implement block file locking in my C# application. The built-in FileStream.Lock method throws an exception if it is unable to acquire the lock. The underlying LockFile method returns a status code however I'd prefer not to use a spin-lock to wait for the file to be unlocked. Question Does anyone have any c...

Is there any circumstance in which calling EnterWriteLock on a ReaderWriterLockSlim should enter a Read lock instead?

I have a seemingly very simple case where I'm using System.Threading.ReaderWriterLockSlim in the 3.5 version of the .NET Framework. I first declare one, as shown here: I put a break point right before the lock is acquired and took a screen shot so you can see (in the watch window) that there are currently no locks held: Then, ...

Sql Server locked tabled

Hi guys, I am thinking this is impossible but I wanted to make sure. Is there a way for me to know when a table was locked and maybe for how long? I know that I can see whether a table is currently locked, but I would like to have a "history" of locks. ...

Conversion Deadlock problem, please help!

Hi all, really hope you can help. We've got a problem with conversion deadlocking going on within one environment (the same proc + trigger works in at least four other environments). The stored proc in question inserts a row into a table (cmsreceipt) that has a trigger which updates another table (cmsreceiptarchive). To try and preven...

SQL Server locking problem on popular table

I've run into an issue that I need clearer heads to think through. Occasionally this stored procedure (and many others similar to it): CREATE PROC [dbo].[add_address1] @recno int OUTPUT, @clientID int, @street varchar (23), @city varchar (21), @state varchar (2), @zip varchar (9) AS declare @s int; select @s = updated from is_c...

How to avoid double check locking when adding items to a Dictionary<> object in .NET?

I have a question about improving the efficiency of my program. I have a Dictionary<string, Thingey> defined to hold named Thingeys. This is a web application that will create multiple named Thingey’s over time. Thingey’s are somewhat expensive to create (not prohibitively so) but I’d like to avoid it whenever possible. My logic for ...

rails - implementing a simple lock to prevent user's from editing the same data concurrently

Hi - I have an app where I need to prevent users from editing data while it is being edited by a different user. I'm trying to think of the best way to do it and wanted to ask for ideas. So far, I've created a settings model that stores application wide configuration on the db in key/value pairs. So, for the lock, I have a settings insta...

Threading mechanism: preparing and releasing a cache in the background

Preface: This has become a quite a long post. While I'm not new to programming, I have close to zero practice around threading and could need some help here... This is probably a common problem that could be described in shorted words, but I'm a bit overwhelmed with it. Some background first... I'm writing code for the iPhone where I ...

Concurrency / Synchronization question

I have 2 programs running on 2 different machines. Each program has a method called updateRecord that does the following 2 things: 1. Do a SELECT query on a particular record Z 2. Do a UPDATE query on the same record. If these 2 queries are in the same transaction (between beginTransaction and commitTransaction) does it guarantee proper...