From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1009 invoked by alias); 16 Feb 2006 16:54:15 -0000 Received: (qmail 1001 invoked by uid 22791); 16 Feb 2006 16:54:15 -0000 X-Spam-Check-By: sourceware.org Received: from tomts36-srv.bellnexxia.net (HELO tomts36-srv.bellnexxia.net) (209.226.175.93) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 16 Feb 2006 16:54:13 +0000 Received: from derekwin ([69.159.205.41]) by tomts36-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20060216165411.KYFX13653.tomts36-srv.bellnexxia.net@derekwin>; Thu, 16 Feb 2006 11:54:11 -0500 From: "Derek Bouius" To: "'Andrew Lunn'" Cc: , Date: Thu, 16 Feb 2006 16:54:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit In-Reply-To: <20060216162548.GC27143@lunn.ch> Message-Id: <20060216165411.KYFX13653.tomts36-srv.bellnexxia.net@derekwin> Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: RE: [ECOS] How to debug synchronisation in the usbs.c in a new usb-driver for the ARM at91sam7s... X-SW-Source: 2006-02/txt/msg00161.txt.bz2 The problem is a race condition between checking the completed flag and executing the callback. I will describe the flow of the usbs_devtab_write: 1. Initialize the variables (signal, mutex, etc) 2. Setup the callback function - (Callback sets the signal) 3. Start the transfer 4. Lock the mutex. 5. Check if wait.completed ...race condition.... 6. Wait for signal -- waits here forever in some cases if the callback was executed after #5 and before #6 7. Unlock the mutex. ... .. What happens in the lower level driver is that the (#3) start_tx_fn() enables the interrupt. That can fire immediately and call the callback from within the dsr. Executing #5 above can happen inbetween the enable of the interrupt and the actual interrupt. The same process can occur in the read. Derek -----Original Message----- From: Andrew Lunn [mailto:andrew@lunn.ch] Sent: Thursday, February 16, 2006 11:26 AM To: Derek Bouius Cc: andrew@lunn.ch; munz@speag.ch; ecos-discuss@sourceware.org Subject: Re: [ECOS] How to debug synchronisation in the usbs.c in a new usb-driver for the ARM at91sam7s... On Thu, Feb 16, 2006 at 11:15:25AM -0500, Derek Bouius wrote: > I am not registered for the mailing list, but peruse it once in a > while, so I am not sure if my mail will go through to it. Feel free > to repost it if it doesn't. It got through. > What we did to fix the locking issue was change the mutex to a > semaphore. See the patch. It seems to work reliably. Did you understand what the problem was with the condition variable? Could you explain it? Thanks Andrew -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss