0

I need to make a program run just one copy of it using Mutex.
But I coudn't find anything on using Mutex in c++.

5
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by rubberman
0

What system and compiler are you using? On Linux/Unix, there is a man page that gives details. Also, are you using pthreads (POSIX threads), or other threading API's?

0

Threading facilities can be found under Boost.Thread. These are essentially the libraries that will form the basis for the upcoming threading standard libraries in C++0x, so better get used to those functions/classes for now, until the standard ones come out. And they are cross-platform, so it doesn't matter much whether you are using Windows or Linux (except that performance of certain things are different from platform to platform because they have different kernel implementations).

You will find examples, on the link, on how to use mutexes.

0

What system and compiler are you using? On Linux/Unix, there is a man page that gives details. Also, are you using pthreads (POSIX threads), or other threading API's?

Well..I'm on Windows and use Visual Studio 08.
I've tried #include <pthreads> but it didn't work at all.

I've just started studing Win Api so I need a bit guidance here.

0

C++ did not added any multi-thread support in their language, instead of other languages like Java (which is far younger than C/C++ and has been in the beginning of the multi-thread era).

C++0x, the next revision of C++, will add thread support as a standard, so every compiler that will respect the new standard will support multi-threading.

This site provides a implementation of the upcoming multi-thread support in C++0x. It is not free (unfortunately), but it illustrates my point: http://www.stdthread.co.uk/

0

Windows does not support POSIX threads (pthreads), if I correctly remember my multi-thread assignments at the unversity.

0

Windows does not support POSIX threads (pthreads), if I correctly remember my multi-thread assignments at the unversity.

The "standard" Windows API's don't support POSIX threads and most other POSIX API's, but they are available for VC++, and I have used them extensively in the past for cross-platform development. Unfortunately, the biggest problem is that VC++ is not particularly standards compliant. For ANSI/ISO C++ standards compliance, the GNU compiler suite is still amongst the best. There are proprietary compilers from Intel and others that are as good, or possibly better, but they are quite costly and don't run on all available platforms, unlike GNU.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.