All of lore.kernel.org
 help / color / mirror / Atom feed
* a question about __down() in Linux/arch/i386/kernel/semaphore.c
@ 2002-08-05 14:33 Edward Shao \(邵治國\)
  2002-08-05 14:42 ` Edward Shao \(邵治國\)
  0 siblings, 1 reply; 3+ messages in thread
From: Edward Shao \(邵治國\) @ 2002-08-05 14:33 UTC (permalink / raw)
  To: linux-kernel

Hi,

I have a question about __down() in kernel 2.4.18
(Linux/arch/i386/kernel/semaphore.c)
I found the last line of __down() is
wake_up(&sem->wait);
but in kernel 2.5.28, i didn't see this line..
is this line necessary in kernel 2.4.18?
why?

Thank you very much.

Best Regard!!!

-Edward Shao-



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a question about __down() in Linux/arch/i386/kernel/semaphore.c
  2002-08-05 14:33 a question about __down() in Linux/arch/i386/kernel/semaphore.c Edward Shao \(邵治國\)
@ 2002-08-05 14:42 ` Edward Shao \(邵治國\)
  2002-08-05 16:37   ` Bob Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Edward Shao \(邵治國\) @ 2002-08-05 14:42 UTC (permalink / raw)
  To: Edward Shao \(邵治國\), linux-kernel

sorry, i found it!
wake_up_locked(&sem->wait);
but why do we need to wake up the sleepers again?
Thank you very much.

-Edward Shao-

----- Original Message -----
From: "Edward Shao (邵治國)" <szg90@cs.ccu.edu.tw>
To: <linux-kernel@vger.kernel.org>
Sent: Monday, August 05, 2002 10:33 PM
Subject: a question about __down() in Linux/arch/i386/kernel/semaphore.c


> Hi,
>
> I have a question about __down() in kernel 2.4.18
> (Linux/arch/i386/kernel/semaphore.c)
> I found the last line of __down() is
> wake_up(&sem->wait);
> but in kernel 2.5.28, i didn't see this line..
> is this line necessary in kernel 2.4.18?
> why?
>
> Thank you very much.
>
> Best Regard!!!
>
> -Edward Shao-
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a question about __down() in Linux/arch/i386/kernel/semaphore.c
  2002-08-05 14:42 ` Edward Shao \(邵治國\)
@ 2002-08-05 16:37   ` Bob Miller
  0 siblings, 0 replies; 3+ messages in thread
From: Bob Miller @ 2002-08-05 16:37 UTC (permalink / raw)
  To: Edward Shao (ªòªv°ê); +Cc: linux-kernel

On Mon, Aug 05, 2002 at 10:42:37PM +0800, Edward Shao \(ªòªv°ê\) wrote:
> sorry, i found it!
> wake_up_locked(&sem->wait);
> but why do we need to wake up the sleepers again?
> Thank you very much.
> 
> -Edward Shao-
> 
> ----- Original Message -----
> From: "Edward Shao (ªòªv°ê)" <szg90@cs.ccu.edu.tw>
> To: <linux-kernel@vger.kernel.org>
> Sent: Monday, August 05, 2002 10:33 PM
> Subject: a question about __down() in Linux/arch/i386/kernel/semaphore.c
> 
> 
> > Hi,
> >
> > I have a question about __down() in kernel 2.4.18
> > (Linux/arch/i386/kernel/semaphore.c)
> > I found the last line of __down() is
> > wake_up(&sem->wait);
> > but in kernel 2.5.28, i didn't see this line..
> > is this line necessary in kernel 2.4.18?
> > why?
> >
> > Thank you very much.
> >
> > Best Regard!!!
> >
> > -Edward Shao-
> >
> >

The quick answer: so we don't miss waking someone up.  But, seriously,
the semaphore code is very subtle.

This semaphore implementation allows more than one process to be in the
critical section at a time (a.k.a. a counting semaphore).  In order to
support those semantics, more than one wakeup may occur before a process
is pulled off the wake_q and changed to running.  Because the process that
is waiting to run (in the __down() code) is responsible for pulling itself 
off the wait_q, if the 2 __up()s happen before the __down() can finish,
the 2 __up()s will wakeup the same process twice.  So, the __down() code
needs to protect agaist this.

-- 
Bob Miller					Email: rem@osdl.org
Open Source Development Lab			Phone: 503.626.2455 Ext. 17

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-05 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-05 14:33 a question about __down() in Linux/arch/i386/kernel/semaphore.c Edward Shao \(邵治國\)
2002-08-05 14:42 ` Edward Shao \(邵治國\)
2002-08-05 16:37   ` Bob Miller

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.