Critical section criticalsection of multi-threaded correlation------

Source: Internet
Author: User

Multi-Threading has been a short board, sorting out the relevant knowledge to facilitate inquiries

Critical area (Critical section)

A critical section is a piece of code that is accessed exclusively by threads. At any point, if a thread is accessing the snippet, all other threads that are trying to access it will be suspended until the thread that is accessed leaves the snippet to enter, ensuring thread safety. applies to control data access . Because of its thread ownership, it can be used for inter-thread mutexes and cannot be used for synchronization.

Related functions

InitializeCriticalSection Initializing critical section objects

void WINAPI initializecriticalsection (  _out_ lpcritical_section lpcriticalsection);

EnterCriticalSection Waiting for critical section object ownership

void WINAPI entercriticalsection (  _inout_ lpcritical_section lpcriticalsection);

LeaveCriticalSection Releasing a critical section object ownership

void WINAPI leavecriticalsection (  _inout_ lpcritical_section lpcriticalsection);

Note: After entercriticalsection execution, it must be ensured that the matching leavecriticalsection can be executed, otherwise the shared resources protected by the critical section will never be freed.

DeleteCriticalSection Destroying critical Area objects

void WINAPI deletecriticalsection (  _inout_ lpcritical_section lpcriticalsection);  

Critical section criticalsection of multi-threaded correlation------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.