[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
BOUNCE rtl@rtlinux.org: Approval required: Non-member submissionfrom [Edouard TISSERANT <tissered@esstin.uhp-nancy.fr>] (fwd)
- To: rtl@rtlinux.org
- Subject: BOUNCE rtl@rtlinux.org: Approval required: Non-member submissionfrom [Edouard TISSERANT <tissered@esstin.uhp-nancy.fr>] (fwd)
- From: Der Herr Hofrat <der.herr@hofr.at>
- Date: Thu, 17 May 2001 20:45:32 +0200 (CEST)
>From owner-rtl Thu May 17 03:44:36 2001
Received: from esstin.esstin.u-nancy.fr (IDENT:root@esstin.u-nancy.fr [193.54.10.10])
by hq.fsmlabs.com (8.11.2/8.11.2) with ESMTP id f4H9iZr16493
for <rtl@rtlinux.org>; Thu, 17 May 2001 03:44:35 -0600
Received: from 0 (IDENT:root@webmail.esstin.uhp-nancy.fr [193.54.10.60])
by esstin.esstin.u-nancy.fr (8.9.3/8.9.3) with ESMTP id LAA02318
for <rtl@rtlinux.org>; Thu, 17 May 2001 11:39:55 +0200
Message-Id: <200105170939.LAA02318@esstin.esstin.u-nancy.fr>
Date: Fri, 17 May 2001 11:46:18 +0200
Subject: =?iso-8859-1?q?rtl=5Fmutex.c?= : possible add : =?iso-8859-1?q?rtl=5Fwait=5Fsleep=5Firqrestore?= =?iso-8859-1?q?_=3F?=
Content-Type: text/plain; charset=iso-8859-1
MIME-Version: 1.0
To: rtl@rtlinux.org
In-Reply-To: <200105170921.f4H9LVH16333@hq.fsmlabs.com>
User-Agent: IMHO/0.98.1 (Webmail for Roxen)
From: Edouard TISSERANT <tissered@esstin.uhp-nancy.fr>
Content-Transfer-Encoding: 8bit
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