]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Add msleep_interruptible() function to kernel/timer.c
authorMaximilian Attems <janitor@sternwelten.at>
Fri, 3 Sep 2004 03:35:44 +0000 (20:35 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 3 Sep 2004 03:35:44 +0000 (20:35 -0700)
Signed-off-by: Maximilian Attems <janitor@sternwelten.at>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/delay.h
kernel/timer.c

index d665e4b98711d6c9332736d7f92a1fcd1fc4582f..5c43c336c849c799d1c72889b99162f3acf0129e 100644 (file)
@@ -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)
 {
index 29ecc04d8684c764d12a4e855e64d95c7cce607a..0f112148ae651a721dd14737fc5f66cf1371decd 100644 (file)
@@ -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);