mutex

App hangs at __psynch_mutexwait

☆樱花仙子☆ 提交于 2019-12-05 02:24:14
Our app seems to semi-randomly hang at psynch_mutexwait. It seems to be related to a background process that updates a bunch of data stored in CoreData - but I've been completely unable to figure out just who is locking on what to cause the deadlock. Following is the complete stack trace that lldb gives me - which is obviously incomplete, AND the last frame of Thread 1 is bogus. I had a breakpoint in that method a few lines before that, and it was never hit. Is there ANY way of figuring out what lock is being waited on? (or even get correct stack traces?) Of course there is LOTS of code

Does QMutex need to be static so other threads calls of this class instance know to suspend their operations?

▼魔方 西西 提交于 2019-12-05 01:39:28
问题 From multiple threads the following append function is called. I don't want data to re-write an append because the counter had not yet been incremented. Will this suspend all threads coming in except for the one currently using Append? Or will the other threads just continue running and not append the data? Does the mutex need to be "STATIC" or will each instance know to suspend operations? If I don't want hiccups, I assume I have to build a buffer to back log data? void classA::Append(int

std::timed_mutex::try_lock* fail spuriously

佐手、 提交于 2019-12-05 00:43:25
By try_lock* , I take to mean try_lock() , try_lock_for() , and try_lock_until() . According to cppreference , all three methods may just fail spuriously. Following is quoted from the description for try_lock_for() As with try_lock() , this function is allowed to fail spuriously and return false even if the mutex was not locked by any other thread at some point during timeout_duration . I know that spurious wakeup may happen with std::condition_variable and the rationale behind it. But, what is the case with a mutex? According to: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3209

Delete an object securely from a multi-threaded program

我是研究僧i 提交于 2019-12-04 21:40:28
DISCLAIMER: neither Boost, nor C++11 allowed. I've a program, in which I create an instance of Foo and I operate with it in a number of threads. Then I want to delete it securely so those threads do not fall into a segmentation fault. I've added a mutex member to Foo and lock it each time a thread function runs. In order different threads do not conflict with each other. class Foo { public: pthread_mutex_t mutex; }; void* thread ( void* fooPtr ) { Foo* fooPointer = (Foo*) fooPtr; while ( 1 ) { if ( fooPointer ) { pthread_mutex_lock ( &fooPointer->mutex ); /* some code, involving fooPointer */

Maintaining single instance application

人走茶凉 提交于 2019-12-04 17:54:33
I have been working on this application of mine and got this problem. Running program through command line with different arguments opens different .exe process. My question is how can i prevent from opening same file few times, and is it possible to send new command line arguments to already open instance of application. Thanks. There are standard .NET classes for that. Check out: http://www.openwinforms.com/single_instance_application.html http://www.smartasses.be/2009/04/24/single-instance-application-with-c/ http://www.google.be/search?source=ig&hl=nl&rlz=&q=SingleInstanceApplication&btnG

difference between std::mutex and std::shared_mutex

巧了我就是萌 提交于 2019-12-04 17:37:36
问题 I came across an std::shared_mutex in C++17 . what exactly is std::shared_mutex and how it is different from std::mutex ? 回答1: As noted in the documentation The shared_mutex class is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads. In contrast to other mutex types which facilitate exclusive access, a shared_mutex has two levels of access: shared - several threads can share ownership of the same mutex . exclusive - only

Send parameters to a running application in C#

断了今生、忘了曾经 提交于 2019-12-04 17:06:45
I am trying to send parameters to an application which is already in the processor. I am using Mutex to find if the application is running or not already. I need to send any command line parameter and that text is added to the listbox. But the parameter is going in but the values are not getting added to the listbox. Application's name is "MYAPPLICATION" and the function which adds the value to listbox is parameters() static class Program { /// <summary> /// The main entry point for the application. /// </summary> [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern

Thread-safe way to build mutex protection into a C++ class?

☆樱花仙子☆ 提交于 2019-12-04 16:30:47
I'm trying to implement a producer/consumer model multithreaded program in C++ for a project I'm working on. The basic idea is that the main thread creates a second thread to watch a serial port for new data, process the data and put the result in a buffer that is periodically polled by the main thread. I've never written multi-threaded programs before. I've been reading lots of tutorials, but they're all in C. I think I've got a handle on the basic concepts, but I'm trying to c++ify it. For the buffer, I want to create a data class with mutex protection built in. This is what I came up with.

How does this implementation of semaphore work?

自古美人都是妖i 提交于 2019-12-04 15:11:34
问题 Merry Xmas! I'm reading the The Little Book of Semaphores. There is an implementation of semaphores in C in the book that I don't completely understand. See below for code. There is this wakeups variable. The author explains: wakeups counts the number of pending signals; that is, the number of threads that have been woken but have not yet resumed execution. The reason for wakeups is to make sure that our semaphores have Property 3, described in Section 4.3 and Property 3: if there are threads

Fastest Multi-Reader / Single Writer Protection for Shared Resources - C++

岁酱吖の 提交于 2019-12-04 14:16:22
问题 I would like confirmation that my approach is extremely fast and appropriate for cross platform protection of a shared resource for a mostly multiple reader, single writer approach using C++. It favors writers such that when they enter all current threads are allowed to finish, but all new threads of any type must wait. The reverse of these two functions should be obvious. The reading I've done suggest that boost shared_mutex and other type rwlocks are not implemented very well and should be