locking

Error opening streamreader because file is used by another process

I am developing an application to read an excel spreadsheet, validate the data and then map it to a sql table. The process is to read the file via a streamreader, validate the data, manually make corrections to the excel spreadsheet, validate again -- repeat this process until all data validates. If the excel spreadsheet is open, the...

Explain the code: c# locking feature and threads

I used this pattern in a few projects, (this snipped of code is from CodeCampServer), I understand what it does, but I'm really interesting in an explanation about this pattern. Specifically: Why is the double check of _dependenciesRegistered. Why to use lock (Lock){}. Thanks. public class DependencyRegistrarModule : IHttpModule { ...

How can I lock files in android using java code?

I want to lock files that is on the sdcard of android. I need to lock them so no one except my software can delete copy move or send them over bluetooth or any other way. How can I do it? ...

How do filesystems handle concurrent read/write?

User A asks the system to read file foo and at the same time user B wants to save his or her data onto the same file. How is this situation handled on the filesystem level? ...

How do I make a checkbox in jQuery lock a existing sliding window from moving and then unlock it by unchecking the box?

I`m very new to jQuery but am starting to get the hang of it. My Question is: How do I make a checkbox in jQuery lock a existing sliding window function from moving and then unlock it by unchecking the box? So basically enable/disable a existing function in my project called - #navigate Any help would be greatly appreciated! ...

Generating a set of files containing dumps of individual tables in a way that guarantees database consistency

I'd like to dump a MySQL database in such a way that a file is created for the definition of each table, and another file is created for the data in each table. I'd like this to be done in a way that guarantees database integrity by locking the entire database for the duration of the dump. What is the best way to do this? Similarly, w...

MEMORY(HEAP) vs. InnoDB in a Read and Write Environment

I want to program a real-time application using MySQL. It needs a small table (less than 10000 rows) that will be under heavy read (scan) and write (update and some insert/delete) load. I am really speaking of 10000 updates or selects per second. These statements will be executed on only a few (less than 10) open mysql connections. The...

Python Locking Implementation (with threading module)

This is probably a rudimentary question, but I'm new to threaded programming in Python and am not entirely sure what the correct practice is. Should I be creating a single lock object (either globally or being passed around) and using that everywhere that I need to do locking? Or, should I be creating multiple lock instances in each...

Deleting a possibly locked file in c

I am using fcntl locks in C on linux and have a dilemma of trying to delete a file that may possibly be locked from other processes that also check for the fcntl locking mechanism. What would be the preferred way of handling this file which must be deleted, (Should I simply delete the file w/o regard of other processes that may have read...

Locking a file to verify a single execution of a service. How reliable?

Hello, I am deploying a little service to an UNIX(AIX) system. I want to check if there is no active instance of that service running when starting it. How reliable is to implement that check like this? Try to acquire a lock on a file (w/ FileChannel) If succeeds, keep lock and continue execution If fails, exit and refuse to run the m...

Real World Examples of read-write in concurrent software

I'm looking for real world examples of needing read and write access to the same value in concurrent systems. In my opinion, many semaphores or locks are present because there's no known alternative (to the implementer,) but do you know of any patterns where mutexes seem to be a requirement? In a way I'm asking for candidates for the s...

Lock thread using somthing other than an object

when using a lock does the thing you are locking on have to be a object. For example is this legal static DateTime NextCleanup = DateTime.Now; const TimeSpan CleanupInterval = new TimeSpan(1, 0, 0); private static void DoCleanup() { lock ((object)NextCleanup) { if (NextCleanup < DateTime.Now) ...

Is there any kind of standard for 8086 multiprocessing?

Back when I made an 8086 emulator I noticed that there was the LOCK prefix intended for synchonization in a multiprocessor environment. Yet the only multitasking I know of for the x86 arch. involves use of the APIC which didn't come around until either the Pentiums or 486s. Was there any kind of standard for 8086 multitasking or was it...

Guidelines of when to use locking

I would like to know if there are any guidelineswhich a developer should follow as to when (and where) to place locks. For instance: I understand that code such as this should be locked, to avoid the possibility of another thread changing the value of SomeHeapValue unexpectedly. class Foo { public SomeHeapObject myObject; public v...

Best practice for avoiding locks on a heavily read table?

Hi, I have a big database (~4GB), with 2 large tables (~3M records) having ~180K SELECTs/hour, ~2k UPDATEs/hour and ~1k INSERTs+DELETEs/hour. What would be the best practice to guarantee no locks for the reading tasks while inserting/updating/deleting? I was thinking about using a NOLOCK hint, but there is so much discussed about this...

SQLite how to use perl DBI to return SQLite database waiting status?

Hi! I used BEGIN EXCLUSIVE for my write transaction so that the other users connect to the database at the same time will have to wait. My question is "Is there a way to track how long the script has been waiting before timeout"? I would like to return either a "database locked" or "sqlite busy" message to a variable in my script and ex...

How pattern lock disbles screen lock in android

Hi, In android 2.1, if we enable pattern lock, then the screen lock (slide to unlock) is not displayed and if pattern lock is disabled then screen lock is enabled again. Can someone point me out the java file in framework and the function where this happens. I mean when the screen is about to get locked, how does android decide that whe...

Lock innoDB table temporarily

Hi everyone, I make bigger inserts consisting of a couple of thousand rows in my current web app and I would like to make sure that no one can do anything but read the table, until the inserts have been done. What is the best way to do this while keeping the read availability open for normal, non-admin users? Thanks! ...

Putting a thread to sleep until event X occurs

I'm writing to many files in a threaded app and I'm creating one handler per file. I have HandlerFactory class that manages the distribution of these handlers. What I'd like to do is that thread A requests and gets foo.txt's file handle from the HandlerFactory class thread B requests foo.txt's file handler handler class recognizes tha...

android unlock screen intent?

Is there an intent that is fired when a user unlocks their screen? I want my app to adjust the brightness when the screen turns on, but the problem im running into is that the screen on intent is fired on the lock screen and it does not adjust the display on that screen. ...