Results 1 to 1 of 1
Hi- I've got a queue which has a semaphore whose value is equal to the number of items in the queue. The queue read function calls down_interruptible() on the semaphore, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-14-2007 #1
- Join Date
- Jun 2006
- Reading, UK
up() within spin_lock/unlock()
However, although I don't need to protect against concurrent queue reads, I do need to protect against concurrent queue writes. The write code is fairly simple, so I'm using a spinlock_t. Very simplified code:
queue_read(q) down_interruptible(q->count_sem) /* decrement queue's item count */ return next item on q queue_write(q, item) spin_lock(&q->write_lock); add item to q up(&q->count_sem); /* increment queue's item count */ spin_unlock(&q->write_lock);