Thread: get semaphore count

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

    get semaphore count

    I want to get the count of a semaphore without tripping the signaled/non-signaled state. But no matter what I can think of, I'd have to do it at one point or another. How can I accomplish this regardless of the maximum value and current value?

  2. #2
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    Well, what about managing the semaphore objects inside a class ? I don't know if there's a direct way to get to the count of the semaphore (except with the ReleaseSemaphore function but in this case it's not a valid option), but depending on how you use the semaphore object, it might be a valid option. Or it might not.
    I hate real numbers.

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    I've thought of that, but the whole idea is that my API can handle semaphores created and managed by other programs by use of Win32 API. If I use a class, it'll screw everything up.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Even if there were a "GetSemCount()" function, the returned count would only be a *snapshot* at the point in time the function was called.

    So what would you do with that information? Why do you need it?

    gg

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Windows takes care of the semaphore count and functionality. You just use it.

  6. #6
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Yeah... the more I think about it, the more I realize my original idea is in vain. Thanks for replying anyhow.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bintree and count (withouth using template)?
    By cubimongoloid in forum C++ Programming
    Replies: 7
    Last Post: 05-24-2009, 06:22 AM
  2. input question
    By piyush_v in forum C Programming
    Replies: 9
    Last Post: 04-12-2007, 07:09 AM
  3. Semaphore Question
    By azamsharp1 in forum C Programming
    Replies: 4
    Last Post: 10-30-2005, 09:01 AM
  4. CreateSemaphore/ReleaseSemaphore
    By nrieger in forum Windows Programming
    Replies: 2
    Last Post: 08-03-2005, 06:57 AM
  5. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM