相关疑难解决方法(0)

x86相当于LWARX和STWCX

我正在寻找相当于LWARX和STWCX(在PowerPC处理器上找到)或在x86平台上实现类似功能的方法.此外,哪里是最好的地方找到这样的事情(即锁定/等待免费编程的好文章/网站/论坛).


编辑
我想我可能需要提供更多细节,因为我假设我只是在寻找CAS(比较和交换)操作.我要做的是实现一个带有智能指针的无锁引用计数系统,可以通过多个线程访问和更改.我基本上需要一种在x86处理器上实现以下功能的方法.

int* IncrementAndRetrieve(int **ptr)
{
  int val;
  int *pval;
  do
  {
    // fetch the pointer to the value
    pval = *ptr;

    // if its NULL, then just return NULL, the smart pointer
    // will then become NULL as well
    if(pval == NULL)
      return NULL;

    // Grab the reference count
    val = lwarx(pval);

    // make sure the pointer we grabbed the value from
    // is still the same one referred to by  'ptr'
    if(pval != *ptr)
      continue;

    // Increment …

x86 multithreading reference-counting low-level

9
推荐指数
1
解决办法
4392
查看次数