Thread: SetEvent()

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    2

    SetEvent()

    Hi,

    I am new to Windows Programming. Can anyone tell me whether the calling thread is blocked on SetEvent() function? Or atleast is it ensured that the thread(s) waiting on the Event set by Set Event() function are scheduled ahead of the thread calling the SetEvent() function?

    Thanks,
    Abhijit

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    the calling thread is blocked on SetEvent
    No it is not, why should it be?

    Or atleast is it ensured that the thread(s) waiting on the Event set by Set Event() function are scheduled ahead of the thread calling the SetEvent() function?
    With multiple threads waiting for the same event - behavior will be different for Manual reset and automatic reset events... (all or only one random thread will be resumed)

    All resumed threads will be scheduled in the regular mode... And no one will give you a guarantee that it (they) will be scheduled on the same CPU as the thread calling SetEvent
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Aug 2008
    Posts
    2
    Thanks for the info.

    I agree with you for multiple processor environment. What about uni processor environment?

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    What about uni processor environment?
    What about it? All resumed threads are scheduled according to the scheduler model of the Windows...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Events are not meant for thread synchronization...
    For that you need critical sections, semaphores or mutexes.
    Events are used to signal when an event occurs.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SetEvent() and ResetEvent()?
    By cpjust in forum Windows Programming
    Replies: 50
    Last Post: 03-26-2008, 09:07 AM