Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
83 views

I'm a bit confused with an example of std::conditional_variable. I have several waiting threads, and would like to use notify_all() to wake up all of them at the same time. I have modified code from ...
buggi zhuk's user avatar
2 votes
2 answers
173 views

So I have this lab problem where I need to use 2 threads with mutex and cond var to print the title pattern. The pattern is stored in an array of char, and there's a global keeping track of which ...
Sliferslacker's user avatar
-3 votes
1 answer
115 views

I'm using unique_locks and normal lock to lead the threads. I try to interlink the threads, so they don't loose too many cycles and work together and not separately. I don't know, if my code can ...
user avatar
0 votes
0 answers
131 views

For some reason, my project is always crashing when I call std::condition_variable::wait_for(). Unfortunately, this project's crash handler goes out of its way to be as unhelpful as possible, but it ...
Opux's user avatar
  • 806
0 votes
2 answers
141 views

This is in continuation to this really nice one: https://stackoverflow.com/a/33500554/22598822. That post was for the sequence (t1 & t2) --> t3. Let's say I have a program running, and there ...
barak's user avatar
  • 25
2 votes
0 answers
86 views

Beginner level synchronization question here. There’s a lot of material on how to implement producer-consumer synchronization. I really did try all variations that I thought made sense, but none seems ...
barak's user avatar
  • 25
0 votes
0 answers
32 views

I use an ConcurrentQueue in my project.But sometimes I meet crash caused by this ConcurrentQueue.I do not have any idea about this crash so I want to get some help.This code show my ConcurrentQueue #...
user24542906's user avatar
0 votes
1 answer
58 views

Below programs works fine. But My doubt is very beginning both threads (printEven and printOdd) is waiting for signal on conditional variable( statement pthread_cond_wait(&cond, &mutex);) then ...
sagul kumar's user avatar
1 vote
0 answers
63 views

I've got a very time critical simulator that is supposed to run as fast as humanly possible. I tried to increase the data throughput by distributing every data frame to multiple worker threads. To ...
itzFlubby's user avatar
  • 2,287
6 votes
1 answer
695 views

I'm testing edge cases with std::condition_variable and I tested scenario to starve one thread. Scenario is that there are 99 producers and only one consumer, all of them working on 1 queue with max ...
Piwniczne's user avatar
3 votes
1 answer
403 views

I compiled and linked this simple program using g++ in a Raspberry Pi 4 running on the ARMv8-A. compiler: g++ -Wall -O0 -g3 -std=c++11 -c Main.cpp linker: g++ -static -o "bugTest.elf" ./Main....
alien's user avatar
  • 89
0 votes
1 answer
114 views

Consider this case (which is the standard usage in cppreferences): std::atomic<bool> condition(false); thread 1: lock // check condition the last time before waiting if (condition == true) { ...
searchstar's user avatar
4 votes
2 answers
787 views

I read unusual case in documentation sync.Cond: Because c.L is not locked while Wait is waiting, the caller typically cannot assume that the condition is true when Wait returns. Instead, the caller ...
QuickDzen's user avatar
  • 281
0 votes
1 answer
75 views

I have two goroutines which are two TestXxx functions during the testing. I use a conditional variable to synchronize these goroutines. However, once one of them fails the test while the other one is ...
WeiAnHsieh's user avatar
0 votes
3 answers
570 views

I am currently learning multi-threading in C++. I have a question about the conditional variable. If I have such code: std::condition_variable cvS; std::condition_variable cvR; std::condition_variable ...
Kevin eyeson's user avatar
0 votes
1 answer
103 views

Just making a simple example because I am having issues with a more complex usecase and want to udnerstand the base case before spending too much time in trial and error. Scenario: I have two binaries ...
Serj's user avatar
  • 61
-1 votes
1 answer
2k views

I am learning C++ threads and i don't understand unique_lock mechanism very well. I reed This Link with Conditional variable, and more examples here but still I have my confusions: 1- So my question ...
Azzurro94's user avatar
  • 499
1 vote
0 answers
829 views

I'm dealing with an "apparently" simple problem with enums in Python that i cannot figure out how to solve. I just need to load different values for an enum in different environments (dev ...
Maurício Silva's user avatar
-1 votes
2 answers
117 views

Assum have two thread that one of them has more priority and they are running on same core (single core), I only want work just one thread at same time.(maybe you say that is not threading paradigm , ...
user avatar
0 votes
1 answer
130 views

I want two Makefile targets which both create the same targetfile but with some bonus files added to the normal files in the bonus rule (all files inside the final .a though). Which in itself is ...
ludmuterol's user avatar
0 votes
1 answer
538 views

I've read from https://en.cppreference.com/w/cpp/thread/condition_variable/wait that wait() "Atomically unlocks lock". How do I see this via std::cout? I am trying to understand conditional ...
davidj361's user avatar
  • 191
2 votes
3 answers
120 views

So I am trying to understand pthread_cond_t variables, but the problem is often sometimes pthread_cond_signal()/pthread_cond_broadcast() doesn't work and the sleeping threads are not woken up, leading ...
Cardinal's user avatar
2 votes
1 answer
845 views

I am having a trouble exiting a thread using a Restart function. When calling Stop it exits the thread, but Restart which calls Stop and then Start right after - doesn't exit the thread -> calls ...
rozfet's user avatar
  • 23
0 votes
0 answers
69 views

I am having a trouble exiting a thread using a Restart function. When calling Stop it exits the thread, but Restart which calls Stop and then Start right after - doesn't exit the thread -> calls ...
poorharambe1's user avatar
0 votes
1 answer
106 views

Below is the current code that I am working with. When I comment out the code to run the progress_bar function, code works perfectly as expected with the mandelbrot printed out into a seperate image ...
Kitso's user avatar
  • 51
0 votes
0 answers
43 views

I'm using the mutex and condition_variable pair to implement mult-threaded processing. I have read examples and solid explanations like this and that. However, I do not understand why separate ...
Jason M's user avatar
  • 421
0 votes
1 answer
107 views

What I'm Trying To Do Hi, I have two types of threads the main one and the workers where the workers are equal to the number of cores on the CPU, what I'm trying to do is when the main thread needs to ...
Pedro S's user avatar
0 votes
1 answer
50 views

I have four binary yes/no variables. I want to create a combined variable that is dummy coded in the following manner: 0 if participants say "Yes" to all 4 Variables (4/4) 1 if participants ...
Heshani's user avatar
  • 13
6 votes
1 answer
1k views

https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html use std::sync::{Arc, Mutex, Condvar}; use std::thread; let pair = Arc::new((Mutex::new(false), Condvar::new())); let pair2 = Arc::clone(&...
Wynell's user avatar
  • 825
0 votes
1 answer
831 views

So I want to wait until ender has started waiting here is what basically: std::condition_variable avalanche; std::mutex mutex; std::cout << "avalanche" << ...
AnArrayOfFunctions's user avatar
7 votes
4 answers
16k views

I wrote a wrote a program and it doesn't work as I expect it to. I have two threads: thread triggers func and anotherThread triggers anotherFunc. What I wanted to do is when cont reaches value 10 in ...
Jacob Krieg's user avatar
  • 3,292