From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 10 Apr 2001 01:44:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 10 Apr 2001 01:44:30 -0400 Received: from neon-gw.transmeta.com ([209.10.217.66]:65285 "EHLO neon-gw.transmeta.com") by vger.kernel.org with ESMTP id ; Tue, 10 Apr 2001 01:44:27 -0400 Date: Mon, 9 Apr 2001 22:43:53 -0700 (PDT) From: Linus Torvalds To: Tachino Nobuhiro cc: Andrew Morton , Ben LaHaise , David Howells , Alan Cox , Kernel Mailing List Subject: Re: rw_semaphores In-Reply-To: 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, 10 Apr 2001, Tachino Nobuhiro wrote: > > I am not familiar with semaphore or x86, so this may not be correct, > but if the following sequence is possible, the writer can call wake_up() > before the reader calls add_wait_queue() and reader may sleep forever. > Is it possible? The ordering is certainly possible, but if it happens, __down_read_failed() won't actually sleep, because it will notice that the value is positive and just return immediately. So it will do some unnecessary work (add itself to the wait-queue only to remove itself immediately again), but it will do the right thing. Linus