[lkml]   [2000]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: Is this a valid construct?
You have a race condition.

> int flagvar = 0;
> struct semaphore blocking_sem;
> void function_called_from_kernel_thread(void)
> {
> chew_on_hardware();
As soon as you do/did this, the IRQ must've happened. So, before the next
statement is executed, the IRQ handler is called which clears flagvar.

> flagvar = 1;
This is executed _after_ the IRQ handler completes. So, you stomp over
the IRQ handler did.

> down(blocking_sem);
Since the IRQ handler did up(), this down() won't sleep.

Try setting flagvar = 1 _before_ you chew_on_hardware().
Make sure that what ever you do is SMP safe.

Store the tick count of when you do the IRQ handler and when you do
chew_on_hardware(). You'll see if I am right.
i.e., try:

before = system_ticks_NOW
flagvar = 1;
chew_on_hardware ();
after = system_ticks_NOW

printk (..., before, after, irq)

interrupt_handler ( ..)
irq = system_ticks_NOW

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:41    [W:0.043 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site