public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "BALBIR SINGH" <balbir.singh@wipro.com>
To: "lkml" <linux-kernel@vger.kernel.org>
Subject: [RFC] down and down_interruptible on x86
Date: Thu, 13 Jun 2002 10:47:00 +0530	[thread overview]
Message-ID: <00a601c21299$8d998520$290806c0@wipro.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]

Hello, All,

I am a little confused about down and down_interruptible.
My mixed mind tells me it might be a bug in __down() and
__down_interruptible()

snippet from semaphore.c

int __down_interruptible(struct semaphore * sem)
{
....

                /*
                 * With signals pending, this turns into
                 * the trylock failure case - we won't be
                 * sleeping, and we* can't get the lock as
                 * it has contention. Just correct the count
                 * and exit.
                 */
                if (signal_pending(current)) {
                        retval = -EINTR;
                        sem->sleepers = 0;
                        atomic_add(sleepers, &sem->count);
                        break;
                }
.....

        spin_unlock_irq(&semaphore_lock);
        tsk->state = TASK_RUNNING;
        remove_wait_queue(&sem->wait, &wait);
        wake_up(&sem->wait);                     <---------------------
Is this correct?
        return retval;
}

Lets assume that two processes/threads called down_interruptible on a
semaphore.

P1							P2
---			                        ---

down_interruptible()			down_interruptible()
 |							 |
 V							 V
Did not get semaphore, so		signals pending, so leave (break
in the signal_pending if)
waits in the wait queue
 |							|
 V							V
schedule()					Remove self from
wait_queue
							|
							V
						Call wake_up on
&sem->wait

Wont wake_up(&sem->wait), wakeup p1, so then when up() is called for
waking up P1,
the system will panic.

Am I missing something?

Warm Regards,
Balbir


[-- Attachment #2: Wipro_Disclaimer.txt --]
[-- Type: text/plain, Size: 490 bytes --]

**************************Disclaimer************************************

Information contained in this E-MAIL being proprietary to Wipro Limited is 
'privileged' and 'confidential' and intended for use only by the individual
 or entity to which it is addressed. You are notified that any use, copying 
or dissemination of the information contained in the E-MAIL in any manner 
whatsoever is strictly prohibited.

***************************************************************************

                 reply	other threads:[~2002-06-13  5:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='00a601c21299$8d998520$290806c0@wipro.com' \
    --to=balbir.singh@wipro.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox