Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S265416AbTFMPdL (ORCPT ); Fri, 13 Jun 2003 11:33:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S265415AbTFMPdL (ORCPT ); Fri, 13 Jun 2003 11:33:11 -0400 Received: from x35.xmailserver.org ([208.129.208.51]:55432 "EHLO x35.xmailserver.org") by vger.kernel.org with ESMTP id S265416AbTFMPdF (ORCPT ); Fri, 13 Jun 2003 11:33:05 -0400 X-AuthUser: davidel@xmailserver.org Date: Fri, 13 Jun 2003 08:44:59 -0700 (PDT) From: Davide Libenzi X-X-Sender: davide@bigblue.dev.mcafeelabs.com To: David Schwartz cc: Linux Kernel Mailing List Subject: RE: [PATCH] udev enhancements to use kernel event queue In-Reply-To: Message-ID: References: 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 Content-Length: 1236 Lines: 52 On Fri, 13 Jun 2003, David Schwartz wrote: > You could also do (in pseudo-code): > > top: > ret <- v->counter > inc ret > LOCK incl v->counter > cmp v->counter, ret > jz end > LOCK decl v->counter > jmp top: > end: > return ret > > This does not strictly guarantee in order return values, but that's > meaningless without a lock anyway. It is even worse since it can return same values. Suppose counter is 0 : TASK0 TASK1 top: ret <- v->counter ; ret = 0 inc ret ; ret -> 1 LOCK incl v->counter ; counter -> 1 top: ret <- v->counter ; ret = 1 inc ret ; ret -> 2 LOCK incl v->counter ; counter -> 2 cmp v->counter, ret ; match !! got 2 jz end ... cmp v->counter, ret ; ret == 1 , counter == 2 no-match jz end LOCK decl v->counter ; counter -> 1 jmp top Then TASK0 starts again with no interruption and gets 2. You need instrucions that does atomic mod/cmp to do this kind of tricks. - Davide - 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/