[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
rtl_mutex.c : possible add : rtl_wait_sleep_irqrestore ?
- To: rtl@rtlinux.org
- Subject: rtl_mutex.c : possible add : rtl_wait_sleep_irqrestore ?
- From: Edouard TISSERANT <tissered@esstin.uhp-nancy.fr>
- Date: Fri, 17 May 2001 11:46:18 +0200
- In-Reply-To: <200105170921.f4H9LVH16333@hq.fsmlabs.com>
- User-Agent: IMHO/0.98.1 (Webmail for Roxen)
In some kinds of communication (see ArbraCan driver in CanFestival
project, http://www.esstin.uhp-nancy.fr/~tissered/CanFestival/) it is
usefull to stop IRQs while entering in a wait queue, and allowing them
while sleeping.
This could be possible by adding a rtl_wait_sleep_irqrestore function
in rtl_mutex.c.
This would look like this:
------8<------8<------8<------8<------8<------8<------8<
int rtl_wait_sleep_irqrestore (rtl_wait_t *wait, spinlock_t *lock,
unsigned long irq_state)
{
pthread_t self = pthread_self();
struct rtl_wait_struct wait_struct;
self->abort = &rtl_wait_abort;
self->abortdata = wait;
wait_struct.magic = RTL_WAIT_MAGIC;
wait_struct.waiter = self;
wait_struct.next = wait->queue;
wait->queue = &wait_struct;
wait->p_lock = lock;
RTL_MARK_SUSPENDED (self);
rtl_spin_unlock_irqrestore(lock, irq_state);
return rtl_schedule();
}
------8<------8<------8<------8<------8<------8<------8<
And the associated macro:
------8<------8<------8<------8<------8<------8<------8<
#define rtl_wait_event(wq, condition)\
do{\
unsigned long irq_state;\
rtl_spin_lock_irqsave(wq->p_lock, irq_state);\
if(!condition){\
do{\
rtl_wait_sleep_irqrestore(wq, wq->p_lock, irq_state);\
rtl_spin_lock_irqsave(wq->p_lock, irq_state);\
}while(!condition);\
}\
rtl_spin_unlock_irqrestore(wq->p_lock, irq_state);\
}while(0)
------8<------8<------8<------8<------8<------8<------8<
I use it in the last version of ArbraCan.c and I think it could be
usefull for everyone.
Thanks,
Edouard TISSERANT