multi-threaded application in C++
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 4 1234 LastLast
Results 1 to 15 of 50

Thread: multi-threaded application in C++

  1. #1
    Join Date
    Dec 2003
    Posts
    47

    multi-threaded application in C++

    hi all:
    can anyone supply me the links on multi-threaded application tutorials in C++/C or just any tutorials on Threads in C++/C
    ------------
    I.B.M... I Blame Microsoft

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Well...did you try to e.g. google for it? There should be more than enough links to choose from...
    Ciao, Andreas

    "Software is like sex, it's better when it's free." - Linus Torvalds


    Article(s): Allocators (STL) Function Objects (STL)

  3. #3
    Join Date
    Feb 2002
    Posts
    5,758
    Multithreading is OS dependent. In other words, the syntax is different for Windows, Linux, Solaris, etc.

    What do you want to know?

    Kuphryn

  4. #4
    Join Date
    Sep 2002
    Location
    Belarus - Tirol, Austria
    Posts
    647
    Originally posted by kuphryn
    Multithreading is OS dependent. In other words, the syntax is different for Windows, Linux, Solaris, etc.

    What do you want to know?

    Kuphryn
    Yes. Internally they have different
    implementations for threads. Nevertheless, Linux and Solaris have the same POSIX-compliant thread api - pthread_*. U can use pthread interface for windoze applications, because it has POSIX subsystem (well, it's based on the old posix specification, though). So U can use pthread api for all these systems.
    "UNIX is simple; it just takes a genius to understand its simplicity!"

  5. #5
    Join Date
    Feb 2002
    Posts
    5,758
    Okay.

    Kuphryn

  6. #6
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    First, if you can get the book:

    ISBN: 0471180122
    Title: Object-oriented multithreading using C++
    Author: Hughes, Tracey
    Publisher: J. Wiley

    Then that is supposedly platform-independent (see ACCU Reviews: Object-Oriented Multithreading Using C++).

    I don't know what the CodeGuru articles have but it is nearly certain there is useful stuff there.

    Otherwise you can look through the links I have gathered into my Other C++ Sites and Other Windows Sites pages; you can probably find some tutorials and such but it might take a couple of hours.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  7. #7
    Join Date
    Nov 2003
    Posts
    1,405
    I asked the same some time ago,

    http://www.codeguru.com/forum/showth...multithreading

    You need to use the thread-safe versions of all libraries you link to your program.

    If you want portable multithreading you can use the Boost libraries. WxWindows (a portable GUI toolkit) also has portable threading primitives.

  8. #8
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    Multithreading exists in C and I think there is a possibility that it will be added to C++. As far as I know, the Boost library version is a possible implementation of the future standard.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  9. #9
    Join Date
    Nov 2003
    Location
    Vienna, Austria
    Posts
    212
    That's the goal of many boost libraries, to make it into future versions of the standard.


    I've never heard of Windows implementing pthreads, it certainly isn't in the documentation.


    But there are several other cross-platform libraries providing multithreading: the Netscape Portable Runtime (base for Mozilla) and the Apache Portable Runtime (base for Apache2 web server).
    http://www.mozilla.org/
    http://www.apache.org/
    All the buzzt
    CornedBee

  10. #10
    Join Date
    Nov 2003
    Posts
    1,405
    Originally posted by CornedBee
    But there are several other cross-platform libraries providing multithreading: the Netscape Portable Runtime (base for Mozilla) and the Apache Portable Runtime (base for Apache2 web server).
    Aren't those just examples of thread-safe libraries which use threading internally? They don't assist you in making your own general threading application, instead they provide functionality for specific application domains.

  11. #11
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    1,557
    Thanks for an interesting post.

    Unfortunately, the Microsoft compilers do not have support for posix.

    GNU offers a common envrionment for threads and sockets. It is called Common-C++. I used it once. As with most GNU packages, it is very rich and complete, resulting in a large and cumbersome package. It might be over-dimensioned for your application. I do not have a lot of experience with Common-C++ since it was always best for my developments to write smaller custom solutions.

    Nevertheless, you might want to take a look.

    http://www.gnu.org/software/commoncpp/

    Sincerely, Chris.

    You're gonna go blind staring into that box all day.

  12. #12
    Join Date
    Sep 2002
    Location
    Belarus - Tirol, Austria
    Posts
    647
    Originally posted by dude_1967

    Unfortunately, the Microsoft compilers do not have support for posix.
    I donot understand from your point of view why some compiler should support POSIX. The OS should has such a support. There are no any explicit reasons for the compiler to do that. Even M$ Winodoze supports (oh at least I know that's true for NT) one of the first POSIX standards.
    The OS may give such a support, providing a set of libraries. What concerns to posix threads, Linux has a library called pthread, FreeBSD includes these functions in the libc_r library. All U need to do is to re-compile your program, linking it with a library specified for the current OS.
    So I wonder why people want to get such kind of support from the compiler, because one thing it should provide for that (and that's enough) is the ability of linking with the external library.
    "UNIX is simple; it just takes a genius to understand its simplicity!"

  13. #13
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    1,557
    dimm_coder,

    This is a very rich topic which brings a lot of valid opinions to light, since multithreading is often viewed as a programming incarnation which is OS-dependent. On the one hand, a lot of developers could benefit from a common environment for multithreading which is compiler-independent. On the other hand, mandating compiler support for multithreading idioms requires the implementation of programming elements which are very near if not identical with operating system elements.

    It would be hard to draw the line between OS and compiler---nearly impossible for smaller microcontroller architectures for which there is no typical underlying OS.

    Posix is already specified. This is why I find the support of Posix to be a good thing on large, well established compilers for platforms such as Unix.

    Sincerely, Chris.

    You're gonna go blind staring into that box all day.

  14. #14
    Join Date
    Nov 2003
    Location
    Vienna, Austria
    Posts
    212
    If I'm not mistaken, POSIX is a standard interface an OS should provide, not a compiler.
    All the buzzt
    CornedBee

  15. #15
    Join Date
    Nov 2003
    Posts
    1,405
    Originally posted by dimm_coder
    So I wonder why people want to get such kind of support from the compiler, because one thing it should provide for that (and that's enough) is the ability of linking with the external library.
    The ability to link external libraries is NOT enougth. The libraries that come with the compiler must be guaranteed threadsafe, otherwise there's no way a program can become multithreading no matter what other stuff you link to it. But today I'd say all major compilers have threadsafe vesions of their standard libraries. The important thing is to make sure you use them.

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center