Sirish Kumar Bethala
Sirish Kumar Bethala

Reputation: 9259

SpinLock read_lock_irqsave flags attribute

This is regarding the void spin_lock_irqsave(spinlock_t *lock, unsigned long flags); function call. It is mentioned that previous interrupt state is stored in flags and we can restore them by passing this to spin_unlock_irqrestore function.

But I did not get how flags which is passed by values captures the previous interrupt state when spin_lock_irqsave is called.

Upvotes: 1

Views: 776

Answers (1)

zwol
zwol

Reputation: 140540

spin_lock_irqsave is a macro, not a function. So it can assign to flags even though it's apparently passed by value.

See:

http://lxr.linux.no/#linux+v2.6.35.4/include/linux/spinlock.h#L312
http://lxr.linux.no/#linux+v2.6.35.4/include/linux/spinlock.h#L187

Upvotes: 6

Related Questions