Hi,
I have been coding in Windows for many years so have a mindset to it,
so forgive any stupid questions.
Is it possible to create a multithread application in C++ that is
portable (OS/compiler)? In my Windows applications, I use
synchronization objects like, mutex, semaphores etc. Is there anything
similar in the Standard ANSI C++ or would I be best off doing this
myself, possibly creating a new class to handle any critical sections
and memory sharing etc.
Any articles on this subject are welcome as well.
Thanks. 22 4067
Morpheus wrote:
Hi,
I have been coding in Windows for many years so have a mindset to it,
so forgive any stupid questions.
Is it possible to create a multithread application in C++ that is
portable (OS/compiler)? In my Windows applications, I use
synchronization objects like, mutex, semaphores etc. Is there anything
similar in the Standard ANSI C++ or would I be best off doing this
myself, possibly creating a new class to handle any critical sections
and memory sharing etc.
Any articles on this subject are welcome as well.
There is no support for threads or the kind of synchronisation objects
you mention in standard C++. However, before you write everything you
need from scratch, you might want to have a look at the threads library
in boost. http://www.boost.org/doc/html/threads.html
See if it does what you want and if it is portable to the platforms you
care about.
Gavin Deane
Morpheus wrote:
Is it possible to create a multithread application in C++ that is
portable (OS/compiler)? In my Windows applications, I use
synchronization objects like, mutex, semaphores etc. Is there anything
similar in the Standard ANSI C++ or would I be best off doing this
myself, possibly creating a new class to handle any critical sections
and memory sharing etc.
Any articles on this subject are welcome as well.
Check out this article on Boost.Threads: http://www.ddj.com/dept/cpp/184401518
And you might be interested in this article on the future of threads in
standard C++: http://www.artima.com/cppsource/threads_meeting.html
Cheers! --M
"Morpheus" <ad***********@ gmail.comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Hi,
I have been coding in Windows for many years so have a mindset to it,
so forgive any stupid questions.
Is it possible to create a multithread application in C++ that is
portable (OS/compiler)? In my Windows applications, I use
synchronization objects like, mutex, semaphores etc. Is there anything
similar in the Standard ANSI C++ or would I be best off doing this
myself, possibly creating a new class to handle any critical sections
and memory sharing etc.
Any articles on this subject are welcome as well.
Here are some link to some relevant information: http://groups.google.com/group/comp....d30a778b43f2c5 http://groups.google.com/group/comp....f096adecdd0369
(refer to last part of the post...) http://groups-beta.google.com/group/...3df394a0370fa6
FWIW, I raise this issue in a very rough draft of a paper I am currently
working on. Here is a link to the crude draft: http://appcore.home.comcast.net/vzdo...c/static-init/
Its incomplete, however, what's there should be of interest to you...
Any thoughts?
"Gavin Deane" <de*********@ho tmail.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
Morpheus wrote:
>Hi,
I have been coding in Windows for many years so have a mindset to it, so forgive any stupid questions.
Is it possible to create a multithread application in C++ that is portable (OS/compiler)? In my Windows applications, I use synchronizatio n objects like, mutex, semaphores etc. Is there anything similar in the Standard ANSI C++ or would I be best off doing this myself, possibly creating a new class to handle any critical sections and memory sharing etc.
Any articles on this subject are welcome as well.
There is no support for threads or the kind of synchronisation objects
you mention in standard C++. However, before you write everything you
need from scratch, you might want to have a look at the threads library
in boost.
http://www.boost.org/doc/html/threads.html
See if it does what you want and if it is portable to the platforms you
care about.
Right. You can also get a commercial version of boost threads, already
ported to several major platforms, from us. But you might want to
check out Boost first. We also have documentation in the on-line manual
at our web site, for a quick overview.
P.J. Plauger
Dinkumware, Ltd. http://www.dinkumware.com
Pete Becker wrote:
Morpheus wrote:
>> Is it possible to create a multithread application in C++ that is portable (OS/compiler)? In my Windows applications, I use synchronizatio n objects like, mutex, semaphores etc. Is there anything similar in the Standard ANSI C++ or would I be best off doing this myself, possibly creating a new class to handle any critical sections and memory sharing etc.
Any articles on this subject are welcome as well.
Thread-related proposals under discussion for the next C++ standard:
Concurrency memory model http://www.open-std.org/jtc1/sc22/wg...2006/n2052.htm
Thread-local storage http://www.open-std.org/jtc1/sc22/wg...006/n1966.html
Atomic operations http://www.open-std.org/jtc1/sc22/wg...006/n2047.html
Thread support http://www.open-std.org/jtc1/sc22/wg...005/n1907.html http://www.open-std.org/jtc1/sc22/wg...006/n2090.html
Since it's for the most part language adoption of Posix thread apis which
where established in the 90's, shouldn't it be called C++9x instead of
C++0x?
Seriously, the hardware is advancing at a faster rate than software
support for threading. This stuff won't scale for 100+ core processors.
This doesn't even begin to address the issues faced by techniques being
developed now. This is just language support for the last war so to
speak.
--
Joe Seigh
When you get lemons, you make lemonade.
When you get hardware, you make software.
Joe Seigh wrote:
>
Seriously, the hardware is advancing at a faster rate than software
support for threading. This stuff won't scale for 100+ core processors.
This doesn't even begin to address the issues faced by techniques being
developed now. This is just language support for the last war so to
speak.
I don't know how to write code that will scale to 100+ core processors,
much less what standard language support for it ought to look like. But
from the three-day special meeting we had in Redmond last month, which
included representatives from several hardware manufacturers as well as
people with far more experience writing multi-threaded code than I have,
I don't think anyone else does, either.
You're right that the papers pretty much stick to what's in existence
today. That's what language standards ought to do: standardize existing
practice. But note also that those papers are aimed at the next revision
of the C++ standard, which is pretty much feature-frozen now. There's
more going on, but it's targeted farther out in the future, and is still
somewhat speculative.
--
-- Pete
Roundhouse Consulting, Ltd. -- www.versatilecoding.com
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." For more information about this book, see www.petebecker.com/tr1book.
Pete Becker wrote:
Joe Seigh wrote:
You're right that the papers pretty much stick to what's in existence
today. That's what language standards ought to do: standardize existing
practice. But note also that those papers are aimed at the next revision
of the C++ standard, which is pretty much feature-frozen now. There's
more going on, but it's targeted farther out in the future, and is still
somewhat speculative.
I'm a little concerned since there doesn't seem to be any awareness of
some of the issues I've been running into. Being on the bleeding
edge isn't any fun when they move that edge out from under you and
you do a Wiley Coyote. I've had that happen to me in Java when they
revised the JVM specs and broke something I did that was legal in
Java 1.x. Fortunately I wasn't really using it but nevertheless.
--
Joe Seigh
When you get lemons, you make lemonade.
When you get hardware, you make software.
Joe Seigh wrote:
Pete Becker wrote:
Joe Seigh wrote:
You're right that the papers pretty much stick to what's in existence
today. That's what language standards ought to do: standardize existing
practice. But note also that those papers are aimed at the next revision
of the C++ standard, which is pretty much feature-frozen now. There's
more going on, but it's targeted farther out in the future, and is still
somewhat speculative.
I'm a little concerned since there doesn't seem to be any awareness of
some of the issues I've been running into. Being on the bleeding
edge isn't any fun when they move that edge out from under you and
you do a Wiley Coyote.
That's the price of living on the bleeding edge. The stuff the standard
is concerned with is, as Pete said (cf. also the article I mentioned
elsethread), not on the bleeding edge precisely because the edge
changes so rapidly. Only common practice should be standardized, not
any of the myriad possible future practices.
Cheers! --M This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: MarionEll |
last post by:
XML 2003 Interoperability Demonstrations to Showcase
Industry Standards, Integrated Vendor Solutions
Alexandria, VA – Nov. 19, 2003 – IDEAlliance, a leading trade association
dedicated to fostering information technology standards, today announced that
XML Conference and Exposition 2003 will feature several “interoperability...
|
by: Isaac Grover |
last post by:
Hi everyone,
Just out of curiosity I recently pointed one of my hand-typed pages at the W3
Validator, and my hand-typed code was just ripped to shreds. Then I pointed
some major sites (microsoft.com, cnn.com, etc.) at the W3 Validator; to my
surprise none of them passed.
Doesn't anyone care anymore, or are the standards more-or-less...
|
by: John Doe |
last post by:
Hi all,
I know the standard doesn't care about threads (wrongly :-)
But in current compilers implementation, is the "list" which holds count
of the occupied and free heap addresses SHARED among various threads or not?
I don't know if I was clear:
Case1: the list which holds count of what is free and what is occupied
is SHARED among all...
|
by: John Doe |
last post by:
I have a webpage which shows and hides divs as a method of
navigation. It works great in the ever evil IE. It works not so
great (read not at all) in any standards compliant browser. I
haven't ever bothered with standards compliance type stuff before,
but am slowly converting. For now I just want to get things working
on standards compliant...
|
by: Sugapablo |
last post by:
Just out of curiosity, while checking on a site I was working on, I
decided to throw a couple of the web's most popular URLs into the W3C
Markup Validator.
Out of microsoft.com, google.com, amazon.com, yahoo.com, aol.com, and
mozilla.org, only Mozilla's site came back "Valid HTML".
So if all these places, with their teams of web...
| |
by: Natt Serrasalmus |
last post by:
After years of operating without any coding standards whatsoever, the
company that I recently started working for has decided that it might be a
good idea to have some. I'm involved in this initiative.
Typically I find that coding standards are written by some guy in the
company who has a way of coding that he likes and then tries to force...
|
by: Michael Moreno |
last post by:
Hello,
I have a C# server which has 4 worker threads running all the time.
When I let the server runs for several hours, for some reasons the CPU
usage of the application will shoot to 100% and remain there.
I would like to find out which thread(s) is/are the source of the
problem.
Would you have any idea on how to tackle the problem...
|
by: auratius |
last post by:
http://www.auratius.co.za/CSharpCodingStandards.html
Complete CSharp Coding Standards
1. Naming Conventions and Styles
2. Coding Practices
3. Project Settings and Project Structure
4. Framework-Specific Guidelines
Naming Conventions and Styles
|
by: climber.cui |
last post by:
Hi all,
Does anyone have experience on the thread-safty issue with malloc()?
Some people said this function provided in stdlib.h is not thread-
safe, but someone said it is thread safe. Is it possible this
function evolves from thread-unsafe to thread-safe in recent years?
How could i find out?
I am using the C library coming with GNU linux...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |