All of lore.kernel.org
 help / color / mirror / Atom feed
From: Victor Alvidrez <v.alvidrez@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-help] Question about the TSC and how it is used by Xenomai.
Date: Thu, 03 Nov 2011 17:52:37 -0600	[thread overview]
Message-ID: <4EB32945.6090001@domain.hid> (raw)

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.

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?

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.

Thanks


             reply	other threads:[~2011-11-03 23:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-03 23:52 Victor Alvidrez [this message]
2011-11-04 14:07 ` [Xenomai-help] Question about the TSC and how it is used by Xenomai Gilles Chanteperdrix

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=4EB32945.6090001@domain.hid \
    --to=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.