multithreading.

Discussion in 'C++' started by mohangupta13@gmail.com, Mar 26, 2008.

  1. Guest

    hello everyone,
    i want to use multithreading in c++,i have no previous experience of
    implementing multithreading but from my operating system concepts i
    know few concepts of multithreading .
    can anyone please guide me how and were to begin from.
    all help is apprecitated.
    thank you
    mohan gupta
     
    , Mar 26, 2008
    #1
    1. Advertising

  2. wrote:
    > i want to use multithreading in c++,i have no previous experience of
    > implementing multithreading but from my operating system concepts i
    > know few concepts of multithreading .
    > can anyone please guide me how and were to begin from.


    Begin with a good book. I recall that "Java Thread Programming" by
    Paul Hyde gave me the needed push (never mind that it's for Java,
    the principles are the same). I am sure that nowadays you can find
    many a book on multithreading. Ask in 'comp.programming.threads'.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Mar 26, 2008
    #2
    1. Advertising

  3. wrote in message
    > hello everyone,
    > i want to use multithreading in c++,i have no previous experience of
    > implementing multithreading but from my operating system concepts i
    > know few concepts of multithreading .
    > can anyone please guide me how and were to begin from.
    > all help is apprecitated.
    > thank you
    > mohan gupta


    The book "Cross-Platform Development in C++" by Syd Logan has a section on
    threads, where Win32 threads, pthreads and NSPR threads are introduced.
     
    Maarten Kronenburg, Mar 26, 2008
    #3
  4. wrote:
    > i want to use multithreading in c++,i have no previous experience of
    > implementing multithreading but from my operating system concepts i
    > know few concepts of multithreading .
    > can anyone please guide me how and were to begin from.
    > all help is apprecitated.


    http://bisqwit.iki.fi/story/howto/openmp/
     
    Juha Nieminen, Mar 26, 2008
    #4
  5. wrote:
    > hello everyone,
    > i want to use multithreading in c++,i have no previous experience of
    > implementing multithreading but from my operating system concepts i
    > know few concepts of multithreading .
    > can anyone please guide me how and were to begin from.
    > all help is apprecitated.
    > thank you
    > mohan gupta


    Multithreading concepts can get very involved. Probably best to start
    with a good book.

    There are good cross platform C++ threading libraries though so try not
    to use OS specific threading constructs, it will make your life much easier.
     
    Gianni Mariani, Mar 26, 2008
    #5
  6. James Kanze Guest

    On Mar 26, 8:28 pm, "Victor Bazarov" <> wrote:
    > wrote:
    > > i want to use multithreading in c++,i have no previous experience of
    > > implementing multithreading but from my operating system concepts i
    > > know few concepts of multithreading .
    > > can anyone please guide me how and were to begin from.


    > Begin with a good book. I recall that "Java Thread
    > Programming" by Paul Hyde gave me the needed push (never mind
    > that it's for Java, the principles are the same). I am sure
    > that nowadays you can find many a book on multithreading. Ask
    > in 'comp.programming.threads'.


    Along the same lines, the Butendorf is an excellent introductory
    text: even though it is for C and Posix, almost everything in it
    holds for C++, and an awful lot holds for Windows as well.
    (Obviously, not the API names, but all of the considerations as
    to when you need to lock, etc.)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Mar 27, 2008
    #6
  7. On Mar 27, 6:24 am, wrote:
    > hello everyone,
    > i want to use multithreading in c++,i have no previous experience of
    > implementing multithreading but from my operating system concepts i
    > know few concepts of multithreading .
    > can anyone please guide me how and were to begin from.
    > all help is apprecitated.
    > thank you
    > mohan gupta


    Hi Mohan,

    As long as you know the concept of multithreading, then I would say
    you are ready to write multithreading codes. Multithreading codes are
    not that difficult as people think. Multithreading programming is, in
    my opinion, a great fun to do allowing you to taste a bit of
    programming.

    However, there are a number of things you should know before you
    start. First of all, when C++ was born, multithreading wasn't really
    expected to be happened in programming world. In other words,
    Multithreading is not supposed to be used in C++ world. BUT! don't
    take this serisouly there are so many ways that you can deal with C++
    multithreading programming. Second of all, according to some article(I
    can't remember which one was...), when you design a multithreading
    module, you should be extra careful about what you are really trying
    to do. BUT! still just do fail few times and you will learn!!! so
    don't give up =)

    If you have bit of knowledge about algorithms, O-O concept and generic
    programming, then I recommend you to look up a open source library C++
    BOOST. Boost allows you to create multithreaded application so easily
    and safely.

    regards,
    Alex D. B. Kim
     
    Alexander Dong Back Kim, Mar 27, 2008
    #7
  8. <> wrote in message
    > hello everyone,
    > i want to use multithreading in c++,i have no previous experience of
    > implementing multithreading but from my operating system concepts i
    > know few concepts of multithreading .
    > can anyone please guide me how and were to begin from.
    > all help is apprecitated.
    > thank you
    > mohan gupta


    Multithreading has in my opinion two ways of applying C++ virtual functions:
    (1) the thread caller function (e.g. in win32):
    DWORD CALLBACK thread_call( void * arg )
    { base_thread * p = (base_thread *)arg;
    ( *p )();
    }
    where class base_thread has a pure virtual operator()():
    virtual operator()() = 0;
    and derive the different thread call classes from base_thread,
    implementing different operator()(),
    (2) the multi-threading class:
    class multi_thread
    { base_thread * * the_threads;
    public:
    multi_thread( unsigned int );
    ~multi_thread();
    void set_thread( unsigned int, base_thread * );
    virtual void start_threads() = 0;
    virtual void wait_threads() = 0;
    virtual void close_threads() = 0;
    }
    multi_thread::multi_thread( unsigned int n )
    { the_threads = new base_thread * [ n ];
    } etc.
    and derive the different win32/pthread etc. implementations.
    This way C++ runtime polymorphism is set to work in multithreading.
    Maarten.
     
    Maarten Kronenburg, Mar 27, 2008
    #8
  9. gpderetta Guest

    On Mar 27, 9:50 am, James Kanze <> wrote:
    > On Mar 26, 8:28 pm, "Victor Bazarov" <> wrote:
    >
    > > wrote:
    > > > i want to use multithreading in c++,i have no previous experience of
    > > > implementing multithreading but from my operating system concepts i
    > > > know few concepts of multithreading .
    > > > can anyone please guide me how and were to begin from.

    > > Begin with a good book. I recall that "Java Thread
    > > Programming" by Paul Hyde gave me the needed push (never mind
    > > that it's for Java, the principles are the same). I am sure
    > > that nowadays you can find many a book on multithreading. Ask
    > > in 'comp.programming.threads'.

    >
    > Along the same lines, the Butendorf is an excellent introductory
    > text: even though it is for C and Posix, almost everything in it
    > holds for C++, and an awful lot holds for Windows as well.
    > (Obviously, not the API names, but all of the considerations as
    > to when you need to lock, etc.)
    >
    > --
    > James Kanze (GABI Software) email:
    > Conseils en informatique orientée objet/
    > Beratung in objektorientierter Datenverarbeitung
    > 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


    Just to clarify, I think you meant _Butenhof_ book 'Programming with
    POSIX threads'.

    Googling 'Butendorf thread' returns nothing :)

    --
    gpd
     
    gpderetta, Mar 27, 2008
    #9
  10. James Kanze Guest

    On Mar 27, 11:49 pm, gpderetta <> wrote:
    > On Mar 27, 9:50 am, James Kanze <> wrote:
    > > On Mar 26, 8:28 pm, "Victor Bazarov" <> wrote:


    > > > wrote:
    > > > > i want to use multithreading in c++,i have no previous experience of
    > > > > implementing multithreading but from my operating system concepts i
    > > > > know few concepts of multithreading .
    > > > > can anyone please guide me how and were to begin from.
    > > > Begin with a good book. I recall that "Java Thread
    > > > Programming" by Paul Hyde gave me the needed push (never mind
    > > > that it's for Java, the principles are the same). I am sure
    > > > that nowadays you can find many a book on multithreading. Ask
    > > > in 'comp.programming.threads'.


    > > Along the same lines, the Butendorf is an excellent introductory
    > > text: even though it is for C and Posix, almost everything in it
    > > holds for C++, and an awful lot holds for Windows as well.
    > > (Obviously, not the API names, but all of the considerations as
    > > to when you need to lock, etc.)


    > Just to clarify, I think you meant _Butenhof_ book
    > 'Programming with POSIX threads'.


    Yes. That's what comes of typing too quickly.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Mar 28, 2008
    #10
  11. wrote:
    > hello everyone,
    > i want to use multithreading in c++,i have no previous experience of
    > implementing multithreading but from my operating system concepts i
    > know few concepts of multithreading .
    > can anyone please guide me how and were to begin from.
    > all help is apprecitated.
    > thank you
    > mohan gupta



    Multithreading is a platform-specific feature. Check the documentation
    of the API you are going to use (e.g. MFC, .NET, QT, GTKMM, wxWidgets,
    SDL, etc).
     
    Ioannis Vranos, Mar 30, 2008
    #11
  12. On Mar 26, 9:24 pm, wrote:
    > hello everyone,
    > i want to use multithreading in c++,i have no previous experience of
    > implementing multithreading but from my operating system concepts i
    > know few concepts of multithreading .
    > can anyone please guide me how and were to begin from.
    > all help is apprecitated.


    If you know some concepts of multi-threading from your operating
    systems concepts, go ahead and apply them. Just pick up some canonical
    examples, e.g. the producer-consumer problem, the dining philosophers
    problem, or any other ones. Pick up Pthreads or Boost library and
    adapt the examples in C/C++. Later on, you can also formulate the
    algorithms in your favourite notation and hand-compile them into the
    available library calls.

    If you need further help, just let me know.

    Best Regards,
    Szabolcs
     
    Szabolcs Ferenczi, Mar 30, 2008
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Boris Condarco

    Multithreading

    Boris Condarco, Jun 28, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    605
    Boris Condarco
    Jun 30, 2003
  2. Ilia
    Replies:
    6
    Views:
    3,009
    John Saunders
    Nov 4, 2003
  3. Fieldadvice

    Multithreading with HttpWebRequest

    Fieldadvice, Nov 6, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    1,348
  4. Muralidharan Ramakrishnan

    MultiThreading

    Muralidharan Ramakrishnan, Nov 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    415
    Kevin Spencer
    Nov 10, 2003
  5. BoomWackaBoom

    Asynchronous requests vs. multithreading

    BoomWackaBoom, Nov 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    636
    Alvin Bruney
    Nov 15, 2003
Loading...

Share This Page