求解一个API函数问题
InitialzeCriticalSection()这个函数是干么的?什么功能?成员是什么?怎么我MSDN找不到这个函数?
[解决办法]
这个,msdn 没有?
是没有去找吧?
临界区的任何一个相关api,底下有个示范代码的链接,示范页,必有InitialzeCriticalSection函数。
点击 该函数,就跳到了临界区初始化的页面....
[解决办法]
哦, LZ 的拼写,还有错误。
应该是 InitializeCriticalSection
,而不是 LZ 写的 InitialzeCriticalSection
[解决办法]
可以结贴,给分了
萎软 链接:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683472%28v=vs.85%29.aspx
Initializes a critical section object.
Syntax
void WINAPI InitializeCriticalSection(
__out LPCRITICAL_SECTION lpCriticalSection
);
Parameters
lpCriticalSection [out]
A pointer to the critical section object.
Return value
This function does not return a value.
Windows Server 2003 and Windows XP: In low memory situations, InitializeCriticalSection can raise a STATUS_NO_MEMORY exception. This exception was eliminated starting with Windows Vista.
Remarks
The threads of a single process can use a critical section object for mutual-exclusion synchronization. There is no guarantee about the order in which threads will obtain ownership of the critical section, however, the system will be fair to all threads.
The process is responsible for allocating the memory used by a critical section object, which it can do by declaring a variable of type CRITICAL_SECTION. Before using a critical section, some thread of the process must initialize the object.
After a critical section object has been initialized, the threads of the process can specify the object in the EnterCriticalSection, TryEnterCriticalSection, or LeaveCriticalSection function to provide mutually exclusive access to a shared resource. For similar synchronization between the threads of different processes, use a mutex object.
A critical section object cannot be moved or copied. The process must also not modify the object, but must treat it as logically opaque. Use only the critical section functions to manage critical section objects. When you have finished using the critical section, call the DeleteCriticalSection function.
A critical section object must be deleted before it can be reinitialized. Initializing a critical section that has already been initialized results in undefined behavior.
Requirements
Minimum supported client
Windows XP
Minimum supported server
Windows Server 2003
Header
WinBase.h (include Windows.h)
Library
Kernel32.lib
DLL
Kernel32.dll
See also
CreateMutex
Critical Section Objects
DeleteCriticalSection
EnterCriticalSection
InitializeCriticalSectionAndSpinCount
LeaveCriticalSection
Synchronization Functions
TryEnterCriticalSection