locking

How do I list files with edit locks on a network drive using a dos shell and associated tools?

How do I list files with edit locks on a network drive using a dos shell and associated tools? I think net file has to be run on the server, and I'm looking to do this from any box on the drive. ...

How do I do an exclusive checkout in SVN?

Hi, I'm looking for a way to make an exclusive checkout from SVN. Is there a way to automatically lock a file when it's being checked out ? If one user makes an exclusive checkout, and then another user makes a checkout to the same file, how do I generate some sort of notification or an instant message to the 2nd user that the file i...

What is the difference between lockless and non-blocking?

Hi, In the context of data-structures synchronization, can someone clarify the difference between "lockless" and "non-blocking"? These terms seem to be used interchangeably by a lot of people but I'm not yet sure if there isn't some subtle difference hidden somewhere. I mean lockless is "without locks" and non-blocking is more like gua...

Detecting for Pessimistic lock in VB6

I have a database system developed in VB6, and we have a scenario where more than one user may register at the same time triggering an insert in the database. I have used normal sqlconnection and recordset to make the insert and i initialize it with a pessimistic lock. Now how can i check in my application before inserting a record, if t...

How do I tell the Hotspot JVM whether to use single or multi-processor thread-synchronization?

The Machine is Dual-Core, the OS uses a Multi-Processor kernel. In order to run some performance assessments, I want to set the thread-affinity of the JVM to a single core. However, I am worried that I will get skewed performance measurements as the JVM may be unaware that it is now constrained to a single core, but still using multi-pro...

Threadsafe way to add and remove items from list in .Net

I want to add items to a list from one thread and from another thread remove items from the same list. However, I am not sure if I will run into problems with multiple threads accessing the same object. I have read a bit on the lock statement but I am not sure how to implement this. In short, the question is, how do I ensure thread safe...

How do I make double-checked locking syntax less verbose?

In C#, I have the following extremely verbose syntax for pulling a simple list of items from a database: if (malls == null) { lock (_lock) { if (malls == null) { using (var session = NhibernateHelper.OpenSession()) { malls = session.CreateCriteria<Mall>() ...

How to workaround lack of multiple ao.lock?

I'm programming a simple pyS60 app, not really done anything with python or using multiple threads before so this is all a bit new to me. In order to keep the app open, I set an e32.Ao_lock to wait() after the body of the application is initialised, and then signal the lock on the exit_key_handler. One of the tasks the program may do is...

Question about Oracle locking and summarisation

First, here are some scripts to setup the tables and background. CREATE TABLE TEST_P ( ID NUMBER(3) NOT NULL PRIMARY KEY, SRC VARCHAR2(2) NOT NULL, DEST VARCHAR2(2) NOT NULL, AMT NUMBER(4) NOT NULL, B_ID_SRC NUMBER(3), B_ID_DEST NUMBER(3) ); A row in this table indicates that AMT is being moved from SRC to DEST. ...

Do I need to lock or mark as volatile when accessing a simple boolean flag in C#?

Lets just say you have a simple operation that runs on a background thread. You want to provide a way to cancel this operation so you create a boolean flag that you set to true from the click event handler of a cancel button. private bool _cancelled; private void CancelButton_Click(Object sender ClickEventArgs e) { _cancelled = tru...

Sharing a Java synchronized block across a cluster, or using a global lock?

I have some code that I want to only allow access to by one thread. I know how to accomplish this using either synchronized blocks or methods, but will this work in a clustered environment? The target environment is WebSphere 6.0, with 2 nodes in the cluster. I have a feeling that synchronized won't work, since each instance of the ap...

Lock Free Array Element Swapping

In multi-thread environment, in order to have thread safe array element swapping, we will perform synchronized locking. // a is char array. synchronized(a) { char tmp = a[1]; a[1] = a[0]; a[0] = tmp; } Is it possible that we can make use of the following API in the above situation, so that we can have a lock free array ele...

Is there a way to get the list of SQL statements that were previously executed as part of a given transaction in PostgreSQL?

I'm in a situation where I have many connections that are "IDLE in transaction". I spotted them myself. I could kill them, but that wouldn't prevent them from happening again. In fact, it happens regularily. Is there a way to get the list of SQL statements that were previously executed as part of a given transaction? If I could get tha...

Lock a winforms control

I need to ensure that, once the execution hits a method, the control received by this method is not changed by another thread. Basically, I thought in something like this: private void doSomeWork(Control control) { lock (control) { // do some stuff with the control... } } Is this a bad idea? Edit: Actually, what I'm ...

Thread-safe memoization

Let's take Wes Dyer's approach to function memoization as the starting point: public static Func<A, R> Memoize<A, R>(this Func<A, R> f) { var map = new Dictionary<A, R>(); return a => { R value; if (map.TryGetValue(a, out value)) return value; value = f(a); map.Add(a, value); return value; ...

Reliability of file locking on network files

I read that file locking on network files isn't very reliable. I'm using those LockFile/LockFileEx/UnlockFile win32-api functions for range-locks. Does anyone have some experience of using those functions on files living on a network-share? ...

How can I provide access to this buffer with CSingleLock?

I have these two methods for thread-exclusive access to a CMyBuffer object: Header: class CSomeClass { //... public: CMyBuffer & LockBuffer(); void ReleaseBuffer(); private: CMyBuffer m_buffer; CCriticalSection m_bufferLock; //... } Implementation: CMyBuffer & CSomeClass::LockBuffer() { m_bufferLock.Lock(); ...

Why do libraries implement their own basic locks on windows?

Windows provides a number of objects useful for synchronising threads, such as event (with SetEvent and WaitForSingleObject), mutexes and critical sections. Personally I have always used them, especially critical sections since I'm pretty certain they incur very little overhead unless already locked. However, looking at a number of libr...

How deep does a lock go?

I have the following code: locker = new object(); lock (locker) { for (int i = 0; i < 3; i++) ver_store[i] = atomic_Poll(power); } I was just wandering, considering the function within the lock accesses some global resources, (an open socket among them) ...

Locking a custom dictionary

Good day pythonians, I want to make a custom dictionary with two main features: All keys are declared on creation It is impossible to add new keys or modify current ones (values are still modifiable) Right now code is this: class pick(dict): """This will make delicious toffee when finished""" def __init__(self, *args): ...