summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaximilian Attems <janitor@sternwelten.at>2004-09-02 20:35:44 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-09-02 20:35:44 -0700
commit52842ed79df3fafbdfa80cf30638d920b308e8ce (patch)
treede6862021044b73ef8175849eeb5ca0f8118ab37
parentb3cd39c197a0d849a521b57a41d7762a658bf551 (diff)
[PATCH] Add msleep_interruptible() function to kernel/timer.c
Signed-off-by: Maximilian Attems <janitor@sternwelten.at> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/delay.h1
-rw-r--r--kernel/timer.c16
2 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/delay.h b/include/linux/delay.h
index d665e4b98711..5c43c336c849 100644
--- a/include/linux/delay.h
+++ b/include/linux/delay.h
@@ -39,6 +39,7 @@ extern unsigned long loops_per_jiffy;
#endif
void msleep(unsigned int msecs);
+unsigned long msleep_interruptible(unsigned int msecs);
static inline void ssleep(unsigned int seconds)
{
diff --git a/kernel/timer.c b/kernel/timer.c
index 29ecc04d8684..0f112148ae65 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1507,3 +1507,19 @@ void msleep(unsigned int msecs)
EXPORT_SYMBOL(msleep);
+/**
+ * msleep_interruptible - sleep waiting for waitqueue interruptions
+ * @msecs: Time in milliseconds to sleep for
+ */
+unsigned long 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);