Questions tagged [deadlock]

0

votes
0

answer
18

Views

Can scoped_lock lock a shared_mutex in read mode?

C++17 introduced both std::shared_mutex and std::scoped_lock. My problem is now, that it seems, that scoped_lock will lock a shared mutex always in exclusive (writer) mode, when it is passed as an argument, and not in shared (reader) mode. In my app, I need to update an object dst with data from an...
Kai Petzke
14

votes
5

answer
1.2k

Views

Is there a C++ design pattern that implements a mechanism or mutex that controls the amount of time a thread can own a locked resource?

I am looking for a way to guarantee that any time a thread locks a specific resource, it is forced to release that resource after a specific period of time (if it has not already released it). Envision a connection where you need to limit the amount of time any specific thread can own that connectio...
Jay Elston
1

votes
2

answer
1.5k

Views

Deadlock with multiprocessing module

I have a function that without multiprocessing loops over an array with 3-tuples and does some calculation. This array can be really long (>1million entries) so I thought using several processes could help speed things up. I start with a list of points (random_points) with which I create a permutati...
Philipp
1

votes
2

answer
3.3k

Views

How to prevent deadlock in SQL Server stored procedure?

I'm calling a stored procedure which performs either an INSERT or an UPDATE dependent on the procedure key being present in a table. So far the procedure was working as expected. Until our user base started to grow in size. Today I got the following error which was resolved by restarting the Applica...
Brian J
1

votes
1

answer
38

Views

One channel with one receiver and unknown number of goroutines senders causing deadlock

I have one channel and the receiver is main. I spawn multiple goroutines that each send a string over the channel. Now, this causes a deadlock because I didn't close the channel properly using the close function. The thing is, I have no idea how many goroutines will be created, so there's no way to...
Alex Ferg
1

votes
3

answer
2.7k

Views

Small OpenMP program sometimes freezes (gcc, c, linux)

Just write a small omp test, and it does not work correctly all the times: #include int main() { int i,j=0; #pragma omp parallel for(i=0;i
osgx
1

votes
2

answer
767

Views

Multi-thread file access (locking control)

i have two programs working on the same file i want the first program to check regularly on the file, and if any changes are made operate on the file and empty it. the other program writes to the file. the problem occurs when the second program tries to write on the file because it's used from the f...
Muaaz
1

votes
1

answer
940

Views

WCF Service Causes SQL Deadlock Error

I have been beating my head against the wall with this for the last couple days and I can’t seem to come up with a good solution. I have a WCF service that acts as the only entry point with all of our database interactions. In the current dilemma, there is a Windows Service that spins against an ...
keannan5390
1

votes
3

answer
73

Views

Why does this NOT cause a dead-lock

Why does the following piece of code not cause a deadlock? From my limited understanding of multi-threading programming, when getBar1() is called, sharedBuffer would be 'locked', hence, when the method tries to call getBar2(), the thread would have to wait for sharedBuffer (which is held by itself!)...
One Two Three
1

votes
1

answer
2.6k

Views

NHibernate query deadlock in case multiple connection

I have next transaction: Desc d = new Desc(); d.Descr = "new"; _sess.Transaction.Begin(); _sess.SaveOrUpdate(d); var desc = _sess.CreateCriteria(typeof(Desc)).List(); _sess.Transaction.Commit(); This transaction performs next query: BEGIN TRANSACTION INSERT SELECT COMMIT TRANSACTION When I perform...
Artemoniks
1

votes
2

answer
679

Views

Cross-Platform Condition Variable troubles

In our project, we need to implement os dependent abstractions (like file, socket, thread...) for each os (linux, android, osx and win). The general iter for implementing os abstraction is: Write an os independent class header which defines methods that are common for each os (Cond). Write an os de...
mikymod
1

votes
0

answer
3

Views

Why MySQL InnoDB creates so many deadlocks when Hangfire enques multiple jobs in parallel?

