From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Victor Alvidrez <v.alvidrez@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Question about the TSC and how it is used by Xenomai.
Date: Fri, 04 Nov 2011 15:07:11 +0100 [thread overview]
Message-ID: <4EB3F18F.5080805@domain.hid> (raw)
In-Reply-To: <4EB32945.6090001@domain.hid>
On 11/04/2011 12:52 AM, Victor Alvidrez wrote:
> I have been doing a lot of research regarding time and how it is
> measured in Linux.
>
> The book "Understanding the Linux Kernel" by Bovet and Cesati was
> essential in figuring out how time is handled at the kernel level.
>
> Here is what I gather so far (that is relevant to my question):
>
> The RTC is used by the system to initialize the 'struct timeval xtime'
> variable with a UTC time. After this occurs the PIT is programmed so
> that it issues timer interrupts at a fixed frequency. The book states
> that this defines a 'tick'. At each tick occurrence, a interrupt is
> triggered and is handled by the TIMER_BH handler. This handler adds
> 1/HZ microseconds to the 'xtime.tv_usec' value (where HZ is the kernel
> configuration value). If NTP is being used, the adjtimex() function
> adjusts the 1/HZ value to slowly synchronize the time with a reference
> time.
This understanding is outdated. Search for "high resolution timers" and
"dynamic ticks" for a more current understanding.
>
> My issue is in understanding how the TSC (timer stamp counter register)
> is used. I know that this register counts the number of clock ticks. I
> am pretty sure that clock ticks refer to ticks produced by the CPU
> clock, which runs at completely different frequency than HZ.
>
> This is where my confusion with Xenomai comes in. The native skin lets
> me set the timer mode to be oneshot using TM_ONESHOT so that timer ticks
> are in nanoseconds and so that the timer is rescheduled every tick (not
> sure if rescheduled is the right word here). This explanation makes me
> think that 'timer' refers to the PIT?
the timer (usually the APIC, but it can be the PIT on very old
processors) is programmed to tick at the next timer event. The TSC is
used as a clock source, all the time keeping is done using the TSC unit,
durations are converted to the timer frequency when programming the timer.
>
> However, the native skin lets me set intervals (for alarms/timers) down
> to nanoseconds. How can this be accomplished if the HZ value only goes
> up to 1000 in the kernel configuration? Somehow I think the TSC must be
> used separately, independent of the PIT?
>
> I realize this isn't really a Xenomai programming issue, but I thought I
> would go ahead and ask to see if you could provide some help.
Xenomai does not use HZ, it uses a timer (either APIC, or PIT) in
one-shot mode, it means programming it to tick only for the next event.
Using the TSC as clock source is a completely different issue and has
nothing to do with the timer chosen. The difference in frequencies only
cause a conversion between the two.
>
> Thanks
>
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
>
--
Gilles.
prev parent reply other threads:[~2011-11-04 14:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-03 23:52 [Xenomai-help] Question about the TSC and how it is used by Xenomai Victor Alvidrez
2011-11-04 14:07 ` Gilles Chanteperdrix [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EB3F18F.5080805@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=v.alvidrez@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.