All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Vogel <chris@obelix.hedonism.cx>
To: linux-kernel@vger.kernel.org
Subject: [Newbie] Interrupt Handling and sleep/wake_up
Date: Sat, 22 Sep 2001 13:19:16 +0200	[thread overview]
Message-ID: <20010922131916.A1188@emil.frop.org> (raw)

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?

             reply	other threads:[~2001-09-22 11:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-22 11:19 Christian Vogel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-09-22 12:26 [Newbie] Interrupt Handling and sleep/wake_up Manfred Spraul
2001-09-22 16:12 ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010922131916.A1188@emil.frop.org \
    --to=chris@obelix.hedonism.cx \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.