From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29036 invoked by alias); 27 May 2016 16:31:49 -0000 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 Received: (qmail 28305 invoked by uid 89); 27 May 2016 16:31:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:ecos-di, ellis, tick, 2.0.98 X-HELO: mail.calivar.com Received: from calivar.com (HELO mail.calivar.com) (88.97.108.23) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 27 May 2016 16:31:38 +0000 Received: by mail.calivar.com (Postfix, from userid 111) id 1800A41FB8; Fri, 27 May 2016 17:31:33 +0100 (BST) Received: from [10.0.1.1] (daikon.calivar.com [10.0.1.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.calivar.com (Postfix) with ESMTPSA id 6C40D41FB8 for ; Fri, 27 May 2016 17:26:31 +0100 (BST) To: ecos-discuss@ecos.sourceware.org References: <07FFDDED6CBCCE4E9FBD46AEC3EBFD4F02C50652@exchange> From: Nick Garnett Message-ID: <57487536.4090201@calivar.com> Date: Fri, 27 May 2016 16:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <07FFDDED6CBCCE4E9FBD46AEC3EBFD4F02C50652@exchange> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Subject: Re: [ECOS] cyg_flag_timed_wait doesn't seem to work as expected X-SW-Source: 2016-05/txt/msg00002.txt.bz2 On 27/05/16 14:30, Michael W. Ellis wrote: > I'm running an old version of eCos (2.0.98) from eCosCentric and I'm > attempting to use cyg_flag_timed_wait to periodically update a > display (see code, below). My event flag variable g_flags is > initialized elsewhere before this thread is created. Other threads > access the same event flag but use their own bits within the flag. > > My problem is with the timed wait behavior of the event flag. At > startup I see an initial wait of 30 seconds before the first display > update occurs, but the update occurs continually after the initial > timeout. The local variable flags always reads 0, indicating timeout > has occurred. My understanding is that calling cyg_flag_timed_wait > at the top of the loop restarts the timer, but this does not seem to > be the case. What am I missing here? Is there something I must do > to clear the timeout event? > The problem is your use of 3000 for the timeout. In eCos, timeouts give the wakeup time, not the duration. So, the first call waits until tick 3000, but the rest return immediately since it is now past 3000. The solution is to use cyg_current_time()+3000 in the timeout argument. -- Nick Garnett Kernel Architect eCosCentric Limited http://www.eCosCentric.com The eCos experts Barnwell House, Barnwell Drive, Cambridge, UK. +44 1223 245571 Registered in England and Wales: Reg No: 4422071 -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss