locking

How to change the locking mechanism in Alternative PHP Cache (APC)?

I recently read in a presentation on Scribd that Facebook had benchmarked a variety of locking mechanisms for APC including file locks (default), IPC semaphore locks, linux Futex locks, pthread mutex locks, and spin locks. You can view this presentation by clicking the following link: APC@Facebook I was wondering if anybody knew off ha...

C# Lock WinForm Controls

In a program I have written users can add controls to the form and move them around and set some properties in a pseudo design mode. I want to be able to lock all these controls into one location when they press a button to switch to "data mode". How can I do this? I wanted to do be able to loop through all the controls and use the Lo...

Howto limit the map in Android?

I'm developing my first Android application and it is based partly on displaying some information in Google Maps. I've managed to set a new center point and a new default zoom level (the area I want to display is a city). Now is it possible to "lock" that new default view somehow? That is, the user should be able to zoom in/out and pan ...

how can we achieve second application read that file when first application not modifying it

i have two application first application is bash second is java which one of them is periodically deleting and recreating a specific file (first) the other one is also periodically reading this file and process it in it's own logic (second) how can we achieve second application read that file when first application not modifying it ...

C# Multithreading - Telling a waiting process that the first process has finished using the locked code?

I understand that when developing multithreaded applications you must synchronize access to shared memory using either, for instance, a monitor or a lock. QUESTION How do you tell the waiting process(proc2) that the process using the locked code block (proc1) has finished using the code? ...

How to organize ASP.NET request locking or row locking in DB

Hi! I've asp.net page/handler to access images. When performed fist request to the image I resize image to standard size(save on disk) and return it. So I need lock all request to the image except one. This one will resize image. Image identified by ID in URL, so I guess one lock object required per one image(ID in URL). My question is H...

How Do I Solve a Locking Issue in MySQL?

I suppose this issue applies to deadlocks, live-locks, or just lock wait timeouts. I'm trying to figure out what query is causing a lock that is preventing another query from executing. Oracle has (if memory serves) a LOCK table that you can join onto itself to determine which queries are locking others. I need a way to accomplish t...

Question on locking and transactions on MyISAM table

Hello, I have a counter field in a myisam table. To update the counter value in a multitasking environment (web server, concurrent queries from PHP) I need to lock the record for update. So I do it like this: START TRANSACTION; SELECT Counter FROM mytable ... FOR UPDATE; UPDATE Counter value or INSERT INTO mytable; // let's make s...

Replacing ReaderWriterLock with ReaderWriterLockSLim - troubles

Hi, due to performance problems I have replaced RWL with RWLSlim but I am experiencing troubles caused by previously (with RWL) accepted statements. As you can see, sometimes methodA calls another one which have inside ReadLock. The second method is also called from different places, so not always there is lock collision. Previously, Ac...

Message "current thread is in sleep,wait or join state" - locking?

Hi, I have encountered (for me) very strange problem. In my app, when pressing start button, all threads are activated, when pressing stop button, all threads are aborted and all collections are cleared. This is all happen at the main thread, while other procceses have their own threads or are running via threadpool. However, today I rep...

C++ multithreading: explicit locks in domain model classes

Guys, I'm developing a multiplayer game application with C++ and currently in the process of choosing an appropriate multithreading architecture for it. The core of the application is the endless loop which essentially updates each frame all entities of the game World. Currently this World loop is singlethreaded. It's working just fine...

Using lock with Threading.Timer

Hi, I have a Windows Service application which uses a Threading.Timer and a TimerCallback to do some processing at particular intervals. I need to lock down this processing code to only 1 thread at a time. So for example, the service is started and the first callback is triggered and a thread is started and begins processing. This work...

accessing disposed object

hi, i am using following class to provide access to language resources in an asp.net application. i render the page for selected language by getting the text values from database. so i try to optimize fetching texts by caching them in a static datatable. However, i am not sure whether its always safe to read from tableResources that it m...

popen - locks or not thread safe?

I've seen a few implementations of popen()/pclose(). They all used a static list of pids, and no locking: static int *pids; static int fds; if (!pids) { if ((fds = getdtablesize()) <= 0) return (NULL); if ((pids = malloc(fds * sizeof(int))) == NULL) return (NULL); memset(pids, 0, fds * sizeof(int)); } O...

xml Column update and Locking in Sql Server

Hi, I have a few windwos services. They get xml column from Sql server manipulate and update it. Service A- Gets XML Service B- Gets XML Service A- Updates XML (it will be lost) Service B- Updates XML I must lock row and I use next Code: SqlCommand cmdUpdate = new SqlCommand(); cmdUpdate.CommandText = "select MyXML from M...

C# locking read while writing binary file

Hi, I am trying to figure out how to write a binary file with a FileStream and BinaryWriter, and keep the file locked for read while I am writing. I specifically dont want other applications/processes to be able to read from the while while its being written to. //code to declare ba as a byte array //dpath is the path to the file Fi...

Determine thread which holds the lock on file

Hi, I know there is no WINAPI which would do it, but if a thread is hung and holds an open handle of file. how do we determine the thread id and Terminate it within our processes. I'm not talking about releasing file locks in other processes but within my own process. it could also be possible that thread has crashed / terminated with...

Database Locking Problem

Hi All, Pls. we've been getting A LOT of locks on a production database that's recently witnessed substantially increased traffic. We are using IdeaBlade for most of the data access. I got the following trace using Sql Profiler: deadlock victim="process84af28" resource-list keylock hobtid="72057594096451584" dbid="6" objectname=...

Am I right that InnoDb is better for frequent concurrent updates and inserts than MyISAM?

Hello, We have a websites with hundreds of visitors every day and tens of thousands queries a day. So, some tables in the database are updated very rarely, some tables are updated few times a minute and some tables are updated ~10 times a seconds. MyISAM uses table-level locking for updates and InnoDb uses row-level locking. So, as I und...

Lockfree standard collections and tutorial or articles.

Does someone know of a good resource for the implementation (meaning source code) of lock-free usual data types. I'm thinking of Lists, Queues and so on? Locking implementations are extremely easy to find but I can't find examples of lock free algorithms and how to exactly does CAS work and how to use it to implement those structures. ...