Design of the atom and high performance of DSP (I) User State/kernel State Atomic primitive

Source: Internet
Author: User

Type _ sync_fetch_and_add (type * PTR, type value ,...)
Type _ sync_fetch_and_sub (type * PTR, type value ,...)
Type _ sync_fetch_and_or (type * PTR, type value ,...)
Type _ sync_fetch_and_and (type * PTR, type value ,...)
Type _ sync_fetch_and_xor (type * PTR, type value ,...)
Type _ sync_fetch_and_nand (type * PTR, type value ,...)
These functions perform operations on the memory address pointed to by PTR and return the value before the operation.

Type _ sync_add_and_fetch (type * PTR, type value ,...)
Type _ sync_sub_and_fetch (type * PTR, type value ,...)
Type _ sync_or_and_fetch (type * PTR, type value ,...)
Type _ sync_and_and_fetch (type * PTR, type value ,...)
Type _ sync_xor_and_fetch (type * PTR, type value ,...)
Type _ sync_nand_and_fetch (type * PTR, type value ,...)
These functions perform operations on the memory address pointed to by PTR and return the value after the operation.

Bool _ sync_bool_compare_and_swap (type * PTR, type oldval, type newval ,...)
Type _ sync_val_compare_and_swap (type * PTR, type oldval, type newval ,...)

These two functions perform atomic comparison and exchange of variables. That is, if the value of the memory address pointed to by PTR is the same as that of oldval,
Replace it with the value of newval.
Return the comparison result of a function of the bool type, which is the same as true, and the difference is false. The function of the return type returns the value stored before the PTR pointing to the address exchange.

Type can be 1, 2, 4, or 8-byte int type, that is:

Int8_t/uint8_t

Int16_t/uint16_t

Int32_t/uint32_t

Int64_t/uint64_t


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.