From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2950 invoked by alias); 3 Sep 2009 08:46:31 -0000 Received: (qmail 2939 invoked by uid 22791); 3 Sep 2009 08:46:30 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-px0-f204.google.com (HELO mail-px0-f204.google.com) (209.85.216.204) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 Sep 2009 08:46:24 +0000 Received: by pxi42 with SMTP id 42so1555614pxi.20 for ; Thu, 03 Sep 2009 01:46:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.143.21.30 with SMTP id y30mr222719wfi.229.1251967583074; Thu, 03 Sep 2009 01:46:23 -0700 (PDT) In-Reply-To: <4A9F83BF.7040209@intefo.ch> References: <4A9D3FB5.4000707@intefo.ch> <4A9D43DB.4090506@intefo.ch> <4A9E9147.6070609@intefo.ch> <4A9F83BF.7040209@intefo.ch> Date: Thu, 03 Sep 2009 08:46:00 -0000 Message-ID: From: Mandeep Sandhu To: Simon Kallweit Cc: ecos-discuss Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] ecos + lwip X-SW-Source: 2009-09/txt/msg00047.txt.bz2 On Thu, Sep 3, 2009 at 2:22 PM, Simon Kallweit wrote: > Mandeep Sandhu wrote: >>>>> >>>>> >>>>> >>>>> cyg_lwip_sequential_init(); >>>>> >>>>> cyg_lwip_thread_new( "My thread", m_main, (void *)"My thread", >>>>> my_stack, 0x1000, 5 ); >>>>> ... >>>>> ... >>>>> >>>>> >>>>> I'll enable more debugs to see where it's getting stuck. >>>> >>>> After changing it to 2, it's able to find the interface (et0) with all >>>> the right settings. >>> >>> Well, that does not really make sense. cyg_lwip_sequential_init() will >>> not >>> return until the lwip stack is initialized, and initializing ethernet >>> device >>> drivers is part of that. This *must* work even when the TCPIP thread has >>> lower priority, as long as you start your application thread *after* the >>> execution of cyg_lwip_sequential_init(). By starting *after* I mean that >>> you >>> also have to make sure that cyg_lwip_sequential_init() and starting your >>> applications thread is done in the same thread! >>> >>> I hope I didn't miss the obvious here, but that's how it should work. >> >> Well, I checked the code again. The netif init is done as part of >> tcpip_init_done(). >> This I see is being called in tcpip_thread(). This function is being >> executed in the >> tcpip thread's context. >> >> I guess this is why the priority of the threads matters. >> >> Would do you think? > > There is a semaphore created in cyg_lwip_sequential_init() which will block > until all initialization (including ethernet devices) in the tcpip thread is > done. Therefore it's priority does not matter. cyg_lwip_sequential_init() > should not return before initialization is completed. > > I just reviewed the code and found that the semaphore is initialized with 1, > which is clearly a bug, it should be initialized with 0 so that the > following call to cyg_semaphore_wait() is actually blocking the thread until > initialization is done. > > My mistake, sorry! Hope it works as intended now. New release: > > http://download.westlicht.ch/lwip-20090903.tar.gz Thanks Simon. I totally missed the sem init part...i guess since the sem is init to 1...the thread never actually waits...and thats why I was seeing the problem. I'll try out the new build and let you know... Thanks, -mandeep > > Simon > -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss