其中,这些操作的操作数(type)

可以是1,2,4或8字节长度的int类型,即:

int8_t / uint8_t

int16_t / uint16_t

int32_t / uint32_t

int64_t / uint64_t

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);
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);

PS:

bool __sync_bool_compare_and_swap (type *ptr, type cmpValue,type newval)

type __sync_val_compare_and_swap (type *ptr, type cmpValue,type newval)

type __sync_lock_test_and_set (type *ptr, type value)

void __sync_lock_release (type *ptr)

参考:

《Multithreaded simple data type access and atomic variables》

《Built-in functions for atomic memory access》

Linux下原子性操作,类似Windows下的InterLockedXXX的更多相关文章

  1. Ubuntu下的iptux和Windows下的飞秋互传文件

    1.问题 当Linux下的iptux是安装源里的版本时,存在下面的问题:Windows下的飞秋可以向Linux下的iptux发送文件,iptux接受正常Linux下的iputx给Windows下的飞秋 ...

  2. 转 windows下安装pycharm并连接Linux的python环境 以及 windows 下notepad ++编辑 linux 的文件

    ######sample 1:windows下安装pycharm并连接Linux的python环境 https://www.cnblogs.com/junxun/p/8287998.html wind ...

  3. 安装在Linux下的jenkins执行windows下的bat命令

    launch method里面没有 launch agent via java web start 默认是disable 需要改成random 转载自: http://blog.csdn.net/so ...

  4. CentOS下安装MySQL,Windows下使用Navicat for MySql连接

    安装 查看有没有安装过:          yum list installed mysql*          rpm -qa | grep mysql* 查看有没有安装包:          yu ...

  5. Ubuntu下安装nfs,Windows下访问

    Linux 下: 1. 在终端输入  sudo apt-get install portmap nfs-common nfs-kernel-server 2.建立客户机访问目录  sudo mkdir ...

  6. Linux 下的类似Windows下Everything的搜索工具

    Windows NTFS有个超级快的搜索工具Everything,非常好用,Linux下有几个类似的命令行工具,太难用了,推荐一个catfish,类似Everything,有GUI,可以自定义一个快捷 ...

  7. Linux下类似windows下_beginthread和_endthread 的多线程开发

    在 windows下头文件中包含 #include<process.h> 就可以使用_beginthread进行线程创建.个人感觉挺方便的. 在linux下类似于_beginthread ...

  8. 【原】无脑操作:Windows下搭建Kafka运行环境

    Kafka是一种高吞吐量的分布式发布订阅消息系统 1.优点:① 通过磁盘数据结构提供消息的持久化,这种结构对于即使数以TB的消息存储也能够保持长时间的稳定性能.② 高吞吐量:即使是非常普通的硬件Kaf ...

  9. 如何保存gnome的linux的 会话?相当于windows下的休眠?

    在关机前, 你进行的所有操作, 的集合, 就叫做你跟 linux系统 机器间的 一次 会话, 一个session. linux 可以 在关机时保存 这些session, 保存这些打开的窗口 和程序. ...

随机推荐

  1. shopnc编译安装IM服务器node.js

    编译安装IM服务器node.js下载地址http://www.nodejs.org/download/ 选择Source Code node-v0.12.0 #  ./configure # make ...

  2. 如何设置jquery的ajax方法为同步

    jax请求默认的都是异步的如果想同步 async设置为false就可以(默认是true) var html = $.ajax({  url: "some.php",  async: ...

  3. Android消息处理机制

    Android消息处理机制 Android应用程序消息处理机制(深入到native,实际由管道实现-pipe&epoll)

  4. 《Java核心技术卷一》笔记 多线程同步(底层实现)

    一.锁的基本原理 多个线程同时对共享的同一数据存取 ,在这种竞争条件下如果不进行同步很可能会造成数据的讹误. 例如:有一个共享变量int sum=0, 一个线程正调用 sum+=10,另一个线程正好也 ...

  5. 推荐!国外程序员整理的 PHP 资源大全

    推荐!国外程序员整理的 PHP 资源大全 2014/08/02 · PHP, 工具与资源 · 8.5K 阅读 · 1 评论· php 分享到:0 与<YII框架>不得不说的故事—安全篇 R ...

  6. JAVA NIO的理解

    在使用JAVA提供的Socket的IO方法时,服务端为了方便操作,会为每一个连接新建一个线程,一个线程处理一个客户端的数据交互.但是当大量客户端同服务端连接时,会创建大量的线程,线程之间的切换会严重影 ...

  7. Linux命令echo -e

    在Linux命令中 echo -e 这个参数e是什么意思. echo –e “I will use ‘touch’ command to create 3 files.” 这里参数e的作用是什么 ma ...

  8. the basic index concept

    Computer Science An Overview _J. Glenn Brookshear _11th Edition Over the years numerous variations o ...

  9. android Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.

    在当前工程目录中 gradle.properties 添加org.gradle.jvmargs=-XX\:MaxHeapSize\=256m -Xmx256m http://stackoverflow ...

  10. Java ArrayListSerialise

    import java.io.*; import java.util.*; //ArrayListSerialise public class A { public static void main( ...