From 52842ed79df3fafbdfa80cf30638d920b308e8ce Mon Sep 17 00:00:00 2001 From: Maximilian Attems Date: Thu, 2 Sep 2004 20:35:44 -0700 Subject: [PATCH] [PATCH] Add msleep_interruptible() function to kernel/timer.c Signed-off-by: Maximilian Attems Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/delay.h | 1 + kernel/timer.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/delay.h b/include/linux/delay.h index d665e4b98711d..5c43c336c849c 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 29ecc04d8684c..0f112148ae651 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); -- 2.53.0