what are the differences among mutex, condition variables, and semaphore?

This is a discussion on what are the differences among mutex, condition variables, and semaphore? within the C++ Programming forums, part of the General Programming Boards category; what are the differences among mutex, condition variables, and semaphore? If multiple threads are hang on a lock, are they ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    284

    what are the differences among mutex, condition variables, and semaphore?

    what are the differences among mutex, condition variables, and semaphore?

    If multiple threads are hang on a lock, are they maintained in a queue? When another thread signals the lock, will the first thread in the queue be released, or it randomly pick one thread to release?

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Is this homework? Usually if it isn't homework, you would not have heard of those terms.

    If you want actual code, you could try Beej's tutorial (assuming you're using POSIX pthreads). Just type "beej" into google.

    If you want theory, you could try Wikipedia.
    http://en.wikipedia.org/wiki/Multithreading
    http://en.wikipedia.org/wiki/Mutex
    http://en.wikipedia.org/wiki/Semaphore_(programming)
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 12:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21