In my asp.net core application I am using Hangfire with MySQL database storage. I have an endpoint which when accessed schedules a hangfire job on the background. When I do load testing to this endpoint, if I send more than 40 concurrent requests, this code BackgroundJob.Schedule(s => s.ScheduleSome...
Dejan Bogatinovski
1

votes
1

answer
1.3k

Views

Write a static synchronized method (wait for a result from thread)

I have a problem with a task. Namely, we must write a class, which is called from Threads. One of the methods is: public static synchronized void waitForResults() { } So the Master-Thread calls this method, and then the Master-Thread triggers an other Thread, that new work is to be done. How can I t...
Halso Johnson
1

votes
1

answer
893

Views

Non resource deadlock?

I've gotten a question from my professor in operating systems that reads "Explain non resource deadlocks", and I haven't got a clue what I'm supposed to answer! Doesn't a deadlock require some kind of resource to hog to be considered an actual deadlock? If any of you have any suggestion to what he m...
Sappalele
1

votes
1

answer
480

Views

Asynchronous Cocoa - Preventing “simple” (obvious) deadlocks in NSOperation?

When subclassing NSOperation to get a little chunk of work done, I've found out it's pretty easy to deadlock. Below I have a toy example that's pretty easy to understand why it never completes. I can only seem to think through solutions that prevent the deadlock from the caller perspective, never th...
edelaney05
1

votes
3

answer
1.7k

Views

Implementing an thread-safe queue with pThreads: Deadlock?

I'm trying to implement a thread-safe queue based on a fixed array. The queue holds an array of void pointers. pthread_t a; pthread_t b; Queue *q; Queue* queue_new(int size) { // malloc stuff } void queue_put(Queue* q, void* item) { pthread_mutex_lock(&(q->lock)); // details on array queue managment...
Joachim
1

votes
1

answer
84

Views

How to stop a thread whose run() doesnt have a loop

How to stop a thread whose run() doesnt have a loop. So basically I want a replacement for the stop() method. I want to stop one of the Thread when there is a deadlock. I dont want to use locks. Just want to kill one thread so that the resource will be freed and other Thread will continue thus en...
Ravindra
1

votes
1

answer
164

Views

Alternative to solve the DeadLock in java

I am reading Java Concurrency Tutorial from Oracle. And there is an example of the DeadLock Core code: public synchronized void bow(Friend bower) { System.out.format("%s: %s" + " has bowed to me!%n", this.name, bower.getName()); bower.bowBack(this); } public synchronized void bowBack(Friend bower)...
hguser
1

votes
2

answer
247

Views

Testing go channel throughput - all goroutines deadlock

I made a small program to benchmark go channel throughput, however it always deadlocks, I tried very hard but cannot understand why: package main import ( "fmt" "runtime" ) const CONCURRENCY = 32 const WORK_PER_WORKER = 100 const TOTAL_WORK = CONCURRENCY * WORK_PER_WORKER func work() { sum := 0 for...
1

votes
1

answer
5.2k

Views

SQL Server Deadlock on UPDATE for the same table

I have 3 stored procedures (simplified, please try to ignore why I'm updating the table twice and why the SP is called twice): CREATE SP1 AS BEGIN TRANSACTION -- Updated twice UPDATE Customers SET Name = 'something' Where Id = 1 OUTPUT INSERTED.* UPDATE Customers SET Name = 'something' COMMIT TRANSA...
Uri Abramson
1

votes
1

answer
209

Views

BroadcastReceiver onReceive() Race Condition / Deadlock

I was wondering if Android's BroadcastReceiver's onReceive() message can result in race conditions and/or deadlocks? I have read Android's developer pages in regards to the BroadcastReceiver's onReceive() method but cannot discern the answer to my question. Let's assume that I have implemented code...
Justin Papez
1

votes
1

answer
68

Views

Channels Deadlock

I'm building an asynchronous Btree in Go with channels, but I'm getting the error fatal error: all goroutines are asleep - deadlock! I don't know why 'cause I'm getting the values from the channel in a for loop with a buffered channel. type Obj interface { Compare(node Obj) int } type Tree struct {...
sescob27
1

votes
1

answer
592

Views

Task deadlocks because of Result

I have the following construct: A base-class which does some loading tasks asynchronously and a inherited class which only converts the result of the base-class into a special data-type (it's just a generic version with some extensions, but those are not of importance). I initially call the inherite...
SharpShade
1

votes
1

answer
976

Views

how to synchronize a set of multiple threads with respect to a single thread in Java

Suppose that I have an arraylist called myList of threads all of which are created with an instance of the class myRunnable implementing the Runnable interface, that is, all the threads share the same code to execute in the run() method of myRunnable. Now suppose that I have another single thread ca...
Pablo Messina
1

votes
1

answer
268

Views

task deadlock when invoking in worker threads

I have a windows form program (**VS 2010 .NET 4 **) that detecting recursively folders and sub folders of a directory and optimizing files. I do it by tasking library and have a progressbar that shows progress of item and label near progressbar that shows current file. I have a SetText(string text)...
Hamed_gibago
1

votes
3

answer
501

Views

Execution stops in possible deadlock

I've continued working on my program yesterday after a month long break. I didn't change anything on the code but now my application does not start anymore. At one point it just interrupts execution and seems to be stuck in a deadlock, though I'm not sure if it really is a deadlock since it happens...
SharpShade
1

votes
1

answer
293

Views

Deadlock / Access violation in my code even though I've mutually excluded it

So I'm trying to better understand multi threading and how deadlocks happen and how to avoid them so I put together a small piece of code. Basically I have two threads which share an int pointer. Each thread both reads and writes from/to the value being pointed to. When a thread writes (increases th...
Joe Bid
1

votes
1

answer
349

Views

pthread process shared mutex deadlock

I use process shared pthread_mutex_t on shared memory. I wonder what if a process lock the mutex and somehow exit, what will happen? As my experiment shows, deadlock happens, but this is a bad news. So is there a way to prevent this? Should not the mutex automatically unlocked when process exit?
Hoping White
1

votes
2

answer
101

Views

Deadlock when calling dispatch_sync() even though it's on another queue

I am aware that calling dispatch_async in the current queue will cause a deadlock, however, experiencing a deadlock in a completely different queue: -(void) deadlock{ // we reach this point in the main queue dispatch_sync(dispatch_queue_create("lucas", 0), ^{ NSLog(@"Doing something in the bakcgound...
cfischer
1

votes
1

answer
644

Views

IMobileServiceClient.PullAsync deadlock when trying to sync with Azure Mobile Services

I have the classes below. public class AzureMobileDataContext : IAsyncInitialization { private static readonly Lazy lazy = new Lazy (() => new AzureMobileDataContext( new MobileServiceClient( "http://myservice.azure-mobile.net/", "123456789ABCDEFGHIJKLMNOP"))); public static AzureMobileDataContext...
George Taskos
1

votes
1

answer
289

Views

Threads locked in TraceSource methods by Console

I've run into a situation and I don't know if it can be resolved. I've started adding a TraceSource and trace statements to my multithreaded service, and I'm running into locks in the threads that process the trace methods in my code. This is causing the entire app to hang. My service is configure...
khargoosh
1

votes
5

answer
441

Views

Deadlocks occur more often in a two-tier architecture or in a three-tier architecture? And why?

I am working with Microsoft Navision 2009 and a lot of times, if for example you make a new order, and change something later on the records, then often occurred that you will get a message: Another user has changed the records and you cant do anything to change the records. So we now investigate i...
InfinityGoesAround
1

votes
1

answer
58

Views

Why is my waiting thread not waking up even though it's being notified?

I have a client server tic-tac-toe game which is attempting to run a different thread (in different terminals) for each player, which I have built in eclipse. My goal is to make each player make their move, .notify() the other player and then .wait() for the other player to make their move, and alte...
Sebastian C
1

votes
1

answer
580

Views

Deeadlock prevention :Mutual Exclusion

Deadlock prevention say : All four of the conditions are necessary for deadlock to occur, it follows that deadlock might be prevented by denying any one of the conditions. condition Mutual Exclusion Hold and Wait No Premption Circular Wait Now Let us Deny first one Mutual Exclusion There are many...
laura
7

votes
3

answer
5.1k

Views

Handling innoDB deadlock

I've been getting a Deadlock found when trying to get lock; try restarting transaction error on my InnoDB tables. Here is the query: UPDATE views SET visit_cnt = visit_cnt + 1 WHERE visit_day = DATE(NOW()) AND article_id = '4838' This query also triggers this via ON UPDATE trigger: UPDATE article...
Silver Light
9

votes
1

answer
143

Views

VSIX - Deadlock on XmlEditingScope.Complete()

We are using the classes in the Microsoft.VisualStudio.XmlEditor namespace (https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.xmleditor.aspx) to modify an xml document in an Visual Studio Extension. For some reason a deadlock occurs after calling the XmlEditingScope.Complete() method....
TWT
3

votes
2

answer
3.1k

Views

how to create deadlock situation in the oracle on a table which is having simple 4 columns(sno,name,job,dept)?

i wanted to create a deadlock situation in the oracle table which will not give response and will be hang on executing the same query from the java application ?Could you please provide one sample query which makes this situation on a table (having 4 columns sno,name,job,dept ) .
user3442562
1

votes
3

answer
90

Views

How to Implements Dead Lock Example in Java

I'm reading about Java Deadlock Situations, I have understood about where deadlock can occur, But I'm facing problem how I can implement the below example. public class DeadLockDemo { public void method1() { synchronized (String.class) { System.out.println("Aquired lock on String.class object"); syn...
Asif Mushtaq
0

votes
2

answer
32

Views

Class initialization deadlock mechanism explanation

I found article(https://habr.com/company/odnoklassniki/blog/255067/) from the @apangin(https://stackoverflow.com/users/3448419/apangin) on my native langugage but I am not able to understand it. Explanation is very concise Let's consider that code: static class A { static final B b = new B(); } stat...
gstackoverflow
0

votes
0

answer
13

Views

Updating a row at the same time

Imagine I have a table with two columns that have a point register from two different teams, like the one below: TABLE: first_team second_team first_team_points second_team_points The table has the relation of the two teams and the points they get when they finish a level during a period of time. Th...
Kane

View additional questions