简体   繁体   English

Linux 3.16中的SPIN_LOCK_UNLOCKED等效于什么?

[英]What is the Linux 3.16 equivalent of SPIN_LOCK_UNLOCKED?

Here is a line from a kernel module that I wrote for a 2.x kernel. 这是我为2.x内核编写的内核模块中的一行。

static spinlock_t mr_lock = SPIN_LOCK_UNLOCKED;

When I try to compile this module for a 3.16 kernel, I get the following build error. 当我尝试为3.16内核编译该模块时,出现以下构建错误。

error: ‘SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)

When I look at the 3.16 version of linux/spinlock_types.h , which defines the spinlock_t type for this kernel, there is indeed no SPIN_LOCK_UNLOCKED constant anymore. 当我查看linux/spinlock_types.h的3.16版本时,该版本定义了此内核的spinlock_t类型,实际上不再有SPIN_LOCK_UNLOCKED常量。

However, it is not clear how to initialize a spinlock to unlocked for this kernel. 但是,尚不清楚如何初始化该内核的自旋锁以解锁。

What is the correct way to achieve the same initialization? 实现相同初始化的正确方法是什么?

It depends on how you were using it. 这取决于您的使用方式。

#define DEFINE_SPINLOCK(x)    spinlock_t x = __SPIN_LOCK_UNLOCKED(x)

to replace code like:

  spinlock_t init_lock = SPIN_LOCK_UNLOCKED;

with the improved:

  DEFINE_SPINLOCK(init_lock);

I took the above from this 我从上面拿了上面

https://www.mail-archive.com/kernelnewbies@nl.linux.org/msg02836.html https://www.mail-archive.com/kernelnewbies@nl.linux.org/msg02836.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM