locking

Why lock may become a bottleneck of multithreaded program?

Why lock may become a bottleneck of multithreaded program? If I want my queue frequently pop() and push() by multithread, which lock should I use? ...

Need help on choosing locks for thread synchronization

I have several modifying threads and some reading threads, which all access the global variable X. I want to make my synchronization policy like this: When a thread try to modify X, it will require a lock first, and several modifying threads can have several locks required. When a thread try to read X, it must wait until all the modify...

database view performance issue

Hello everyone, I am using SQL Server 2008 and I have two tables which are of the same schema and I create a view which union the content of the two tables to provide a single view of "table" to external access. One of the table is read only and the other table contains bulk insert/delete operation (on the other table, I will use bulk ...

NOLOCK on Views, does it propagate to the tables?

If you include a NOLOCK on a select from a VIEW, does that NOLOCK propagate down into the tables joined within the view? If not, what's the purpose of locking a VIEW? Sample View Code: CREATE VIEW [my_custom_view] AS SELECT a1.[column_a], a1.[column_b], a1.[column_c], a1.[column_d] FROM [table_a] a1 JOIN [table_b] b1 O...

Thread safety... what's my "best" course of action?

I'm wondering what is the "best" way to make data thread-safe. Specifically, I need to protect a linked-list across multiple threads -- one thread might try to read from it while another thread adds/removes data from it, or even frees the entire list. I've been reading about locks; they seem to be the most commonly used approach, but ap...

How Do I Find Out If An Object Is Locked? c#

Hi there, I have a lock in my code.I have two threads running at the same time. How can I tell if a thread is locking that object? private readonly object _lockObject = new Object(); // Both methods running public void Method1() { if(certainCriteria) { lock(_lockObject) { //doWork; } } } ...

Locking on several methods only if a thread is in a certain method

I have a class (simplified example) like : public class SomeCollection : ICloneable { public void Add(Item item) { /* ... */ } public void Remove(Item item) { /* ... */ } public Item Get(Key key) { /* ... */ } /* ... */ public object Clone() { /* ... */ } } I need that when a thread enters Clone() no other ...

How to monitor file locking to track down a deadlock?

Our application is occasionally hanging while it saves, where the core data raw file is being left locked (perhaps by our spotlight importer). We've verified that it's at a low-level file level, not at the core data level. What I'm trying to do is figure out how to monitor the application while it's running so if I get this hang, I can...

Long Running Workflows in Sharepoint, do they block the w3wp process

We have a WSS 3.0 installation with Search Server, which is used to search for documents and Save the search definition to repeat the search later. The users want the option to be able to download all the files in their search results as a one-off Zip file. I have a very basic solution where the Zipping of the files is done in the web p...

Is spin lock useful in a single processor uni core architecture?

I am confused by the function of spin lock. The spin lock is used to stop the process from re-scheduling. However, in a machine with just one core, is it useful to use spin lock to prevent context switching? ...

ActiveRecord: Avoid inconsistency in has_many relations

Assume we have an usual M-M relationship between two tables, like: users---< users_tags >--- tags. In this post I'm only concerned about the relation user_tags, tags: I'd like to avoid that linked tags can be deleted. Only tags which aren't referenced should be destroyable. The stupid way to do this would be: class Tag def before...

SQL Server - how to set (nolock) hint as a default?

is there some way to tell sql server to use the (nolock) hint or every select in a stored procedure? is pretty tiresome to add it to each an every select.... ...

What free tools are available to analyze lock contention in java ?

I need to determine which locks are the most-contended-for in my application code. What free tools can I use to determine this ? ...

Java synchronize statement around a lock

I was wondering if synchronize (lock) { ... } Where lock is an instance of java.util.concurrent.locks.Lock, treats lock like any other object or as the try-finally idiom i.e. lock.lock(); try { ... } finally { lock.unlock(); } ...

Do spurious wakeups actually happen?

Seeing various locking related question and (almost) always finding the 'loop because of spurious wakeups' terms1 I wonder, has anyone experienced such kind of a wakeup (assuming a decent hardware/software environment for example)? I know the term 'spurious' means no apparent reason but what can be the reasons for such kind of an event?...

Mutex in Python Twisted

I'm using the Twisted framework, and am getting RPCs asynchronously. I have another function which does a task every 2 seconds, and sleeps in between. This is called through reactor.callInThread. These depend on a shared resources, so I need some thread-safe way of accessing them. How does one go about using critical sections / mutexes /...

Distributed Lock Service

Which distributed lock service would you use? Requirements are: A mutual exclusion (lock) that can be seen from different processes/machines lock...release semantics Automatic lock release after a certain timeout - if lock holder dies, it will automatically be freed after X seconds Java implementation Nice to have: .Net implementation...

Locking a self-loading cache

I'm implementing a simple cache in C#, and trying to make it accessible from multiple threads. In the basic read case, it's easy: var cacheA = new Dictionary<int, MyObj>(); // Populated in constructor public MyObj GetCachedObjA(int key) { return cacheA[key]; } This is, I believe, completely thread-safe. But I'd also like to make ...

Locking and multi threading in dotNet

I have multiple threads who all need to write to the same Dictionary. I have a lock on an object that I maintain in order to make sure only 1 thread is updating the dictionary at once. My question is as follows. If one thread tries to update the dictionary while another has a lock, will the thread just know to wait? Will it just fail? If...

Distributed Lock Service over MySql/GigaSpaces/Netapp

Disclaimer: I already asked this question, but without the deployment requirement. I got an answer that got 3 upvotes, and when I edited the question to include the deployment requirement the answer then became irrelevant. The reason I'm resubmitting is because SO considers the original question 'answered', even though I...