Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 26 Feb 2002 19:56:51 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 26 Feb 2002 19:56:43 -0500 Received: from nrg.org ([216.101.165.106]:16412 "EHLO nrg.org") by vger.kernel.org with ESMTP id ; Tue, 26 Feb 2002 19:56:30 -0500 Date: Tue, 26 Feb 2002 16:56:24 -0800 (PST) From: Nigel Gamble Reply-To: nigel@nrg.org To: Jeff Garzik cc: root@chaos.analogic.com, Linux kernel Subject: Re: schedule() In-Reply-To: <3C7BEA6F.97CB8AD4@mandrakesoft.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Feb 2002, Jeff Garzik wrote: > "Richard B. Johnson" wrote: > > > > I just read on this list that: > > > > while(something) > > { > > current->policy |= SCHED_YIELD; > > schedule(); > > } > > > > Will no longer be allowed in a kernel module! If this is true, how > > do I loop, waiting for a bit in a port, without wasting CPU time? > > Call yield() or better yet, schedule_timeout() Yes, please use schedule_timeout() if at all possible, or make sure that the loop will only ever execute for a few 100us at most. One thing to bear in mind is that using yield() will waste CPU time if the code is ever called by a real-time process (unless it is a SCHED_RR process with other runnable SCHED_RR processes at the same priority), because there will be no other process that the scheduler is allowed to run, so the RT process will just be chosen to run again, with no delay. We really need high resolution timers, so that schedule_timeout() can be used for delays of less than one jiffy. Nigel Gamble nigel@nrg.org Mountain View, CA, USA. http://www.nrg.org/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/