Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Thread Sync Objects...

Thread Sync Objects...

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shiva Prasad T S
    wrote on last edited by
    #1

    Hi all, I am quite aware of the working of the thread synchronisation objects like, event, mutex, Critical Section, semaphore...etc... I know each of it's working individually, but can anybody let me know, 1)what is the advantage ,disadvantage over other.. 2)when each of the one is best to use.. I had check out various sources to find this info...But I am not convinced nor it explains me only the concepts... Thanks a lot, Shiva P

    M 1 Reply Last reply
    0
    • S Shiva Prasad T S

      Hi all, I am quite aware of the working of the thread synchronisation objects like, event, mutex, Critical Section, semaphore...etc... I know each of it's working individually, but can anybody let me know, 1)what is the advantage ,disadvantage over other.. 2)when each of the one is best to use.. I had check out various sources to find this info...But I am not convinced nor it explains me only the concepts... Thanks a lot, Shiva P

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      There is no "best" of those objects, because they have different purposes. The only comparison that makes sense is mutex vs. critical section. Those two do the same job, but mutexes are visible to the whole machine, whereas critical sections are not. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber CP SearchBar v2.0.2 released

      A 1 Reply Last reply
      0
      • M Michael Dunn

        There is no "best" of those objects, because they have different purposes. The only comparison that makes sense is mutex vs. critical section. Those two do the same job, but mutexes are visible to the whole machine, whereas critical sections are not. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber CP SearchBar v2.0.2 released

        A Offline
        A Offline
        Abebe
        wrote on last edited by
        #3

        mutexes are only visible to the whole machine when you have specified a name, correct me if i'm wrong.

        B 1 Reply Last reply
        0
        • A Abebe

          mutexes are only visible to the whole machine when you have specified a name, correct me if i'm wrong.

          B Offline
          B Offline
          Blake Coverett
          wrote on last edited by
          #4

          If you don't name them you can't look them up by name in another process, but you can still use them in another process if the handle is passed there in some other fashion. Have a look at DuplicateHandle(). -- -Blake (com/bcdev/blake)

          A 1 Reply Last reply
          0
          • B Blake Coverett

            If you don't name them you can't look them up by name in another process, but you can still use them in another process if the handle is passed there in some other fashion. Have a look at DuplicateHandle(). -- -Blake (com/bcdev/blake)

            A Offline
            A Offline
            Abebe
            wrote on last edited by
            #5

            ok, thanks!

            D 1 Reply Last reply
            0
            • A Abebe

              ok, thanks!

              D Offline
              D Offline
              Dudi Avramov
              wrote on last edited by
              #6

              If the sync is only for the current process then use critical-section since it's faster than mutex. in Mutex you will always have context switch to kernel mode , whereas in critical section you stay in user mode when there is no contention.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups