ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

LONG NTAPI KeReleaseSemaphore ( IN PKSEMAPHORE  Semaphore,
IN KPRIORITY  Increment,
IN LONG  Adjustment,
IN BOOLEAN  Wait 
)

Definition at line 54 of file semphobj.c.

Referenced by CsqInsertIrp(), ExConvertExclusiveToSharedLite(), ExpReleaseOrWaitForKeyedEvent(), ExReleaseResourceForThreadLite(), FF_ReleaseSemaphore(), IssueUniqueIdChangeNotify(), KsGenerateEvent(), LpcpDestroyPortQueue(), MountMgrCheckUnprocessedVolumes(), MountMgrDeviceControl(), MountMgrMountedDeviceArrival(), MountMgrMountedDeviceRemoval(), MountMgrShutdown(), MountMgrUniqueIdChangeRoutine(), MountMgrUnload(), NtReleaseSemaphore(), NtSignalAndWaitForSingleObject(), QueueWorkItem(), ReleaseRemoteDatabaseSemaphore(), and RemoveWorkItem().

{
    LONG InitialState, State;
    KIRQL OldIrql;
    PKTHREAD CurrentThread;
    ASSERT_SEMAPHORE(Semaphore);
    ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);

    /* Lock the Dispatcher Database */
    OldIrql = KiAcquireDispatcherLock();

    /* Save the Old State and get new one */
    InitialState = Semaphore->Header.SignalState;
    State = InitialState + Adjustment;

    /* Check if the Limit was exceeded */
    if ((Semaphore->Limit < State) || (InitialState > State))
    {
        /* Raise an error if it was exceeded */
        KiReleaseDispatcherLock(OldIrql);
        ExRaiseStatus(STATUS_SEMAPHORE_LIMIT_EXCEEDED);
    }

    /* Now set the new state */
    Semaphore->Header.SignalState = State;

    /* Check if we should wake it */
    if (!(InitialState) && !(IsListEmpty(&Semaphore->Header.WaitListHead)))
    {
        /* Wake the Semaphore */
        KiWaitTest(&Semaphore->Header, Increment);
    }

    /* Check if the caller wants to wait after this release */
    if (Wait == FALSE)
    {
        /* Release the Lock */
        KiReleaseDispatcherLock(OldIrql);
    }
    else
    {
        /* Set a wait */
        CurrentThread = KeGetCurrentThread();
        CurrentThread->WaitNext = TRUE;
        CurrentThread->WaitIrql = OldIrql;
    }

    /* Return the previous state */
    return InitialState;
}

Generated on Sun May 27 2012 06:07:58 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.