I want to sleep while holding a mutex
ckim at etri.re.kr
Fri Jun 5 08:37:21 EDT 2015
> Are you trying to use the mutex during a interrupt handler as you can't you
> need something atomic or not able to sleep like a spinlock.
I use mutex during FIFO burst write or burst read. I don't want other processes to mess up the FIFO access.
spinlock is not for long interval I understand.
보낸 사람 : "nick" <xerofoify at gmail.com>
보낸 날짜 : 2015-06-05 21:34:25 ( +09:00 )
받는 사람 : 김찬 <ckim at etri.re.kr>, kernelnewbies at kernelnewbies.org <kernelnewbies at kernelnewbies.org>
제목 : Re: I want to sleep while holding a mutex
On 2015-06-05 08:30 AM, Chan Kim wrote:
> I need to write to and read from a Ethernet chip's FIFO and for that I want to use DMA controller. So I modified an existing driver and made the process to sleep using wait_event_interruptible after triggering DMA transfer and made it woken up by ISR using wake_up_interruptible. My problem is that the original driver was using spinlock to protect the FIFO access. But as all know, while holding spinlock, I should not sleep. So I tried replacing spinlock with mutex. (Because, I might sleep while acquiring the mutex, and after getting the mutex, I'll sleep again after DMA trigger. I get woken up by the ISR, and I'll release the mutex. No problem! I thought. ) But I still get this 'scheduling while atomic BUG'. The question is : I need to go to sleep until DMA completion while holding a lock (for FIFO read and write). Isn't it ok to sleep while holding a mutex?
> Best regards,
> Chan Kim
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
Are you trying to use the mutex during a interrupt handler as you can't you need something
atomic or not able to sleep like a spinlock.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Kernelnewbies