All of lore.kernel.org
 help / color / mirror / Atom feed
From: maximilian attems <janitor@sternwelten.at>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	kj <kernel-janitors@osdl.org>
Subject: [Kernel-janitors] Re: Add msleep_interruptible() function to
Date: Sun, 15 Aug 2004 13:25:48 +0000	[thread overview]
Message-ID: <20040815132548.GF1799@stro.at> (raw)
In-Reply-To: <1092570891.17605.1.camel@localhost.localdomain>

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

On Sun, 15 Aug 2004, Alan Cox wrote:

> On Sul, 2004-08-15 at 13:18, maximilian attems wrote:
> > + * msleep_interruptible - sleep waiting for waitqueue interruptions
> > + * @msecs: Time in milliseconds to sleep for
> > + */
> > +void msleep_interruptible(unsigned int msecs)
> > +{
> > +	unsigned long timeout = msecs_to_jiffies(msecs);
> > +
> > +	while (timeout) {
> 
> You want to have while(timeout && !signal_pending(current))
> 
> A signal will wake the timeout which will then loop. It might also
> be good to add
> 
> > +		set_current_state(TASK_INTERRUPTIBLE);
> > +		timeout = schedule_timeout(timeout);
> > +	}
> 
> return timeout;
> 
> so that the caller knows more about how long the timer ran for before
> the interrupt and if it was interrupted.

belows patches returns timeout in msecs 
as the function is also called with that unit, 
added definition in include/linux/delay.h



this function is equivalent to:
	current->state = TASK_INTERRUPTIBLE;
	schedule_timeout(timeout);

idea from Ingo Molnar:
well, aboves is not 100% equivalent because msleep() is uninterruptible so
stoppage of the md thread (upon shutdown) will occur with only a 250 msec
delay. Someone should add a msleep_interruptible() function to kernel/timer.c.

Signed-off-by: Maximilian Attems <janitor@sternwelten.at>



---

 linux-2.6.8-max/kernel/timer.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+)


this function is equivalent to:
	current->state = TASK_INTERRUPTIBLE;
	schedule_timeout(timeout);

idea from Ingo Molnar:
well, aboves is not 100% equivalent because msleep() is uninterruptible so
stoppage of the md thread (upon shutdown) will occur with only a 250 msec
delay. Someone should add a msleep_interruptible() function to kernel/timer.c.

Signed-off-by: Maximilian Attems <janitor@sternwelten.at>



---

 linux-2.6.8-max/include/linux/delay.h |    1 +
 linux-2.6.8-max/kernel/timer.c        |   16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff -puN kernel/timer.c~add-msleep_interruptible kernel/timer.c
--- linux-2.6.8/kernel/timer.c~add-msleep_interruptible	2004-08-15 15:15:01.000000000 +0200
+++ linux-2.6.8-max/kernel/timer.c	2004-08-15 15:18:56.000000000 +0200
@@ -1503,3 +1503,19 @@ void msleep(unsigned int msecs)
 
 EXPORT_SYMBOL(msleep);
 
+/**
+ * msleep_interruptible - sleep waiting for waitqueue interruptions
+ * @msecs: Time in milliseconds to sleep for
+ */
+unsigned int msleep_interruptible(unsigned int msecs)
+{
+       unsigned long timeout = msecs_to_jiffies(msecs);
+
+       while (timeout && !signal_pending(current)) {
+               set_current_state(TASK_INTERRUPTIBLE);
+               timeout = schedule_timeout(timeout);
+       }
+       return jiffies_to_msecs(timeout);
+}
+
+EXPORT_SYMBOL(msleep_interruptible);
diff -puN include/linux/delay.h~add-msleep_interruptible include/linux/delay.h
--- linux-2.6.8/include/linux/delay.h~add-msleep_interruptible	2004-08-15 15:15:01.000000000 +0200
+++ linux-2.6.8-max/include/linux/delay.h	2004-08-15 15:17:56.000000000 +0200
@@ -39,5 +39,6 @@ extern unsigned long loops_per_jiffy;
 #endif
 
 void msleep(unsigned int msecs);
+unsigned int msleep_interruptible(unsigned int msecs);
 
 #endif /* defined(_LINUX_DELAY_H) */

_

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

WARNING: multiple messages have this Message-ID (diff)
From: maximilian attems <janitor@sternwelten.at>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	kj <kernel-janitors@osdl.org>
Subject: Re: Add msleep_interruptible() function to kernel/timer.c
Date: Sun, 15 Aug 2004 15:25:48 +0200	[thread overview]
Message-ID: <20040815132548.GF1799@stro.at> (raw)
In-Reply-To: <1092570891.17605.1.camel@localhost.localdomain>

On Sun, 15 Aug 2004, Alan Cox wrote:

