Hi all,
I'm writing a device driver for an IP core in a Zynq (Xilinx FPGA SoC). I have what I think would be a fairly standard concurrency/locking requirement, but can't seem to find the right data structure for the task.
I have a write() function which tries to write to a buffer. If the buffer is full, it should sleep until an interrupt occurs. An interrupt occurs when some data has exited the buffer. This does not guarantee that the writer now has enough room to write to the buffer, but should wake up the writer so it can check.
I currently implemented this using wait_event() in the writer and wake_up() in the interrupt. The problem is that it hangs (I think...) in the case:
-> writer checks to see if there is room in buffer, but there is no room
-> interrupts occur until the buffer is empty
-> writer sleeps, waiting indefinitely for interrupts to occur and wake it
I think a binary semaphore is what I need here (I used this in FreeRTOS and it seemed to work well), but it doesn't appear that linux has one.
Any ideas?
(if you want to take a look at the code:
GitHub)
Thanks!!
Jacob