From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12433 invoked by alias); 27 Jun 2011 15:14:16 -0000 Received: (qmail 12122 invoked by uid 22791); 27 Jun 2011 15:14:14 -0000 X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_00,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,SPF_HELO_PASS,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from lo.gmane.org (HELO lo.gmane.org) (80.91.229.12) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Jun 2011 15:14:01 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QbDVf-0003Iq-Cc for ecos-discuss@sources.redhat.com; Mon, 27 Jun 2011 17:13:59 +0200 Received: from dsl.comtrol.com ([64.122.56.22]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Jun 2011 17:13:59 +0200 Received: from grant.b.edwards by dsl.comtrol.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Jun 2011 17:13:59 +0200 To: ecos-discuss@sources.redhat.com From: Grant Edwards Date: Mon, 27 Jun 2011 15:14:00 -0000 Message-ID: References: <4E07AFED.6040405@meduna.org> <4E08983A.5090407@meduna.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: slrn/pre0.9.9-102 (Linux) 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: [ECOS] Re: Adjustable wallclock (get/settimeofday, adjtimex)? X-SW-Source: 2011-06/txt/msg00072.txt.bz2 On 2011-06-27, Stanislav Meduna wrote: > On 27.06.2011 16:16, Grant Edwards wrote: > >> When I needed to adjust the time to keep it in sync with a real-time >> clock, I did it at a lower level by adding hooks into the target's HAL >> code that allowed me to gradually slew the cyg_current_time() value by >> adjusting the length of a system tick by small amounts. > > Could you elaborate a bit? Did you change the hardware's interrupt > frequency? Yes. > This would be the best solution, but it depends on how easy the > frequency can be adjusted without disturbing the current running > interval, if at all (e.g. on some hardware the counter reload value > can't be accessed atomically and hitting the wrong values at wrong > time could produce unacceptable clock interrupt jitter). In my case, I was able to change the system tick timer reload value without causing problems. That might be difficult to do on some hardware. For example, you might have to do one (or both) of a couple different "tricks": 1) Stop the timer, change the reload value, then restart the timer with a new value that takes into account the time it was stopped. 2) Check the timer to make sure it's not about to reload. If it's not about to reload, change the reload value. If it is about to reload, wait a bit and try again later. Both of these generally need to be done with interrupts disabled, and are probably best done in assembly language. -- Grant Edwards grant.b.edwards Yow! Where's SANDY DUNCAN? at gmail.com -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss