From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8949 invoked by alias); 27 Jun 2013 12:51:05 -0000 Mailing-List: contact ecos-devel-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-devel-owner@ecos.sourceware.org Received: (qmail 8938 invoked by uid 89); 27 Jun 2013 12:51:05 -0000 X-Spam-SWARE-Status: No, score=1.9 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE,SPF_PASS,TW_PL autolearn=ham version=3.3.1 Received: from dub0-omc3-s4.dub0.hotmail.com (HELO dub0-omc3-s4.dub0.hotmail.com) (157.55.2.13) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 27 Jun 2013 12:51:04 +0000 Received: from DUB124-W44 ([157.55.2.8]) by dub0-omc3-s4.dub0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 27 Jun 2013 05:51:00 -0700 X-TMN: [9NFWBER6DfieHiBt7yMPWxlOAyEPUPCO] Message-ID: From: Bernd Edlinger To: "ecos-devel@ecos.sourceware.org" Subject: RE: RFC: bsd_tcpip patch on synch.c Date: Thu, 27 Jun 2013 12:51:00 -0000 In-Reply-To: References: <51CC0714.6040805@televic.com>, Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2013-06/txt/msg00002.txt.bz2 Hi J=FCrgen, the variant with cyg_mutex_trylock is like busy waiting, and should be reverted. But I agree that the "while (!cyg_mutex_lock()) continue;" construct is somehow really bad style. I do not think that cyg_mutex_lock can ever return false, unless the spl_mutex is completely invalid. If you really expect cyg_mutex_lock to ever return false, then the right thing to do would be to assert(false) and print a callstack or directly enter the debugger. Regards Bernd Edlinger. > From: J.Lambrecht@TELEVIC.com > To: ecos-devel@ecos.sourceware.org > CC: bernd.edlinger@hotmail.de > Date: Thu, 27 Jun 2013 11:34:12 +0200 > Subject: RFC: bsd_tcpip patch on synch.c >=20 > Hello, >=20 > The patch below we already use since 2009. But I did not code the patch,= =20 > so I do not know what problem it solves. Here are our CVS logs about the= =20 > patch: >=20 > - To avoid deadlock on mutex 'splx_mutex', I changed 'cyg_mutex_lock'=20 > into 'cyg_mutex_trylock'. > - Add 'trylock' and 'cyg_thread_delay' to spl_any() in order to handle=20 > the deadlock issue on the mutex 'splx_mutex' >=20 > I am applying the patches from Bernd Edlinger=20 > (http://bugs.ecos.sourceware.org/show_bug.cgi?id=3D1001656)(to fix an=20 > anoying problem "packet loss every 20 minutes when ARP timeout expires"=20 > and to add raw packets). > And I wonder if this patch (below) is still valid? > -------------------------------------------------------------------------= ------- > Index: net/bsd_tcpip/current/src/ecos/synch.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/src/ecos/synch.c,v > retrieving revision 1.3 > diff -u -5 -p -r1.3 synch.c > --- net/bsd_tcpip/current/src/ecos/synch.c 29 Jan 2009 17:49:56=20 > -0000 1.3 > +++ net/bsd_tcpip/current/src/ecos/synch.c 27 Jun 2013 09:12:54 -0000 > @@ -115,12 +115,14 @@ static volatile cyg_handle_t splx_thread > static inline cyg_uint32 > spl_any( cyg_uint32 which ) > { > cyg_uint32 old_spl =3D spl_state; > if ( cyg_thread_self() !=3D splx_thread ) { > - while ( !cyg_mutex_lock( &splx_mutex ) ) > + while ( !cyg_mutex_trylock( &splx_mutex ) ) { > + cyg_thread_delay(1); > continue; > + } > old_spl =3D 0; // Free when we unlock this context > CYG_ASSERT( 0 =3D=3D splx_thread, "Thread still owned" ); > CYG_ASSERT( 0 =3D=3D spl_state, "spl still set" ); > splx_thread =3D cyg_thread_self(); > } > -------------------------------------------------------------------------= ------- > Kind regards, > J=FCrgen >=20 > --=20 > J=FCrgen Lambrecht > R&D Associate > Mobile: +32 499 644 531 > Tel: +32 (0)51 303045 Fax: +32 (0)51 310670 > http://www.televic-rail.com > Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium > Company number 0825.539.581 - RPR Kortrijk=20=09=09=20=09=20=20=20=09=09= =20=20