locking

Preventing multiple executions

一世执手 提交于 2019-12-11 12:07:34
问题 I have this Django cron job script (I am using kronos for that, which is great). Since I trigger this job every minute, I want to make sure that there isn't another instance of the script already running. If there is a previous job running, then I want to skip the current execution. I know I can do that with a lock file, but that's not very reliable and can cause problems when you reboot in the middle of an execution (you have to clear the lock file), etc. What's the best way to do this using

Database- or user-level locks

跟風遠走 提交于 2019-12-11 11:56:42
问题 I'm currently facing the following problem: I have a C# .NET application connecting to a database (with the use of NHibernate). The application basically displays the database content and lets the user edit it. Since multiple instances of the application are running at the same time (on the same and on different workstations) i'm having concurrency problems as soon as two users modify the same record at the same time. Currently I kind of solved the issues with optimistic locking. But this is

I am trying to implement a resource handler class. It must be deadlock-free and starvation-free

女生的网名这么多〃 提交于 2019-12-11 11:34:35
问题 It is a homework assignment. I have two files which were already given. The Client class and the SharedValues Interface . Here is the description: I need to write a class (resource handler) which contains static interfaces and manage "n" number of resource allocation and its scheduling for "k" number of clients. there must be only two operations for the clients. Reading and writing with no deadlock and no starvation . If one resource is allocated for writing then other clients can't have it

How to get the amount of threads waiting to enter a lock?

戏子无情 提交于 2019-12-11 11:31:00
问题 Is it possible to get a value which indicates how many threads are waiting to acquire a lock on a certain object? 回答1: No, but you could incapsulate the lock in a class that does: Interlocked.Increment before entering the lock on a counter and Interlocked.Decrement after attaining the lock For example: public sealed class SimpleCountedLock { private readonly object obj = new object(); private int counter; public int Counter { get { // Guaranteed to return the last value return Interlocked

Thread Locking in Ruby (use of soap4r and QT)

元气小坏坏 提交于 2019-12-11 10:52:49
问题 [EDIT NOTE: Noticed I had put the mutex creation in the constructor. Moved it and noticed no change.] [EDIT NOTE 2: I changed the call to app.exec in a trial run to while TRUE do app.processEvents() puts '." end I noticed that once the Soap4r service started running no process events ever got called again] [EDIT NOTE 3: Created an associated question here: Thread lockup in ruby with Soap4r I'm attempting to write a ruby program that receives SOAP commands to draw on a monitor (thus allowing

SQLite error (10): delayed 25ms for lock/sharing conflict

旧巷老猫 提交于 2019-12-11 10:07:49
问题 My C#/SQLite app works fine but outputs this error once in a while: SQLite error (10): delayed 25ms for lock/sharing conflict As suggested on this thread, I updated to the latest SQLite, but it still happens. How to fix this? SQLite version: sqlite-netFx40-static-binary-Win32-2010-1.0.84.0.zip at the Precompiled Statically-Linked Binaries for 32-bit Windows (.NET Framework 4.0) paragraph at http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki Visual C# 2010 Express 回答1: From

How to pause/resume or change the period time of TimerTask?

强颜欢笑 提交于 2019-12-11 09:58:40
问题 my original purpose is to execute a section of code every xx TimeUnit without simply looping it and checking a flag. I do some researches and found two solution: Timer + TimerTask - Once the timer is pause, you have to re-new another one. So do the TimerTask. ScheduledThreadPoolExecutor + Runnable - The same as the previous combination. But somebody say this is a enhanced one. But it still don't provide the functions I mentioned before. Now, I'm looking for a elegant method to solove this

The scrollviewer “locks” when scrolling vertically or horizontally

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 09:45:23
问题 If I start the scrolling vertically or horizontically the scroller "locks", such that you can only scroll horizontically or vertically, untill you let go. If I however start of by scrolling diagonally, there is no problem, in thhese cases I can manouvre the scrollviewer how i want. How do I make sure that the scrollViewer doesn't "lock" if I start of scrolling vertically or horizontically. Here is my scrollViewer: <StackPanel> <TextBlock x:Name="MainPageTitle" Text="{Binding title}" Height=

Translate following C# synchronization logic to Stored Procedure

梦想的初衷 提交于 2019-12-11 09:38:24
问题 I have following Entity Framework Logic, and I want to translate to Stored Procedure, I have tried using exclusive lock in Stored Procedure but it results in lots of timeouts... Think of Page as some sort of Hard disk which has 4 columns Pages PageID SpaceAvailable SpaceOccupied TotalSpace and I need to allocate my objects in the pages as the space is available, if object can not fit, it will get the next available page. // a static lock to prevent race condition static object Locker = new

Acquiring lock - C# SQL server

不羁岁月 提交于 2019-12-11 08:49:11
问题 Database : SQL server 2005 Programming language : C# I have a method that does some processing with the User object passed to it. I want to control the way this method works when it is called by multiple threads with the same user object. I have implemented a simple locking which make use of database. I can't use the C#'s lock statement as this method is on a API which will be delivered on different machines. But the database is centralized. Following code shows what I have. (Exception