From: Andrew Morton Subject: Re: [PATCH][RFC] time: add wait_interruptible_timeout macro to sleep (w. timeout) until wake_up Date: Fri, 26 Feb 2010 08:14:18 -0800 Message-ID: <20100226081418.5902446f.akpm@linux-foundation.org> References: <1266761422-2921-1-git-send-email-zajec5@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= Cc: Thomas Gleixner , Ingo Molnar , Linus Torvalds , Linux Kernel Mailing List , DRI List-Id: dri-devel@lists.freedesktop.org On Fri, 26 Feb 2010 11:38:59 +0100 Rafa Miecki wrote: > +#define wait_interruptible_timeout(wq, timeout) > \ > +({ \ > + long ret = timeout; \ > + \ > + DEFINE_WAIT(wait); \ > + prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE); \ > + if (!signal_pending(current)) \ > + ret = schedule_timeout(ret); \ > + finish_wait(&wq, &wait); \ > + \ > + ret; \ > +}) It's often a mistake to use signals in-kernel. Signals are more a userspace thing and it's better to use the lower-level kernel-specific messaging tools in-kernel. Bear in mind that userspace can independently and asynchronously send, accept and block signals. Can KMS use wait_event_interruptible_timeout()?