【问题标题】:Where are mutex locks defined in GCC?GCC 中定义的互斥锁在哪里?
【发布时间】:2014-08-18 12:36:06
【问题描述】:

我正在查看 GCC 中的 arena.c 文件,您可以在以下位置查看:

http://code.woboq.org/userspace/glibc/malloc/arena.c.html#96

更具体地说:

#define arena_lock(ptr, size) do {                                              
      if (ptr)                                                                      
        (void) mutex_lock (&ptr->mutex);                                      
      else                                                                      
        ptr = arena_get2 (ptr, (size), NULL);                                      
   } while (0)

我想知道mutex_lock() 到底做了什么。我在哪里可以找到它的实现?

编辑:找到这个但不确定它是否符合我的要求?

http://lxr.free-electrons.com/source/include/linux/mutex.h

EDIT2 上面的链接不包含mutex_lock() 实现。

【问题讨论】:

  • 一点谷歌搜索让我找到了this link 和许多其他人。我只花了几秒钟。

标签: c linux gcc locking mutex


【解决方案1】:

查看此页面。

http://code.woboq.org/userspace/glibc/sysdeps/nptl/malloc-machine.h.html

它有 mutex_lock() 定义。

您问题中的另一个链接具有内核空间实现。


你应该下载整个glibc源代码,然后使用ctags你应该浏览代码。

【讨论】:

  • ctags 是在 Linux 中浏览代码的 CLI 工具。对于 windows,您可以使用 source insight 或其他 IDE 来读取如此大的 c 项目。
猜你喜欢
  • 2021-11-23
  • 1970-01-01
  • 2012-06-18
  • 1970-01-01
  • 2018-05-23
  • 1970-01-01
  • 2021-12-23
  • 2012-12-25
  • 1970-01-01
相关资源
最近更新 更多