locking

Locking directory and make other part of the code to wait until the directory is released by the thread.

How to lock the directory that is beign processed in a thread ? and The Wait to write a new set of file to the directory after the folder is released by the thread that started procesing the folder? ...

What might cause ruby to lock up while exiting?

I have a ruby script that does a few perforce operations (through the scripting API) then simply ends: def foo() ... end def bar() ... end foo() bar() puts __LINE__ exit 0 #end of file ...and while the LINE will print out, the process never ends, whether the exit(0) is there or not. This is ruby 1.8.6, primarily on the mac, but...

[PHP] Read and write to a file while keeping lock

Hi! I am making a simple page load counter by storing the current count in a file. This is how I want to do this: Lock the file (flock) Read the current count (fread) Increment it (++) Write new count (fwrite) Unlock file/close it (flock/fclose) Can this be done without losing the lock? As I understand it, the file can't be written...

In Perl, how can I wait for threads to end in parallel?

I have a Perl script that launches 2 threads,one for each processor. I need it to wait for a thread to end, if one thread ends a new one is spawned. It seems that the join method blocks the rest of the program, therefore the second thread can't end until everything the first thread does is done which sort of defeats its purpose. I tried...

How do I lock the workstation from a windows service?

I need to lock the workstation from a windows service written in VB.Net. I am writing the app on Windows 7 but it needs to work under Vista and XP as well. User32 API LockWorkStation does not work as it requires an interactive desktop and I get return value of 0. I tried calling %windir%\System32\rundll32.exe user32.dll,LockWorkStation...

How to achieve syncronization in loadbalanced multiserver environment

Hi, I have to create a .net web application which would run on more than one front end server which are load balanced. Now I have to use some third party api which is not thread safe so only one thread should call the API at a time so I have to use some syncronization machanism like lock or mutex which provide syncronisation within the p...

We have multiple app servers running against a single database. How do I ensure that each row in a queue table only get processed once?

We have about 7 app servers running .NET windows services that ping a single sql server 2005 queue table and fetch a fixed amount of records to process at fixed intervals. The amount of records to process and the amount of time between fetches are both configurable and are initially set to 100 and 30 seconds initially. Currently, my qu...

Must all Concurrent Data Store (CDB) locks be explicitly released when closing a Berkeley DB?

I have an application that comprises multiple processes each accessing a single Berkeley DB Concurrent Data Store (CDB) database. Each process is single-threaded and does no explicit locking of the database. When each process terminates normally, it calls DB->close() and DB_ENV->close(). When all processes have terminated, there shoul...

PHP MySQLi timeout on locked tables?

Hi guys I have a weird problem with mysqli timeout options, here you go: I am using mysqli_init() and real_connect() in order to set MYSQLI_OPT_CONNECT_TIMEOUT $this->__mysqli = mysqli_init(); if(!$this->__mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT,1)) throw new Exception('Timeout settings failed') $this->__mysqli->real_connect(h...

detecting locked tables mysql (locked by LOCK TABLE)

Hi guys, I would like to know whether is there an option to detect locked tables in mysql or no. I mean locked by LOCK TABLE table WRITE/READ command ? cheers, Marcin ...

Unable to delete file locked by same process -- weird!

I have an application written in PHP that uses a COM dll written in C#. The dll creates an image file by combining two other image files. The PHP script then takes over to do the housekeeping tasks of deleting the two source files and renaming the resulting combined file. The problem is the PHP script can't delete one of the source ...

Using Monitor Class

Dear All I would like to ask couple of Questions regarding the use of Monitor Class in .Net. To understand the Questions please look at the following Code. public class MyClass { private List<int> _MyCollection = new List<int>(); public void GetLock() { Monitor.Enter(_MyCollection); } public void Release...

What is the best way to apply rowlevel writelock in T-SQL? Best Practices And Samples Please

What is the best way to apply rowlevel writelock in T-SQL? Best Practices And Samples Please ...

How can two threads access a common array of buffers with minimal blocking ? (c#)

Hello, I'm working on an image processing application where I have two threads on top of my main thread: 1 - CameraThread that captures images from the webcam and writes them into a buffer 2 - ImageProcessingThread that takes the latest image from that buffer for filtering. The reason why this is multithreaded is because speed is cri...

Oracle global lock across process

I would like to synchronize access to a particular insert. Hence, if multiple applications execute this "one" insert, the inserts should happen one at a time. The reason behind synchronization is that there should only be ONE instance of this entity. If multiple applications try to insert the same entity,only one should succeed and other...

Do condition variables still need a mutex if you're changing the checked value atomically?

Here is the typical way to use a condition variable: // The reader(s) lock(some_mutex); if(protected_by_mutex_var != desired_value) some_condition.wait(some_mutex); unlock(some_mutex); // The writer lock(some_mutex); protected_by_mutex_var = desired_value; unlock(some_mutex); some_condition.notify_all(); But if protected_by_mutex...

Why use SyncLocks in .NET for simple operations when Interlocked class is available?

I've been doing simple multi-threading in VB.NET for a while, and have just gotten into my first large multi-threaded project. I've always done everything using the Synclock statement because I didn't think there was a better way. I just learned about the Interlocked Class - it makes it look as though all this: Private SomeInt as Integ...

Mysql SELECT FOR UPDATE - strange issue

Hi, I have a strange issue (at least for me :)) with the MySQL's locking facility. I have a table: Create Table: CREATE TABLE test ( id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1 With this data: +----+ | id | +----+ | 3 | | 4 | | 5 | | 6...

ASP.NET lock thread method

Hello, I'm developing an ASP.NET forms webapplication using C#. I have a method which creates a new Order for a customer. It looks similar to this; private string CreateOrder(string userName) { // Fetch current order Order order = FetchOrder(userName); if (order.OrderId == 0) { // Has no order ye...

detection of 'flush tables with read lock' in php

I would like to know from my application if a myisam table can accept writes (i.e. not locked). If an exception is thrown, everything is fine as I can catch this and log the failed statement to a file. However, if a 'flush tables with read lock' command has been issued (possibly for backup), the query I send will pretty much hang out f...