condition-variable Questions
2
Solved
I find that the std::mutex implementation in Visual Studio 2013 is too slow. It uses a heavy weight mutex to assure that synchronization can be achieved even between processes which is all fine and...
Caveat asked 2/9, 2014 at 10:28
2
Solved
I am new to multi threading. While writing multi threaded code in C++11 using condition variable , I use the following construct
while(predicate) {
cond_var.wait(&lock);
}
However, I have b...
Idioblast asked 3/4, 2014 at 10:38
2
Solved
I am trying to understand the basic multithreading mechanisms in the new C++ 11 standard. The most basic example I can think of is the following:
A producer and a consumer are implemented in sepa...
Joyner asked 13/2, 2014 at 14:33
2
When implementing condition variables into a Win32 C++ program, would it be better to use Win32 functions, classes, and data types (e.g. CreateThread, SleepConditionVariableCS, WaitForSingleObjectE...
Eba asked 27/1, 2014 at 16:8
2
Solved
So I just found out that it's legal to signal a condition variable if you're not holding the lock in c++11. That seems to open the door to some nasty race condition:
std::mutex m_mutex;
std::condi...
Pompei asked 29/1, 2014 at 18:20
2
Solved
I have thread1 which is waiting on a condition from thread2. But it could be that thread2 is never signalling the condition variable. So I have added a timeout to the wait call in thread 1, like th...
Karaite asked 9/7, 2012 at 8:47
3
Solved
I need to some little help to understand how to use condition variables in C to resolve an exercise. Here is a little example:
#include <stdio.h>
#include <stdlib.h>
#include <unist...
Grandeur asked 2/12, 2013 at 9:46
2
Solved
Suppose I have two threads and one shared c++ 11 condition variable.
What whould happen if thread1 call notify and after that thread2 call wait?
Will thread2 block forever or it will continue it's ...
Portraitist asked 2/10, 2013 at 16:49
2
I can't get code working reliably in a simple VS2012 console application consisting of a producer and consumer that uses a C++11 condition variable. I am aiming at producing a small reliable progra...
Kelila asked 13/12, 2012 at 18:26
1
Solved
I'm trying to use a C++11 std::condition_variable, but when I try to lock the unique_lock associated with it from a second thread I get an exception "Resource deadlock avoided". The thread that cre...
Acred asked 24/7, 2013 at 16:47
2
I have a situation where a notify() 'can' be called before a wait().
I am trying to make a simulator to schedule its next event when I 'notify' him by sending him messages. So I have devised a wa...
Youmans asked 10/7, 2013 at 5:18
2
Solved
I try to develop a threadpool in C++ and I wonder if it is better to yield() the thread in the main loop of the worker thread or to wait on a condition variable:
void worker_thread( void )
{
// t...
Hillside asked 12/7, 2013 at 11:16
4
Solved
I am currently working on a problem that simulates a extended Producer-Worker model. In this problem there are 3 workers and 3 tools available, and for workers to work they need 2 tools (and materi...
Viviyan asked 2/7, 2013 at 7:29
2
I'm stuck on a problem when trying to awake a thread by another one. A simple producer / consumer thing.
Below the code. Line 85 is the point I don't understand why it's not working. The producer ...
Karyokinesis asked 17/5, 2013 at 16:4
1
Solved
I would like to have to possibility to make thread (consumer) express interest in when another thread (producer) makes something. But not all the time.
Basically I want to make a one-shot consum...
Pursy asked 16/4, 2013 at 10:47
2
Solved
Do I need to synchronize std::condition_variable/condition_variable_any::notify_one?
As far as I can see, if lost of notifications is acceptable - it is OK to call notify_one not protected (by mut...
Hospice asked 8/4, 2013 at 19:30
1
Solved
How many waiting threads will wake up in this example:
1st thread:
void wakeUp2Threads()
{
std::unique_lock<std::mutex> lock(condvar_mutex);
condvar.notify_one();
condvar.notify_one();
...
Sculley asked 26/2, 2013 at 9:45
2
How many waiting threads will wake up if I call std::condition_variable::notify_one() twice without any time interval, like this:
{
std::unique_lock<std::mutex> lock(condvar_mutex);
...
Jorgan asked 26/2, 2013 at 8:1
2
A while back I was thinking about how to implement various synchronization primitives in terms of one another. For example, in pthreads you get mutexes and condition variables, and from these can b...
Brevier asked 19/3, 2011 at 20:28
3
Solved
I am using a SynchronisedQueue to communicate between threads. I found that destroying the thread object when the attaching thread is waiting on a condition variable would cause the program crash. ...
Byrne asked 21/12, 2012 at 3:45
2
Solved
I'm having some trouble understanding condition variables and their use with mutexes, I hope the community can help me with. Please note, I come from a win32 background, so I'm used with CRITICAL_S...
Marilou asked 14/11, 2012 at 0:3
1
Solved
I haven't wrapped my head around the C++11 multithreading stuff yet, but I'm trying to have multiple threads wait until some event on the main thread and then all continue at once (processing what ...
Monika asked 11/7, 2012 at 23:11
3
Solved
I read somewhere that we should lock the mutex before calling pthread_cond_signal and unlock the mutex after calling it:
The pthread_cond_signal() routine is
used to signal (or wake up) another
th...
Leatherback asked 28/12, 2010 at 6:52
2
Solved
From the Wikipedia article on Polling
Polling, or polled operation, in computer science, refers to actively sampling the status of an external device by a client program as a synchronous activity....
Grumous asked 15/5, 2012 at 5:7
1
Solved
Currently, I am implementing a multi-thread project using std::thread in C++11. I use std::condition_variable to synchronize threads. In detail, one consumer function calls wait() member function o...
Selfsupporting asked 26/1, 2012 at 8:58
© 2022 - 2024 — McMap. All rights reserved.