Commit 54de6994 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Improve documentation for critical sections.

parent c95959dc
...@@ -77,13 +77,18 @@ static inline HANDLE get_semaphore( RTL_CRITICAL_SECTION *crit ) ...@@ -77,13 +77,18 @@ static inline HANDLE get_semaphore( RTL_CRITICAL_SECTION *crit )
/*********************************************************************** /***********************************************************************
* RtlInitializeCriticalSection (NTDLL.@) * RtlInitializeCriticalSection (NTDLL.@)
* *
* Initialise a new RTL_CRITICAL_SECTION. * Initialises a new critical section.
* *
* PARAMS * PARAMS
* crit [O] Critical section to initialise * crit [O] Critical section to initialise
* *
* RETURN * RETURNS
* STATUS_SUCCESS. * STATUS_SUCCESS.
*
* SEE
* RtlInitializeCriticalSectionAndSpinCount(), RtlDeleteCriticalSection(),
* RtlEnterCriticalSection(), RtlLeaveCriticalSection(),
* RtlTryEnterCriticalSection(), RtlSetCriticalSectionSpinCount()
*/ */
NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit ) NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit )
{ {
...@@ -93,7 +98,7 @@ NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -93,7 +98,7 @@ NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit )
/*********************************************************************** /***********************************************************************
* RtlInitializeCriticalSectionAndSpinCount (NTDLL.@) * RtlInitializeCriticalSectionAndSpinCount (NTDLL.@)
* *
* Initialise a new RTL_CRITICAL_SECTION with a given spin count. * Initialises a new critical section with a given spin count.
* *
* PARAMS * PARAMS
* crit [O] Critical section to initialise * crit [O] Critical section to initialise
...@@ -103,8 +108,12 @@ NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -103,8 +108,12 @@ NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit )
* STATUS_SUCCESS. * STATUS_SUCCESS.
* *
* NOTES * NOTES
* The InitializeCriticalSectionAndSpinCount() (KERNEL32) function is * Available on NT4 SP3 or later.
* available on NT4SP3 or later, and Win98 or later. *
* SEE
* RtlInitializeCriticalSection(), RtlDeleteCriticalSection(),
* RtlEnterCriticalSection(), RtlLeaveCriticalSection(),
* RtlTryEnterCriticalSection(), RtlSetCriticalSectionSpinCount()
*/ */
NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *crit, ULONG spincount ) NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *crit, ULONG spincount )
{ {
...@@ -139,7 +148,7 @@ NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION * ...@@ -139,7 +148,7 @@ NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *
* Sets the spin count of a critical section. * Sets the spin count of a critical section.
* *
* PARAMS * PARAMS
* crit [O] Critical section * crit [I/O] Critical section
* spincount [I] Spin count for crit * spincount [I] Spin count for crit
* *
* RETURNS * RETURNS
...@@ -147,6 +156,11 @@ NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION * ...@@ -147,6 +156,11 @@ NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *
* *
* NOTES * NOTES
* If the system is not SMP, spincount is ignored and set to 0. * If the system is not SMP, spincount is ignored and set to 0.
*
* SEE
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
*/ */
ULONG WINAPI RtlSetCriticalSectionSpinCount( RTL_CRITICAL_SECTION *crit, ULONG spincount ) ULONG WINAPI RtlSetCriticalSectionSpinCount( RTL_CRITICAL_SECTION *crit, ULONG spincount )
{ {
...@@ -159,13 +173,18 @@ ULONG WINAPI RtlSetCriticalSectionSpinCount( RTL_CRITICAL_SECTION *crit, ULONG s ...@@ -159,13 +173,18 @@ ULONG WINAPI RtlSetCriticalSectionSpinCount( RTL_CRITICAL_SECTION *crit, ULONG s
/*********************************************************************** /***********************************************************************
* RtlDeleteCriticalSection (NTDLL.@) * RtlDeleteCriticalSection (NTDLL.@)
* *
* Free the resources used by an RTL_CRITICAL_SECTION. * Frees the resources used by a critical section.
* *
* PARAMS * PARAMS
* crit [I/O] Critical section to free * crit [I/O] Critical section to free
* *
* RETURNS * RETURNS
* STATUS_SUCCESS. * STATUS_SUCCESS.
*
* SEE
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
*/ */
NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit ) NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit )
{ {
...@@ -190,13 +209,22 @@ NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -190,13 +209,22 @@ NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit )
/*********************************************************************** /***********************************************************************
* RtlpWaitForCriticalSection (NTDLL.@) * RtlpWaitForCriticalSection (NTDLL.@)
* *
* Wait for an RTL_CRITICAL_SECTION to become free. * Waits for a busy critical section to become free.
* *
* PARAMS * PARAMS
* crit [I/O] Critical section to wait for * crit [I/O] Critical section to wait for
* *
* RETURNS * RETURNS
* STATUS_SUCCESS. * STATUS_SUCCESS.
*
* NOTES
* Use RtlEnterCriticalSection() instead of this function as it is often much
* faster.
*
* SEE
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
*/ */
NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit ) NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
{ {
...@@ -244,6 +272,25 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -244,6 +272,25 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
/*********************************************************************** /***********************************************************************
* RtlpUnWaitCriticalSection (NTDLL.@) * RtlpUnWaitCriticalSection (NTDLL.@)
*
* Notifies other threads waiting on the busy critical section that it has
* become free.
*
* PARAMS
* crit [I/O] Critical section
*
* RETURNS
* Success: STATUS_SUCCESS.
* Failure: Any error returned by NtReleaseSemaphore()
*
* NOTES
* Use RtlLeaveCriticalSection() instead of this function as it is often much
* faster.
*
* SEE
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
*/ */
NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit ) NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit )
{ {
...@@ -257,7 +304,7 @@ NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -257,7 +304,7 @@ NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit )
/*********************************************************************** /***********************************************************************
* RtlEnterCriticalSection (NTDLL.@) * RtlEnterCriticalSection (NTDLL.@)
* *
* Enter an RTL_CRITICAL_SECTION. * Enters a critical section, waiting for it to become available if necessary.
* *
* PARAMS * PARAMS
* crit [I/O] Critical section to enter * crit [I/O] Critical section to enter
...@@ -265,8 +312,10 @@ NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -265,8 +312,10 @@ NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit )
* RETURNS * RETURNS
* STATUS_SUCCESS. The critical section is held by the caller. * STATUS_SUCCESS. The critical section is held by the caller.
* *
* NOTES * SEE
* The caller will wait until the critical section is availale. * RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlSetCriticalSectionSpinCount(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
*/ */
NTSTATUS WINAPI RtlEnterCriticalSection( RTL_CRITICAL_SECTION *crit ) NTSTATUS WINAPI RtlEnterCriticalSection( RTL_CRITICAL_SECTION *crit )
{ {
...@@ -307,7 +356,7 @@ done: ...@@ -307,7 +356,7 @@ done:
/*********************************************************************** /***********************************************************************
* RtlTryEnterCriticalSection (NTDLL.@) * RtlTryEnterCriticalSection (NTDLL.@)
* *
* Enter an RTL_CRITICAL_SECTION without waiting. * Tries to enter a critical section without waiting.
* *
* PARAMS * PARAMS
* crit [I/O] Critical section to enter * crit [I/O] Critical section to enter
...@@ -315,6 +364,11 @@ done: ...@@ -315,6 +364,11 @@ done:
* RETURNS * RETURNS
* Success: TRUE. The critical section is held by the caller. * Success: TRUE. The critical section is held by the caller.
* Failure: FALSE. The critical section is currently held by another thread. * Failure: FALSE. The critical section is currently held by another thread.
*
* SEE
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlSetCriticalSectionSpinCount()
*/ */
BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit ) BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit )
{ {
...@@ -338,13 +392,18 @@ BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -338,13 +392,18 @@ BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit )
/*********************************************************************** /***********************************************************************
* RtlLeaveCriticalSection (NTDLL.@) * RtlLeaveCriticalSection (NTDLL.@)
* *
* Leave an RTL_CRITICAL_SECTION. * Leaves a critical section.
* *
* PARAMS * PARAMS
* crit [I/O] Critical section to enter * crit [I/O] Critical section to leave.
* *
* RETURNS * RETURNS
* STATUS_SUCCESS. * STATUS_SUCCESS.
*
* SEE
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlSetCriticalSectionSpinCount(), RtlTryEnterCriticalSection()
*/ */
NTSTATUS WINAPI RtlLeaveCriticalSection( RTL_CRITICAL_SECTION *crit ) NTSTATUS WINAPI RtlLeaveCriticalSection( RTL_CRITICAL_SECTION *crit )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment