-
October 7th, 2013, 11:00 AM
#1
How to know if a VS2008 project supports multithread or not?
Hi,
I get a VC2008 project with full source. How to know whether it supports multithread or not? I think as long as the “Runtime Library” under “C/C++” - “Code generation” category is set to “Multi-threaded”, then the project should be thread-safe, is that correct? Or are there any other project settings need to be checked?
Thanks
Alan
-
October 7th, 2013, 11:10 AM
#2
Re: How to know if a VS2008 project supports multithread or not?
“Multi-threaded” category does NOT mean that "the project should be thread-safe", but only it "supports multithread".
It is up to project developer to do a project to be "thread-safe" or not.
Victor Nijegorodov
-
October 8th, 2013, 01:34 AM
#3
Re: How to know if a VS2008 project supports multithread or not?
Originally Posted by AlanCCC
I think as long as the “Runtime Library” under “C/C++” - “Code generation” category is set to “Multi-threaded”, then the project should be thread-safe, is that correct? Or are there any other project settings need to be checked?
This runtime setting is exactly what it says: C Runtime multithreading.
And there is no setting that would turn on or off multithreading for entire project, as any Windows process natively supports multithreading. You can create a multithreaded program even when linking to single threaded runtime, you just have to be careful enough to not use runtime objects across threads bounds.
And to the point of being thread safe, I agree with Victor, it's strictly up to programmer to make it be that, as C/C++ knows nothing about threads.
Best regards,
Igor
-
October 8th, 2013, 04:41 AM
#4
Re: How to know if a VS2008 project supports multithread or not?
Certain functions (eg _beginthreadex) are only declared in the header file if the code generation is set to 'Multi-threaded'.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
October 8th, 2013, 07:06 AM
#5
Re: How to know if a VS2008 project supports multithread or not?
popping a few myth bubbles here...
_EVERY_ program you write for windows inherently supports multithreading. All it takes is create the extra threads either through the windows API functions, the runtime lib or some other library that allows you to do so.
Even if you don't make any extra threads in your own code. The OS dll's itself, drivers, hooks etc can all create additional threads.
So your answer is sort of a bogus one, it is literally impossible (other than hacking deep into the OS kernel) to create an application on windows that will guarantee that at no time during it's runtime no additional threads can ever be created.
Even if you compile your program as non-MT. You can still create threads and do so safely, one restriction is going to be that the thread cannot use (some of) the runtime library functions.
Regardless, you're always subject to whatever libs you are using and to what degree those libraries support being called from multiple threads at the same time.
Most of the windows API is fully MT enabled (part of it isn't), but that doesn't mean you can safely access a single resource simultaneously.
Any time you access a single resource/memory/object/handle/something from 2 threads at the same time, you're Always going to need to ask the question if doing so is thread safe.
-
October 8th, 2013, 03:14 PM
#6
Re: How to know if a VS2008 project supports multithread or not?
Originally Posted by OReubens
So your answer is sort of a bogus one.
Which answer is bogus?
-
October 9th, 2013, 06:39 AM
#7
Re: How to know if a VS2008 project supports multithread or not?
Typo: I meant a bogus/meaningless QUESTION.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|