> On Sul, 2004-08-15 at 13:18, maximilian attems wrote:
> > + * msleep_interruptible - sleep waiting for waitqueue interruptions
> > + * @msecs: Time in milliseconds to sleep for
> > + */
> > +void msleep_interruptible(unsigned int msecs)
> > +{
> > +	unsigned long timeout = msecs_to_jiffies(msecs);
> > +
> > +	while (timeout) {
> 
> You want to have while(timeout && !signal_pending(current))
> 
> A signal will wake the timeout which will then loop. It might also
> be good to add
> 
> > +		set_current_state(TASK_INTERRUPTIBLE);
> > +		timeout = schedule_timeout(timeout);
> > +	}
> 
> return timeout;
> 
> so that the caller knows more about how long the timer ran for before
> the interrupt and if it was interrupted.

belows patches returns timeout in msecs 
as the function is also called with that unit, 
added definition in include/linux/delay.h



this function is equivalent to:
	current->state = TASK_INTERRUPTIBLE;
	schedule_timeout(timeout);

idea from Ingo Molnar:
well, aboves is not 100% equivalent because msleep() is uninterruptible so
stoppage of the md thread (upon shutdown) will occur with only a 250 msec
delay. Someone should add a msleep_interruptible() function to kernel/timer.c.

Signed-off-by: Maximilian Attems <janitor@sternwelten.at>



---

 linux-2.6.8-max/kernel/timer.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+)


this function is equivalent to:
	current->state = TASK_INTERRUPTIBLE;
	schedule_timeout(timeout);

idea from Ingo Molnar:
well, aboves is not 100% equivalent because msleep() is uninterruptible so
stoppage of the md thread (upon shutdown) will occur with only a 250 msec
delay. Someone should add a msleep_interruptible() function to kernel/timer.c.

Signed-off-by: Maximilian Attems <janitor@sternwelten.at>



---

 linux-2.6.8-max/include/linux/delay.h |    1 +
 linux-2.6.8-max/kernel/timer.c        |   16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff -puN kernel/timer.c~add-msleep_interruptible kernel/timer.c
--- linux-2.6.8/kernel/timer.c~add-msleep_interruptible	2004-08-15 15:15:01.000000000 +0200
+++ linux-2.6.8-max/kernel/timer.c	2004-08-15 15:18:56.000000000 +0200
@@ -1503,3 +1503,19 @@ void msleep(unsigned int msecs)
 
 EXPORT_SYMBOL(msleep);
 
+/**
+ * msleep_interruptible - sleep waiting for waitqueue interruptions
+ * @msecs: Time in milliseconds to sleep for
+ */
+unsigned int msleep_interruptible(unsigned int msecs)
+{
+       unsigned long timeout = msecs_to_jiffies(msecs);
+
+       while (timeout && !signal_pending(current)) {
+               set_current_state(TASK_INTERRUPTIBLE);
+               timeout = schedule_timeout(timeout);
+       }
+       return jiffies_to_msecs(timeout);
+}
+
+EXPORT_SYMBOL(msleep_interruptible);
diff -puN include/linux/delay.h~add-msleep_interruptible include/linux/delay.h
--- linux-2.6.8/include/linux/delay.h~add-msleep_interruptible	2004-08-15 15:15:01.000000000 +0200
+++ linux-2.6.8-max/include/linux/delay.h	2004-08-15 15:17:56.000000000 +0200
@@ -39,5 +39,6 @@ extern unsigned long loops_per_jiffy;
 #endif
 
 void msleep(unsigned int msecs);
+unsigned int msleep_interruptible(unsigned int msecs);
 
 #endif /* defined(_LINUX_DELAY_H) */

_

  reply	other threads:[~2004-08-15 13:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-15 12:18 [Kernel-janitors] Add msleep_interruptible() function to maximilian attems
2004-08-15 12:18 ` Add msleep_interruptible() function to kernel/timer.c maximilian attems
2004-08-15 11:54 ` [Kernel-janitors] Re: Add msleep_interruptible() function to Alan Cox
2004-08-15 11:54   ` Add msleep_interruptible() function to kernel/timer.c Alan Cox
2004-08-15 13:25   ` maximilian attems [this message]
2004-08-15 13:25     ` maximilian attems
2004-08-16  2:22     ` [Kernel-janitors] Re: Add msleep_interruptible() function to Ingo Molnar
2004-08-16  2:22       ` Add msleep_interruptible() function to kernel/timer.c Ingo Molnar
2004-08-16 20:00     ` [Kernel-janitors] Re: Add msleep_interruptible() function to Nishanth Aravamudan
2004-08-16 20:00       ` [Kernel-janitors] Re: Add msleep_interruptible() function to kernel/timer.c Nishanth Aravamudan
2004-08-15 12:50 ` [Kernel-janitors] Re: Add msleep_interruptible() function to Oliver Neukum
2004-08-15 12:50   ` Add msleep_interruptible() function to kernel/timer.c Oliver Neukum

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=20040815132548.GF1799@stro.at \
    --to=janitor@sternwelten.at \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=kernel-janitors@osdl.org \
    --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.