locking

Document Server: Handling Concurrent Saves

I'm implementing a document server. Currently, if two users open the same document, modify it and save the changes, document's state will be undefined (either the first user's changes are saved permanently, or the second's). This is entirely unsatisfactory. I considered two possibilities to solve this problem. The first is to lock docum...

How do I lock a file in Perl?

What is the best way to create a lock on a file in Perl? Is it best to flock on the file or to create a lock file to place a lock on and check for a lock on the lock file? ...

How do I avoid read locks in my database?

Answers for multiple databases welcome! ...

Is a bool read/write atomic in C#

Is accessing a bool field atomic in C#? In particular, do I need to put a lock around: class Foo { private bool _bar; //... in some function on any thread (or many threads) _bar = true; //... same for a read if (_bar) { ... } } ...

lock keyword in C#

I understand the main function of the lock key word from MSDN lock Statement (C# Reference) The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock. When should the lock be used? For instance it mak...

Has anyone tried transactional memory for C++?

I was checking out Intel's "whatif" site and their Transactional Memory compiler (each thread has to make atomic commits or rollback the system's memory, like a Database would). It seems like a promising way to replace locks and mutexes but I can't find many testimonials. Does anyone here have any input? ...

Want to write to a file, but may have potentially multiple writers at once, need to lock.

Hi, In a asp.net web application, I want to write to a file. This function will first get data from the database, and then write out the flat file. What can I do to make sure only 1 write occurs, and once the write occurrs, the other threads that maybe want to write to the file don't since the write took place. I want to have this wr...

SQL Server locks explained

Below is a list of locks that SQL Server 2000 is meant to support. I am a bit confused as to what the "intent" locks actually mean. I've looked around on the Web and the answers seem to be a bit cryptic. Further to getting an answer to my specific question, I am hoping to use this question as a Wiki for what each lock means and under w...

Locking File using Apache Server and TortoiseSVN

Guys, I am seeting up Apache server with TortoiseSVN for local source code repository. Currently on trial purpose I am setting only two users. Is it possible for administrator to set up some thing so that file get compulsory locked once its checkout (copy to working directory) by some one. Abhijit Dhopate ...

Are locks unnecessary in multi-threaded Python code because of the GIL?

If you are relying on an implementation of Python that has a Global Interpreter Lock (i.e. CPython) and writing multithreaded code, do you really need locks at all? If the GIL doesn't allow multiple instructions to be executed in parallel, wouldn't shared data be unnecessary to protect? sorry if this is a dumb question, but it is somet...

Locking Row in SQL 2005-2008

Is there a way to lock a row in the SQL 2005-2008 database without starting a transaction, so other processes cannot update the row until it is unlocked? ...

C# / ASP.NET - Web Application locking

I'm working on a C#/ASP.NET web application, and I have a number of situations where I need to do locking. Ideally, I want the locks to act independently, since they have nothing to do with each other. I've been considering [MethodImpl(MethodImplOptions.Synchronized)] and a few ways of using lock(), but I have a few questions/concerns....

Techniques to Get rid of low level Locking

I'm wondering, and in need, of strategies that can be applied to reducing low-level locking. However the catch here is that this is not new code (with tens of thousands of lines of C++ code) for a server application, so I can't just rewrite the whole thing. I fear there might not be a solution to this problem by now (too late). However ...

Optimistic vs. Pessimistic locking

I understand the differences between optimistic and pessimistic locking*. Now could someone explain to me when I would use either one in general? And does the answer to this question change depending on whether or not I'm using a stored procedure to perform the query? *But just to check, optimistic means "don't lock the table while re...

Why avoid pessimistic locking in a version control system?

Based on a few posts I've read concerning version control, it seems people think pessimistic locking in a version control system is a bad thing. Why? I understand that it prevents one developer from submitting a change while another has the file checked out, but so what? If your code files are so big that you constantly have more than...

How to make a method exclusive in a multithreaded context ?

I have a method which should be executed in an exclusive fashion. Basically, it's a multi threaded application where the method is invoked periodically by a timer, but which could also be manually triggered by a user action. Let's take an example : The timer elapses, so the method is called. The task could take a few seconds. Right af...

AutoLock in Java - how to ?

What is the best way to free resources (in this case unlock the ReadWriteLock) when leaving the scope ? How to cover all possible ways (return, break, exceptions etc)? ...

Volatile vs. Interlocked vs. lock

Let's say that a class has a public int counter field that is accessed by multiple threads. This int is only incremented or decremented. To increment this field, which approach should be used, and why? lock(this.locker) this.counter++; Interlocked.Increment(ref this.counter); Change the access modifier of counter to public volatile ...

Another locking question

I'm trying to get my multithreading understanding locked down. I'm doing my best to teach myself, but some of these issues need clarification. I've gone through three iterations with a piece of code, experimenting with locking. In this code, the only thing that needs locking is this.managerThreadPriority. First, the simple, procedura...

How to properly implement a shared cache in ColdFusion?

I have built a CFC designed to serve as a dynamic, aging cache intended for almost everything worth caching. LDAP queries, function results, arrays, ojects, you name it. Whatever takes time or resources to calculate and is needed more than once. I'd like to be able to do a few things: share the CFC between applications define the scope...