locking

Making pthread_rwlock_wrlock recursive

依然范特西╮ 提交于 2019-12-05 08:43:19
I have a problem regarding the behaviour of the pthread function pthread_rwlock_wrlock . The specification linked above states that when one thread has locked the lock for writing and the same thread locks it again, it results in undefined behaviour (I could actually observe this in that on x86 Linux calling this function is a noop and on PowerPC Linux it stalls the thread). The behaviour I need would be a read write lock that has the following characteristics: read-locking by a thread succeeds if: the lock is not held by any thread the lock is only read-locked by zero or more threads

Corrupted lock ? Magic deadlock?

这一生的挚爱 提交于 2019-12-05 08:26:00
I work with multethreading bug. Now I see that for some reason lock isn't executed even once but is locked. I have the next class: public sealed class Foo { private readonly object _lock = new object(); private static ulong _inCnt = 0; public void SomeMethod(ulong poo) { lock (_lock) { _inCnt++; ... [some code] } } } I paused all threads in the VS, inspected all of them and see that there is only one thread in the SomeMethod and it is waiting for lock (_lock) to be freed (_inCnt = 0) . I resumed threads, waited for a while, paused threads and see the same picture, the same (and only one)

Pessimistic locking in EF code first

醉酒当歌 提交于 2019-12-05 08:02:51
I'd like to lock specified row(s) in my table exclusively, so no reads no updates allowed until the actual transaction completes. To do this, I've created a helper class in my database repository: public void PessimisticMyEntityHandler(Action<IEnumerable<MyEntity>> fieldUpdater, string sql, params object[] parameters) { using (var scope = new System.Transactions.TransactionScope()) { fieldUpdater(DbContext.Set<MyEntity>().SqlQuery(sql, parameters)); scope.Complete(); } } Here is my test code. Basicly I'm just starting two tasks and both of them tries to lock the row with the Id '1'. My guess

How to see SQL 2008 Locks and Blocked Tables

守給你的承諾、 提交于 2019-12-05 07:55:06
During the ASP.NET execution of my app, it seems SQL 2008 Express holds some lock, and I get Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding Maybe some of my query is not optimized. Visual Studio crashes with: Microsoft Visual Studio may be unstable now. It is recommended that you save all files and exit. I need to see what query is blocking my tables, but I have the Express version. How can I do? Thanks You can query against the sys.dm_tran_locks dynamic view to obtain this information. Go here on MSDN to lean more. exec sp_lock

PostgreSQL row read lock

只谈情不闲聊 提交于 2019-12-05 07:54:39
问题 Let’s say I have a table called Withdrawals (id, amount, user_id, status). Whenever I a withdrawal is initiated this is the flow: Verify if user has sufficient balance (which is calculated as sum of amount received - sum of withdrawals amount) Insert row with amount, user_id and status=‘pending’ Call 3rd party software through gRPC to initiate a withdrawal (actually send money), wait for a response Update row with status = ‘completed’ as soon we a positive response or delete the entry if the

Java threads waiting to lock object that isn't (visibly) locked

怎甘沉沦 提交于 2019-12-05 07:51:40
Normally when I ask for a thread dump, the symptoms of a poorly performing system are easily explained; i.e. normally I would be able to see that a number of threads are clearly waiting on a monitor which has been acquired but not released by another. In this case, I have a lot of threads waiting for a monitor (0x965ad100), but none appears to have that monitor in the first place. The threads in question can be identified with this signature: waiting to lock <0x965ad100> (a uk.gov.dti.og.fox.ConAgent) I've tried Googling this, and all I seem to find are posts that discuss monitors that are

How to transfer locks between threads?

让人想犯罪 __ 提交于 2019-12-05 07:21:19
问题 I would like to Monitor.Enter(this.StaticLock); try { // Do something ... ThreadPool.QueueUserWorkItem(state => { try { // Do something else... } finally { Monitor.Exit(this.StaticLock); } }); } catch (Exception) { Monitor.Exit(this.StaticLock); throw; } But it doesn't work since the it can't Monitor.Exit on an object that wasn't Monitor.Enter in the current thread. How to do that? Should I use interthread communication? 回答1: Semaphore s allow you to lock them in one thread and unlock them in

Collection was modified; enumeration operation may not execute. Lock is being used everywhere how possible?

六月ゝ 毕业季﹏ 提交于 2019-12-05 06:54:24
This is a small program that only i am writing and using. Now i am going to write code of all areas where i use the hashset that caused this problem I don't understand how this is possible. This item is being used only at MainWindow hsProxyList is a hashset HashSet<string> hsProxyList = new HashSet<string>(); the error happened at below iteration lock (hsProxyList) { int irRandomProxyNumber = GenerateRandomValue.GenerateRandomValueMin(hsProxyList.Count, 0); int irLocalCounter = 0; foreach (var vrProxy in hsProxyList) { if (irLocalCounter == irRandomProxyNumber) { srSelectedProxy = vrProxy;

python multiprocessing: write to same excel file

不羁的心 提交于 2019-12-05 05:35:34
问题 I am new to Python and I am trying to save the results of five different processes to one excel file (each process write to a different sheet). I have read different posts here, but still can't get it done as I'm very confused about pool.map, queues, and locks, and I'm not sure what is required here to fulfill this task. This is my code so far: list_of_days = ["2017.03.20", "2017.03.21", "2017.03.22", "2017.03.23", "2017.03.24"] results = pd.DataFrame() if __name__ == '__main__': global list

Workarounds for ReadUncommitted Isolation level in an SSIS package

▼魔方 西西 提交于 2019-12-05 05:29:02
问题 The ReadUncommitted IsolationLevel in SSIS is a bug acknowledged by Microsoft for the following but 'Wont fix' as described below. http://connect.microsoft.com/SQLServer/feedback/details/498891/ssis-setting-isolationlevel-to-readuncommitted-still-uses-read-committed#details What would be the workaround(s) for the same? 回答1: yes, but you have to inform the sql command on your source instead of selecting a table and set the isolation level before the execution: SET TRANSACTION ISOLATION LEVEL