* [Newbie] Interrupt Handling and sleep/wake_up
@ 2001-09-22 11:19 Christian Vogel
0 siblings, 0 replies; 3+ messages in thread
From: Christian Vogel @ 2001-09-22 11:19 UTC (permalink / raw)
To: linux-kernel
Hi,
-- Warning, newbie qeustion! --
currently I'm trying to write a very simple driver for the NI-GPIB-PCII
card and I'm mostly copying what was linux-gpib a long time ago.
Why am I writing to this list? I think I miss some obvious solution to a
problem. The problem lies within my handling of interrupts, let my try a
simplified example:
The board signals arrival of new data, it's ability to accept new data
or errors via the interrupt. I want my program to sleep until enough
data has been accepted or an error has occured.
Unfortunately on errors the interrupt hits just before I call
sleep_on_timeout() and because it's the only interrupt in this case
that's being generated I have to wait until sleep_on_timeout()
timeout's.
The old driver mostly uses
while(!condition && !i++>threshold)
udelay()
which I would like to avoid.
What would be the preferred way of doing this and what am I missing?
Some simple pseudocode follows to illustrate my point: bdIrq
is the interrupt-service-routine, bdDoSomething is called via
device->file-operations->read/write->... and wants to fetch something
from the card or write to it.
void bdIrq(int irq,void *data, struct pt_regs *regs){
query_board_for_status();
if( board_has_data_available )
readbuf[readcounter++]=inb(data_port);
if( board_can_accept_data )
outb(wrbuf[writecounter++],data_port);
if( board_has_error_condition_set )
board_has_error = 1;
if( buffer_full_or_end_of_data || board_has_error )
wake_up_interruptible(&irq_wqueue);
}
void bdDoSomething(){
setup_buffers_for_interrupt_routing();
tell_board_to_start_reading_or_writing();
/***** BOARD THROWS ITS INTERRUPTS HERE!!! *****/
interruptible_sleep_on_timeout(&irq_wqueue,PCIIA_SLEEP_TIMEOUT);
}
Chris
--
Is it true that cannibals won't eat clowns because they taste funny?
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Newbie] Interrupt Handling and sleep/wake_up
@ 2001-09-22 12:26 Manfred Spraul
2001-09-22 16:12 ` Alan Cox
0 siblings, 1 reply; 3+ messages in thread
From: Manfred Spraul @ 2001-09-22 12:26 UTC (permalink / raw)
To: Christian Vogel; +Cc: linux-kernel
> void bdDoSomething(){
> setup_buffers_for_interrupt_routing();
> tell_board_to_start_reading_or_writing();
> /***** BOARD THROWS ITS INTERRUPTS HERE!!! *****/
> interruptible_sleep_on_timeout(&irq_wqueue,PCIIA_SLEEP_TIMEOUT);
> }
>
Just do not use sleep_on, use wait_event or a manual wait loop.
check the mouse driver sample from Alan Cox:
linux/Documentation/DocBook/mousedriver.tmpl
The document is slightly outdated:
* do not access current->state directly, use set_current_state.
* do not use MOD_INC_USE_COUNT, set module->owner to THIS_MODULE
instead.
--
Manfred
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Newbie] Interrupt Handling and sleep/wake_up
2001-09-22 12:26 [Newbie] Interrupt Handling and sleep/wake_up Manfred Spraul
@ 2001-09-22 16:12 ` Alan Cox
0 siblings, 0 replies; 3+ messages in thread
From: Alan Cox @ 2001-09-22 16:12 UTC (permalink / raw)
To: Manfred Spraul; +Cc: Christian Vogel, linux-kernel
> check the mouse driver sample from Alan Cox:
> linux/Documentation/DocBook/mousedriver.tmpl
>
> The document is slightly outdated:
>
> * do not access current->state directly, use set_current_state.
> * do not use MOD_INC_USE_COUNT, set module->owner to THIS_MODULE
> instead.
Thanks: Updated
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-09-22 16:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-22 12:26 [Newbie] Interrupt Handling and sleep/wake_up Manfred Spraul
2001-09-22 16:12 ` Alan Cox
-- strict thread matches above, loose matches on Subject: below --
2001-09-22 11:19 Christian Vogel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox