在并发处理应用中,一般使用锁的方式来解决竞争问题,但锁的效率比较低,因此,在高并发处理中,无锁队列成为应用的需要。CAS无锁算法主要依赖于处理器的支持,绝大多数处理器都支持:
X86平台:CMPXCHG 汇编指令。
在一个指令周期内执行完成,因此是原子性的。
这一原理性操作过程如果采用C描述如下:
intcompare_and_swap (int* reg, int old...
分类:
其他好文 时间:
2014-08-21 19:32:34
阅读次数:
207
Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
You should preserve the original relative order of...
分类:
其他好文 时间:
2014-08-21 19:23:34
阅读次数:
295
Implement an algorithm to print all valid combinations of n-pairs of parentheses#includevoid f(int idx,int left,int right,char *buf){ if(left == 0 ...
分类:
其他好文 时间:
2014-08-21 13:06:34
阅读次数:
168
在C++中,函数参数传递有3种方式,分别是按值传递、按地址传递和按引用传递。其测试代码如下: 1 //Parameter Transmission in C++ 2 #include 3 using namespace std; 4 5 void swap_value(int a,int b)...
分类:
其他好文 时间:
2014-08-21 01:30:23
阅读次数:
290
vmstat# vmstat 3 2procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- r b swpd free buff cache si so bi ...
分类:
其他好文 时间:
2014-08-21 01:27:33
阅读次数:
276
要点:AIX文件系统的访问路径AIX文件系统目录树创建AIX文件系统文件系统的卸载和删除文件系统的自动挂载文件系统的容量管理文件系统的一致性管理文件系统的卸载失败文件系统的快照管理LVM常用命令总结AIX存储部署实践存储使用中的例外在UNIX中,每创建一个文件,就会有一个对应的i-nodes,这些连...
分类:
其他好文 时间:
2014-08-20 23:56:43
阅读次数:
285
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not...
分类:
其他好文 时间:
2014-08-20 14:01:43
阅读次数:
202
Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No...
分类:
其他好文 时间:
2014-08-20 13:58:32
阅读次数:
236
UVA 12338 - Anti-Rhyme Pairs
题目链接
题意:给定一些字符串,每次询问求出两个字符串的最长公共前缀的长度
思路:把字符串排序,就能求出height和rank数组,然后利用RMQ查询即可
代码:
#include
#include
#include
#include
#include
using namespace std;
co...
分类:
其他好文 时间:
2014-08-20 01:24:35
阅读次数:
300
题目:Given an integer N, and how many pairs (A;B) are there such that: gcd(A;B) = A xor B where 1=2)是不同位数的。和同学讨论后得出如下证明:设最大公约数为 j, 假设这两个数是b 和 b+k*j,(k>....
分类:
其他好文 时间:
2014-08-19 23:50:55
阅读次数:
233