From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965268Ab0BZQPY (ORCPT ); Fri, 26 Feb 2010 11:15:24 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:60111 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965245Ab0BZQPX (ORCPT ); Fri, 26 Feb 2010 11:15:23 -0500 Date: Fri, 26 Feb 2010 08:14:18 -0800 From: Andrew Morton To: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= Cc: Thomas Gleixner , Ingo Molnar , Linus Torvalds , Linux Kernel Mailing List , DRI Subject: Re: [PATCH][RFC] time: add wait_interruptible_timeout macro to sleep (w. timeout) until wake_up Message-Id: <20100226081418.5902446f.akpm@linux-foundation.org> In-Reply-To: References: <1266761422-2921-1-git-send-email-zajec5@gmail.com> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.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()?