reactos/ntoskrnl/ke/semphobj.c

109 lines
2.6 KiB
C
Raw Normal View History

/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ke/semphobj.c
* PURPOSE: Implements the Semaphore Dispatcher Object
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
VOID
NTAPI
KeInitializeSemaphore(IN PKSEMAPHORE Semaphore,
IN LONG Count,
IN LONG Limit)
{
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Simply Initialize the Header */
Semaphore->Header.Type = SemaphoreObject;
Semaphore->Header.Size = sizeof(KSEMAPHORE) / sizeof(ULONG);
Semaphore->Header.SignalState = Count;
InitializeListHead(&(Semaphore->Header.WaitListHead));
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Set the Limit */
Semaphore->Limit = Limit;
}
/*
* @implemented
*/
LONG
NTAPI
KeReadStateSemaphore(IN PKSEMAPHORE Semaphore)
{
ASSERT_SEMAPHORE(Semaphore);
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Just return the Signal State */
return Semaphore->Header.SignalState;
}
/*
* @implemented
*/
LONG
NTAPI
KeReleaseSemaphore(IN PKSEMAPHORE Semaphore,
IN KPRIORITY Increment,
IN LONG Adjustment,
IN BOOLEAN Wait)
{
LONG InitialState, State;
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
KIRQL OldIrql;
PKTHREAD CurrentThread;
ASSERT_SEMAPHORE(Semaphore);
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Lock the Dispatcher Database */
OldIrql = KiAcquireDispatcherLock();
/* Save the Old State and get new one */
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
InitialState = Semaphore->Header.SignalState;
State = InitialState + Adjustment;
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Check if the Limit was exceeded */
if ((Semaphore->Limit < State) || (InitialState > State))
{
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Raise an error if it was exceeded */
KiReleaseDispatcherLock(OldIrql);
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
ExRaiseStatus(STATUS_SEMAPHORE_LIMIT_EXCEEDED);
}
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Now set the new state */
Semaphore->Header.SignalState = State;
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Check if we should wake it */
if (!(InitialState) && !(IsListEmpty(&Semaphore->Header.WaitListHead)))
{
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Wake the Semaphore */
KiWaitTest(&Semaphore->Header, Increment);
}
/* Check if the caller wants to wait after this release */
if (Wait == FALSE)
{
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Release the Lock */
KiReleaseDispatcherLock(OldIrql);
}
else
{
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Set a wait */
CurrentThread = KeGetCurrentThread();
CurrentThread->WaitNext = TRUE;
CurrentThread->WaitIrql = OldIrql;
}
Alex Ionescu <ionucu@videotron.ca> Dispatcher Objects Rewrite (minus Queues, coming in next patch). Global Changes: - Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration. - Reformatting, commenting, and addition of Debug Prints for easier debugging - Properly create Executive Objects. They don't need a creation routine. - Make sure to properly lock and release the Dispatcher Database. Mutex/Mutant: - Correct MUTANT_BASIC_INFORMATION - Return previous state in Kernel Functions, intead of 1 or 0 all the time. - Initialize listhead properly - Removed code duplication between mutant and mutex release. - Fix bugs in release - Add proper exeption if the mutex is not owned. Kernel Queues: - Optimize the code - Use Inserted Flag Timers: - Some changes in setting the default data to allow KiInsertTimer to be called internally by the wait code in the next patch. Events: - Optimize and simplify KeInitializeEvent - Implement KeInitializeEventPair - Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function. - Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked. - Fix KeSetEvent. It was not differentiating between Notification and Sycronization events and also signaling the Event even if nobody was waiting on it. Semaphores: - Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread. - Fix not releasing dispatcher database before raising an exception. - Add check to NtCreateSemaphore to make sure the counts make sense. Event Pairs: - Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted. - Use KeInitializeEventPair svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
/* Return the previous state */
return InitialState;
}
/* EOF */