0

I'm trying to protect my list with data using read/write locks, i found solution in this thread: What's the best linux kernel locking mechanism for a specific scenario

But i can't find needed headers for this solution, seems it is outdated, error:

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

Using <linux/spinlock.h>

Community
  • 1
  • 1
Kracken
  • 662
  • 1
  • 11
  • 27

1 Answers1

3

RW_LOCK_UNLOCKED has been deprecated for a long time and finally removed in Linux 2.6.39, so now, according to the documentation:

For dynamic initialization, use spin_lock_init() or rwlock_init() as appropriate:

...

For static initialization, use DEFINE_SPINLOCK() / DEFINE_RWLOCK() or __SPIN_LOCK_UNLOCKED() / __RW_LOCK_UNLOCKED() as appropriate.

Like

static DEFINE_RWLOCK(myrwlock);

or

rwlock_t myrwlock;
static int __init rwlock_init(void)
{
    rwlock_init(&myrwlock);
}

instead of

rwlock_t myrwlock = RW_LOCK_UNLOCKED;
Roman Khimov
  • 4,807
  • 1
  • 27
  • 35