Re: Do not deprecate binary semaphore or do allow mutex in software interrupt contexts

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Matti Linnanvuori <mattilinnanvuori@...>
Cc: <linux-kernel@...>, Alan Cox <alan@...>, arjan <arjan@...>
Date: Tuesday, September 11, 2007 - 12:50 pm

[re-adding CCs, please do not drop these]

On Tue, 2007-09-11 at 09:20 -0700, Matti Linnanvuori wrote:

Yes it is.


If you have to wait a long time in an atomic context you've done
something wrong. If you're only reading it from an atomic context you
might consider storing a copy that can be quickly updated and protect
that using a spinlock.

do_update ()
{
  mutex_lock(&my_device_mutex);
  my_device_frob_state(&my_state); /* <-- this takes a _long_ while */
  spin_lock_irq(&my_shadow_state_lock);
  my_shadow_state = state; /* <-- this is a quick memcopy */
  spin_unlock_irq(&my_shadow_state_lock);
  mutex_unlock(&my_device_mutex);
}

do_read()
{
  spin_lock_irq(&my_shadow_state);
  do_something_with_shadow_state(&mt_shadow_state);
  spin_unlock_irq(&my_shadow_state);

  return foo;
}


Not being too familiar with the timer stuff, it smells wrong what you
say.

As for the whole polling method, consider what Alan said, don't do it if
you don't need to. You'll annoy people at no end. Try to push state
changes where possible.

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Do not deprecate binary semaphore or do allow mutex in softw..., Matti Linnanvuori, (Tue Sep 11, 12:20 pm)
Re: Do not deprecate binary semaphore or do allow mutex in s..., Peter Zijlstra, (Tue Sep 11, 12:50 pm)