Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #19094 > unrolled thread
| Started by | markspace <-@.> |
|---|---|
| First post | 2012-10-19 11:11 -0700 |
| Last post | 2012-10-20 09:14 -0700 |
| Articles | 8 — 6 participants |
Back to article view | Back to comp.lang.c++
Threading tutorial for C++? markspace <-@.> - 2012-10-19 11:11 -0700
Re: Threading tutorial for C++? Öö Tiib <ootiib@hot.ee> - 2012-10-19 11:55 -0700
Re: Threading tutorial for C++? Robert Wessel <robertwessel2@yahoo.com> - 2012-10-19 14:03 -0500
Re: Threading tutorial for C++? markspace <-@.> - 2012-10-20 09:17 -0700
Re: Threading tutorial for C++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-10-20 07:31 +0000
Re: Threading tutorial for C++? ptyxs <kerloch@gmail.com> - 2012-10-20 15:05 +0200
Re: Threading tutorial for C++? Luca Risolia <luca.risolia@studio.unibo.it> - 2012-10-20 15:20 +0200
Re: Threading tutorial for C++? markspace <-@.> - 2012-10-20 09:14 -0700
| From | markspace <-@.> |
|---|---|
| Date | 2012-10-19 11:11 -0700 |
| Subject | Threading tutorial for C++? |
| Message-ID | <k5s53p$15v$1@dont-email.me> |
Hey all, I've got a little personal project to learn a bit about multithreading in C++, and I was wondering if anyone would like to give me a few pointers (no pun intended). What would you recommend as a good tutorial? Threading seems to be a bit in flux, still, since standards have been long in coming (no flames please) and so I was wondering from a practical standpoint what you'd recommend. Let's assume a Unix/Linux environment. I'll tackle Windows later. I have a recommendation for a Boost tutorial, although the article is really old. <http://www.drdobbs.com/cpp/the-boostthreads-library/184401518> There's of course a lot of old pthreads tutorials. I wonder if pthreads has been obviated by now, however. <http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html> <http://codebase.eu/tutorial/posix-threads-c/> So I'm also wondering how prevalent c++11 is, in your practical opinion. <http://solarianprogrammer.com/2011/12/16/cpp-11-thread-tutorial/> What should I tackle first? Some articles I researched seem to say multithreading can't truly (i.e., correctly) be implemented in a library. So is pthreads really relevant any more? <http://www.hpl.hp.com/personal/Hans_Boehm/c++mm/> <http://www.hpl.hp.com/techreports/2004/HPL-2004-209.html> Note especially the second link there. So where should a newb start? Suggestions?
[toc] | [next] | [standalone]
| From | Öö Tiib <ootiib@hot.ee> |
|---|---|
| Date | 2012-10-19 11:55 -0700 |
| Message-ID | <5eb1979c-a765-4993-9b06-043b3995a200@googlegroups.com> |
| In reply to | #19094 |
On Friday, 19 October 2012 21:11:06 UTC+3, markspace wrote: > What should I tackle first? Some articles I researched seem to say > multithreading can't truly (i.e., correctly) be implemented in a > library. So is pthreads really relevant any more? If you want the knowledge gained to have best longevity then you should perhaps study std::thread of c++11 as first thing. If you want to start more narrow and more practical then take boost::asio first. It deals with one very important topic: asynchronous communication. It uses boost::thread that is somewhat similar to std::thread.
[toc] | [prev] | [next] | [standalone]
| From | Robert Wessel <robertwessel2@yahoo.com> |
|---|---|
| Date | 2012-10-19 14:03 -0500 |
| Message-ID | <6i7388d0srm8f4e3qrf625n915sf7jpuk5@4ax.com> |
| In reply to | #19094 |
On Fri, 19 Oct 2012 11:11:02 -0700, markspace <-@.> wrote: >Hey all, I've got a little personal project to learn a bit about >multithreading in C++, and I was wondering if anyone would like to give >me a few pointers (no pun intended). > >What would you recommend as a good tutorial? Threading seems to be a >bit in flux, still, since standards have been long in coming (no flames >please) and so I was wondering from a practical standpoint what you'd >recommend. > >Let's assume a Unix/Linux environment. I'll tackle Windows later. > >I have a recommendation for a Boost tutorial, although the article is >really old. > ><http://www.drdobbs.com/cpp/the-boostthreads-library/184401518> The Boost stuff adds some higher level abstractions which can be useful. It also considerably abstracts the OS's threading API, so stuff written to Boost.Thread is portable to any system supporting that library (which include most *nix and Windows). >There's of course a lot of old pthreads tutorials. I wonder if pthreads >has been obviated by now, however. > ><http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html> ><http://codebase.eu/tutorial/posix-threads-c/> No, pthreads is more-or-less the native threads interface for *nix, and flavors of pthreads are available on a number of other systems. >So I'm also wondering how prevalent c++11 is, in your practical opinion. > ><http://solarianprogrammer.com/2011/12/16/cpp-11-thread-tutorial/> The standard is only a few months old, and full implementations are few (although recent versions of GCC are pretty close). OTOH, there's considerable development, and I'd expect (approximately) full C++11 implementations to become common in the next couple of years. C++11 threads are largely based on Boost.Thread (with some changes and limitations!), so conversion from that will often be reasonably straight-forward. >What should I tackle first? Some articles I researched seem to say >multithreading can't truly (i.e., correctly) be implemented in a >library. So is pthreads really relevant any more? > ><http://www.hpl.hp.com/personal/Hans_Boehm/c++mm/> ><http://www.hpl.hp.com/techreports/2004/HPL-2004-209.html> Correct - threading cannot be generally implemented as (only) a library. Doing it properly requires that the compiler, the OS, and some other bits of the tool chain participate. And the compilers and whatnot *do*. So if you're using pthreads under Linux, both GCC and Linux are already involved in the process, so it's *not* just the pthreads library. >Note especially the second link there. > >So where should a newb start? Suggestions? Eh... Either pthreads or Boost.Threads, with the edge going to the latter. With Boost.Threads everything will be much more C++ friendly, and you have the advantages of portability, but you're a few extra steps away from what's going on at the system level. You'll also find more pthreads expertise in the world. Going the C++11 route is probably plausible too, although you'll be a bit of an explorer at this point.
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-10-20 09:17 -0700 |
| Message-ID | <k5uiqe$iva$2@dont-email.me> |
| In reply to | #19098 |
On 10/19/2012 12:03 PM, Robert Wessel wrote: > Eh... Either pthreads or Boost.Threads, with the edge going to the > latter. With Boost.Threads everything will be much more C++ friendly, > and you have the advantages of portability, but you're a few extra > steps away from what's going on at the system level. You'll also find > more pthreads expertise in the world. Going the C++11 route is > probably plausible too, although you'll be a bit of an explorer at > this point. > Thanks to you and Oo Tiib (sorry, I can't do umlats), some good advice from you two.
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2012-10-20 07:31 +0000 |
| Message-ID | <slrnk84kq5.1d3.grahn+nntp@frailea.sa.invalid> |
| In reply to | #19094 |
On Fri, 2012-10-19, markspace wrote: > Hey all, I've got a little personal project to learn a bit about > multithreading in C++, and I was wondering if anyone would like to give > me a few pointers (no pun intended). My first advice would be to learn when *not* to use it, and instead go for separate processes or event multiplexing using select(2), non-blocking I/O and so on. Most use of threads I see in production code is our of ignorance and/or to hide design flaws. Most such code is also buggy, and works more or less by accident. (But I'm unusually negative. I acknowledge that there *are* valid uses for threads.) Eric Raymond: "Threads - Threat or Menace?" http://www.catb.org/esr/writings/taoup/html/ch07s03.html#id2923889 ... > Let's assume a Unix/Linux environment. I'll tackle Windows later. There's a difference between that and "I'm not interested in Windows at all". You may have to start over when/if you look at Windows. ... > There's of course a lot of old pthreads tutorials. I wonder if pthreads > has been obviated by now, however. Pthreads are alive and well, and won't go away anytime soon. You could use that API, but use it in a modern way. I suspect that we've found better patterns for thread communication since those tutorials were written. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | ptyxs <kerloch@gmail.com> |
|---|---|
| Date | 2012-10-20 15:05 +0200 |
| Message-ID | <5082A18A.2020200@gmail.com> |
| In reply to | #19117 |
Le 20/10/2012 09:31, Jorgen Grahn a écrit : > On Fri, 2012-10-19, markspace wrote: >> Hey all, I've got a little personal project to learn a bit about >> multithreading in C++, and I was wondering if anyone would like to give >> me a few pointers (no pun intended). Probably the best thing to do : study the recent (C++11 compliant) book by Anthony Williams C++ Concurrency In Action Ptyxs
[toc] | [prev] | [next] | [standalone]
| From | Luca Risolia <luca.risolia@studio.unibo.it> |
|---|---|
| Date | 2012-10-20 15:20 +0200 |
| Message-ID | <k5u8e2$89s$1@speranza.aioe.org> |
| In reply to | #19123 |
On 20/10/2012 15:05, ptyxs wrote: > Le 20/10/2012 09:31, Jorgen Grahn a écrit : >> On Fri, 2012-10-19, markspace wrote: >>> Hey all, I've got a little personal project to learn a bit about >>> multithreading in C++, and I was wondering if anyone would like to give >>> me a few pointers (no pun intended). > > Probably the best thing to do : study the recent (C++11 compliant) book > by Anthony Williams > C++ Concurrency In Action I agree with you. It's one of the best books about concurrency in C++ and about concurrency in general.
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-10-20 09:14 -0700 |
| Message-ID | <k5uila$iva$1@dont-email.me> |
| In reply to | #19123 |
On 10/20/2012 6:05 AM, ptyxs wrote: > Le 20/10/2012 09:31, Jorgen Grahn a écrit : >> On Fri, 2012-10-19, markspace wrote: >>> Hey all, I've got a little personal project to learn a bit about >>> multithreading in C++, and I was wondering if anyone would like to give >>> me a few pointers (no pun intended). > > Probably the best thing to do : study the recent (C++11 compliant) book > by Anthony Williams > C++ Concurrency In Action Thank you! An excellent suggestion.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web