Reentrant and thread security

Source: Internet
Author: User

Reentrant: A function can be called at the same time without any impact.
Thread Security: A function can be called by multiple threads at the same time without any impact.
Reentrant> thread security, which requires stronger conditions than thread security.

 

A function is reentrant and must be thread-safe.

A function is thread-safe and may not be reentrant.

==================================

For example:

Malloc is not asynchronous-signal security, but thread security, so it is not Reentrant

Malloc is thread-safe because it adds a thread lock to protect the critical section, but it is not reentrant because there are static variables in it. If it is entered at the same time, this will lead to confusion.
Generally, a function that uses static variables cannot be reentrant.

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.