Linked Questions

-2 votes
1 answer
182 views

I have a class that has its own worker thread, and some of the member variables of the class is shared between the main thread and the worker. How can I use a mutex to lock only the member variables ...
xcorat's user avatar
  • 1,492
1020 votes
37 answers
701k views

Is there any difference between a binary semaphore and mutex or are they essentially the same?
Nitin's user avatar
  • 15.6k
1033 votes
10 answers
534k views

A mutex is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a mutex and how do you use it?
bmurphy1976's user avatar
  • 31.6k
164 votes
13 answers
158k views

When should we use mutex and when should we use semaphore ?
Karthik Balaguru's user avatar
58 votes
6 answers
56k views

I have a class that has a state (a simple enum) and that is accessed from two threads. For changing state I use a mutex (boost::mutex). Is it safe to check the state (e.g. compare state_ == ...
user avatar
45 votes
2 answers
29k views

I'm going to use boost::mutex from boost/thread/mutex.hpp. There are several ways to lock/unlock mutex: with scoped_lock, unique_lock, lock_guard, mutex's member functions ::lock() and ::unlock() and ...
Max's user avatar
  • 4,962
4 votes
8 answers
9k views

I have seen tutorials on the internet for making multithreaded applications in C++ on Windows, and other tutorials for doing the same on Linux, but not for both at the same time. Are there functions ...
Langley's user avatar
  • 75
7 votes
4 answers
14k views

I read a few documents about Mutex and still the only Idea I have got is that it helps preventing threads from accessing a resource that is already being used by another resource. I got from Code ...
Simsons's user avatar
  • 12.8k
5 votes
5 answers
3k views

Do I need a mutex if I have only one reader and one writer? The reader takes the next command (food.front()) from the queue and executes a task based on the command. After the command is executed, it ...
user avatar
2 votes
2 answers
3k views

What is the correct use of a Mutex? How do I know what it is protecting? Does it stop all threads from running for the locked period? For example I have a singleton that contains a list of objects. ...
marsh's user avatar
  • 2,750
2 votes
6 answers
3k views

My app consist of the main-process and two threads, all running concurrently and making use of three fifo-queues: The fifo-q's are Qmain, Q1 and Q2. Internally the queues each use a counter that is ...
slashmais's user avatar
  • 7,185
3 votes
2 answers
2k views

Here I use Peterson's algorithm to implement mutual exclusion. I have two very simple threads, one to increase a counter by 1, another to reduce it by 1. const int PRODUCER = 0,CONSUMER =1; int ...
Lixin Wei's user avatar
  • 553
1 vote
4 answers
3k views

In the title is pretty clear, I just need to know if there's a way to Sleep for some miliseconds and then call a function without stopping the GUI. The way that I do now is just adding Sleep(3000); ...
Grego's user avatar
  • 2,260
1 vote
2 answers
1k views

Code: #include <iostream> #include "stdafx.h" #include <boost/thread.hpp> #include <boost/thread/mutex.hpp> using namespace std; boost::mutex mut; double results[10]; void doubler(...
Flamewires's user avatar
0 votes
2 answers
1k views

Fairly unknowledgable linux (ubuntu 14.04) user here. I'm trying to install a bioinformatics program called Bowtie2 - I get this error and not sure where it's coming from. They did quote this on their ...
user438383's user avatar
  • 6,307

15 30 50 per page