Linux下原子性操作,类似Windows下的InterLockedXXX
其中,这些操作的操作数(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的更多相关文章
- Ubuntu下的iptux和Windows下的飞秋互传文件
1.问题 当Linux下的iptux是安装源里的版本时,存在下面的问题:Windows下的飞秋可以向Linux下的iptux发送文件,iptux接受正常Linux下的iputx给Windows下的飞秋 ...
- 转 windows下安装pycharm并连接Linux的python环境 以及 windows 下notepad ++编辑 linux 的文件
######sample 1:windows下安装pycharm并连接Linux的python环境 https://www.cnblogs.com/junxun/p/8287998.html wind ...
- 安装在Linux下的jenkins执行windows下的bat命令
launch method里面没有 launch agent via java web start 默认是disable 需要改成random 转载自: http://blog.csdn.net/so ...
- CentOS下安装MySQL,Windows下使用Navicat for MySql连接
安装 查看有没有安装过: yum list installed mysql* rpm -qa | grep mysql* 查看有没有安装包: yu ...
- Ubuntu下安装nfs,Windows下访问
Linux 下: 1. 在终端输入 sudo apt-get install portmap nfs-common nfs-kernel-server 2.建立客户机访问目录 sudo mkdir ...
- Linux 下的类似Windows下Everything的搜索工具
Windows NTFS有个超级快的搜索工具Everything,非常好用,Linux下有几个类似的命令行工具,太难用了,推荐一个catfish,类似Everything,有GUI,可以自定义一个快捷 ...
- Linux下类似windows下_beginthread和_endthread 的多线程开发
在 windows下头文件中包含 #include<process.h> 就可以使用_beginthread进行线程创建.个人感觉挺方便的. 在linux下类似于_beginthread ...
- 【原】无脑操作:Windows下搭建Kafka运行环境
Kafka是一种高吞吐量的分布式发布订阅消息系统 1.优点:① 通过磁盘数据结构提供消息的持久化,这种结构对于即使数以TB的消息存储也能够保持长时间的稳定性能.② 高吞吐量:即使是非常普通的硬件Kaf ...
- 如何保存gnome的linux的 会话?相当于windows下的休眠?
在关机前, 你进行的所有操作, 的集合, 就叫做你跟 linux系统 机器间的 一次 会话, 一个session. linux 可以 在关机时保存 这些session, 保存这些打开的窗口 和程序. ...
随机推荐
- [办公自动化]如何对Excel表格顶部设计
领导有一个excel要完成如下功能:顶部要包含企业LOGO,还要包含设计图号.版次等表格,还要包含类似“第 页 of 页” 总体思路: 1.利用顶端标题行完成除了页码以外的所有事情:(当然也可以利 ...
- pox目录中的交换机mac地址学习模块 l2_multi源码
# Copyright 2012-2013 James McCauley # # Licensed under the Apache License, Version 2.0 (the "L ...
- Ubuntu下设置中文字符集支持(解决中文乱码问题)
一. Ubuntu默认的中文字符编码 Ubuntu默认的中文字符编码为zh_CN.UTF-8,这个可以在/etc/environment中看到: sudo gedit /etc/environment ...
- Yii源码阅读笔记(十四)
Model类,集中整个应用的数据和业务逻辑——场景.属性和标签: /** * Returns a list of scenarios and the corresponding active attr ...
- thanksgiving day (eat)
1.try a nibble of your food 2.dig in (开动) 3.ingest in (吞咽) 4.devoured(狼吞虎咽) 5.wolf down your food 6 ...
- using System.Diagnostics; 日志操作
using System.Diagnostics 命名空间 包含了能够与系统进程 事件日志 和性能计数器进行交互的类 一般用于帮助诊断和调试应用程序 例如 Debug类用于帮组调试代码 Process ...
- vbaexcel
Sub WordTest() Dim objwordApp As Word.Application Dim objword As Word.Document Dim objSeheet As Stri ...
- Allowed memory size Out of memory ini_set('memory_limit', '-1');
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 51 bytes) ini_set(' ...
- data-"mit.edu-Thinking In C++"
Volume 2 ctrl+s http://web.mit.edu/merolish/ticpp/TicV2.html http://web.mit.edu/merolish/ticpp/TicV2 ...
- 转:java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
在Win7 64位系统下,使用Java+Access数据库编程,用Java连数据库时,出现错误提示,如下: Java java.sql.SQLException: [Microsoft][ODBC 驱 ...