| | |
Threads!
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
hi to everyone,
In this semester we are having a class concerning High Performace computing / Parallel processing...
In short i have the following questions:
--- We are using pthreads and C. I think that i can use pthreads in c++ code but is there any way to use threads in c++ ,in an object oriented manner?
{Like object oriented pthreads}
--- For everyone that has some experience with production code. Is it common for "everyday" applications (in todays multicore platforms) to use threads?
I use the term everyday to seperate scientific from non scientific applications{*}. I.e. if we open a text editor will we find threads inside?
Last but not least, can anyone propose sources for threaded programming.{Books, sites whatever it might help}. I have "googled" it, but i
was wondering if anyone with hands-on experience has something to say.
{*}:: i imagine that in scientific applications threads are used in things like matrix multiplication.
thanks for your time,
Nicolas
In this semester we are having a class concerning High Performace computing / Parallel processing...
In short i have the following questions:
--- We are using pthreads and C. I think that i can use pthreads in c++ code but is there any way to use threads in c++ ,in an object oriented manner?
{Like object oriented pthreads}
--- For everyone that has some experience with production code. Is it common for "everyday" applications (in todays multicore platforms) to use threads?
I use the term everyday to seperate scientific from non scientific applications{*}. I.e. if we open a text editor will we find threads inside?
Last but not least, can anyone propose sources for threaded programming.{Books, sites whatever it might help}. I have "googled" it, but i
was wondering if anyone with hands-on experience has something to say.
{*}:: i imagine that in scientific applications threads are used in things like matrix multiplication.
thanks for your time,
Nicolas
Two roads diverged in a wood, and I— I took the one less traveled by, and that has made all the difference.
by Robert Frost the "The Road Not Taken"
by Robert Frost the "The Road Not Taken"
>>I think that i can use pthreads in c++ code but is there any way to use threads in c++ ,in an object oriented manner?
There might be some obscure c++ objects out there, such as the Microsoft Foundation Class (MFC) which is only useful for wring MS-Windows windows. Boost libraries have a threading class that.
>>Is it common for "everyday" applications (in todays multicore platforms) to use threads?
Yes, it is very common. If you are running MS-Windows start up the Task Manager, view the Processes tab then you can see how many thread each process has started. You might have to select View --> Options to get that column.
>>I have "googled" it, but i was wondering if anyone with hands-on experience has something to say.
Theread aren't reall all that difficult to start. Here are a few google links you should read. You can ignore the ones about MFC unless you are using that which is doubtful.
There might be some obscure c++ objects out there, such as the Microsoft Foundation Class (MFC) which is only useful for wring MS-Windows windows. Boost libraries have a threading class that.
>>Is it common for "everyday" applications (in todays multicore platforms) to use threads?
Yes, it is very common. If you are running MS-Windows start up the Task Manager, view the Processes tab then you can see how many thread each process has started. You might have to select View --> Options to get that column.
>>I have "googled" it, but i was wondering if anyone with hands-on experience has something to say.
Theread aren't reall all that difficult to start. Here are a few google links you should read. You can ignore the ones about MFC unless you are using that which is doubtful.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
>>I.e. if we open a text editor will we find threads inside?
Text editor will definitely be multithreaded. Imagine a scenario where you send one document for printing and are writing into another document. Almost every application we use in our day to day lives will be multithreaded. The fast CPU speeds, huge amount of RAM's in the systems today make it almost mandatory to write multithreaded code to take full advantage of the processor.
Text editor will definitely be multithreaded. Imagine a scenario where you send one document for printing and are writing into another document. Almost every application we use in our day to day lives will be multithreaded. The fast CPU speeds, huge amount of RAM's in the systems today make it almost mandatory to write multithreaded code to take full advantage of the processor.
thanks
-chandra
-chandra
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
> is there any way to use threads in c++
the ISO standards committee (c++09) has voted voted in a number of concurrency extensions into the working draft (memory model, atomics library, basic threads, locks, and condition variables). an asynchronous future<T> type would be added later, but features like thread pools are deferred.
http://www.open-std.org/jtc1/sc22/wg...007/n2320.html
the Boost.Thread library has been rewritten to align with c++09 proposals.
http://www.boost.org/doc/libs/1_35_0...ml/thread.html
> Is it common for "everyday" applications (in todays multicore platforms) to use threads?
in windows, probably yes. threads have been widely used over the years.
in unix, probably no. fork is very efficient.
most of the push towards concurrency seems to be in the kernel (solaris, bsd), filesystems (zfs) and libc ( bsd's gemalloc, google's tcmalloc) right now.
opinion seems to be divided; here are two extremes:
http://www.informit.com/articles/article.aspx?p=1193856
http://www.gotw.ca/publications/concurrency-ddj.htm
> sources for threaded programming.
a great book: Java Concurrency in Practice by Brian Goetz
http://www.javaconcurrencyinpractice.com/
two other good books:
Patterns for Parallel Programming by Timothy G. Mattson, Beverly A. Sanders, Berna L. Massingill
http://www.amazon.com/Patterns-Paral.../dp/0321228111
The Art of Multiprocessor Programming by Maurice Herlihy, Nir Shavit
http://www.amazon.com/gp/product/0123705916
the ISO standards committee (c++09) has voted voted in a number of concurrency extensions into the working draft (memory model, atomics library, basic threads, locks, and condition variables). an asynchronous future<T> type would be added later, but features like thread pools are deferred.
http://www.open-std.org/jtc1/sc22/wg...007/n2320.html
the Boost.Thread library has been rewritten to align with c++09 proposals.
http://www.boost.org/doc/libs/1_35_0...ml/thread.html
> Is it common for "everyday" applications (in todays multicore platforms) to use threads?
in windows, probably yes. threads have been widely used over the years.
in unix, probably no. fork is very efficient.
most of the push towards concurrency seems to be in the kernel (solaris, bsd), filesystems (zfs) and libc ( bsd's gemalloc, google's tcmalloc) right now.
opinion seems to be divided; here are two extremes:
•
•
•
•
I won’t be surprised at all if the whole multithreading idea turns out to be a flop, worse than the "Itanium" approach that was supposed to be so terrific—until it turned out that the wished-for compilers were basically impossible to write.
Let me put it this way: During the past 50 years, I’ve written well over a thousand programs, many of which have substantial size. I can’t think of even five of those programs that would have been enhanced noticeably by parallelism or multithreading. - Donald Knuth
•
•
•
•
Concurrency is the next major revolution in how we write software
Applications will increasingly need to be concurrent if they want to fully exploit continuing exponential CPU throughput gains. - Herb Sutter
> sources for threaded programming.
a great book: Java Concurrency in Practice by Brian Goetz
http://www.javaconcurrencyinpractice.com/
two other good books:
Patterns for Parallel Programming by Timothy G. Mattson, Beverly A. Sanders, Berna L. Massingill
http://www.amazon.com/Patterns-Paral.../dp/0321228111
The Art of Multiprocessor Programming by Maurice Herlihy, Nir Shavit
http://www.amazon.com/gp/product/0123705916
Last edited by vijayan121; May 13th, 2008 at 10:46 am.
thank you all, for your answers!
from this link.... http://www.ddj.com/cpp/184401518 is also helpful...
this phrase states my problem:
is there any tutorial ,{or} book for this?
[maybe the book Java Concurrency in Practice addresses this thing, but i haven't got it so far]
also i heard nice comments about this book:
http://www.amazon.com/Designing-Buil.../dp/0201575949
which is freely availiable from here:
http://www-unix.mcs.anl.gov/dbpp/
although published in 1995 it seems a bit old....
where do you stand vijayan121{and the other members of daniweb}?
i can understand how you would solve server response problems with fork. But how you would solve others like i.e examining a 2d matrix?
can you point to any articles concerning the concurrency in the kernel?{it seems really interesting...}
thanks again for your help!
-nicolas
from this link.... http://www.ddj.com/cpp/184401518 is also helpful...
this phrase states my problem:
•
•
•
•
these libraries are almost universally C libraries and require careful use in C++
[maybe the book Java Concurrency in Practice addresses this thing, but i haven't got it so far]
also i heard nice comments about this book:
http://www.amazon.com/Designing-Buil.../dp/0201575949
which is freely availiable from here:
http://www-unix.mcs.anl.gov/dbpp/
although published in 1995 it seems a bit old....
•
•
•
•
Originally Posted by vijayan121
opinion seems to be divided
•
•
•
•
Originally Posted by vijayan121
in windows, probably yes. threads have been widely used over the years.
in unix, probably no. fork is very efficient.
fork is very efficient.
•
•
•
•
Originally Posted by vijayan121
most of the push towards concurrency seems to be in the kernel (solaris, bsd), filesystems (zfs) and libc ( bsd's gemalloc, google's tcmalloc) right now.
thanks again for your help!
-nicolas
Two roads diverged in a wood, and I— I took the one less traveled by, and that has made all the difference.
by Robert Frost the "The Road Not Taken"
by Robert Frost the "The Road Not Taken"
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
> maybe the book Java Concurrency in Practice addresses this thing
no, it doesn't. it is a good book on concurrency issues in general, but discusses only java.
> where do you stand vijayan121
closer to Knuth than to Sutter. my experience has been that the extra synchronization overhead very often cancels out quite a bit of the performance gains. not to mention exponentially greater complexity of the software. it is much cheaper to just buy more machines than hire more (good) programmers.
> But how you would solve others like i.e examining a 2d matrix?
high performance mathematical/graphics/engineering computing would remain a niche area. again, i tend to agree with Knuth:
> can you point to any articles concerning the concurrency in the kernel?
freebsd:
not too many articles exist. to be current, you need to look at the source code. and the freebsd-hackers mailing list. http://lists.freebsd.org/mailman/lis...reebsd-hackers
a somewhat dated reference is the book 'The Design and Implementation of the FreeBSD Operating System' http://www.informit.com/store/produc...sbn=0201702452
some other documents/papers that i'm aware of:
http://people.freebsd.org/~kris/scal...%20Preview.pdf
http://www.onlamp.com/pub/a/bsd/2008...70.html?page=4
http://ieeexplore.ieee.org/Xplore/lo...3/04215520.pdf
http://portal.acm.org/citation.cfm?i...GUIDE&dl=GUIDE
http://www.watson.org/~robert/freebs...05-netperf.pdf
solaris:
book: 'Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture, Second Edition'
http://safari.adobepress.com/0131482092
articles at http://www.solarisinternals.com/wiki/
no, it doesn't. it is a good book on concurrency issues in general, but discusses only java.
> where do you stand vijayan121
closer to Knuth than to Sutter. my experience has been that the extra synchronization overhead very often cancels out quite a bit of the performance gains. not to mention exponentially greater complexity of the software. it is much cheaper to just buy more machines than hire more (good) programmers.
> But how you would solve others like i.e examining a 2d matrix?
high performance mathematical/graphics/engineering computing would remain a niche area. again, i tend to agree with Knuth:
•
•
•
•
I know that important applications for parallelism exist—rendering graphics, breaking codes, scanning images, simulating physical and biological processes, etc. But all these applications require dedicated code and special-purpose techniques, which will need to be changed substantially every few years.
freebsd:
not too many articles exist. to be current, you need to look at the source code. and the freebsd-hackers mailing list. http://lists.freebsd.org/mailman/lis...reebsd-hackers
a somewhat dated reference is the book 'The Design and Implementation of the FreeBSD Operating System' http://www.informit.com/store/produc...sbn=0201702452
some other documents/papers that i'm aware of:
http://people.freebsd.org/~kris/scal...%20Preview.pdf
http://www.onlamp.com/pub/a/bsd/2008...70.html?page=4
http://ieeexplore.ieee.org/Xplore/lo...3/04215520.pdf
http://portal.acm.org/citation.cfm?i...GUIDE&dl=GUIDE
http://www.watson.org/~robert/freebs...05-netperf.pdf
solaris:
book: 'Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture, Second Edition'
http://safari.adobepress.com/0131482092
articles at http://www.solarisinternals.com/wiki/
![]() |
Similar Threads
- I want google to index forum threads (Search Engine Optimization)
- new way the threads are timed (DaniWeb Community Feedback)
- IE won't let me access threads. Could someone email me a solution please? (Web Browsers)
Other Threads in the C++ Forum
- Previous Thread: extracting integers using getline
- Next Thread: Using New
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






