WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] xen PIT timer

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] xen PIT timer
From: Ryan Harper <ryanh@xxxxxxxxxx>
Date: Fri, 23 Sep 2005 14:49:07 -0500
Delivery-date: Fri, 23 Sep 2005 19:47:01 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6+20040907i
Still looking at bug #195 which shows up occasionally  upon boot, and
now, I can recreate by generating a lot of traffic over the serial line
into Xen (holding down 'r' to print the run queues).  

I started comparing how Xen sets up and calibrates the timers with
Linux and have a few questions where they differ.

In Linux, the i386 and x86_64 set up the pit timer using 
binary, mode 2, LSB/MSB, ch 0, and then periodically read PIT_CH0 to
obtain a count.  Linux also uses PIT CH2 to do some calibration.

Xen, in xen/arch/x86/i8259.c sets up the PIT in the same manner (binary,
mode 2, LSB/MSB, ch 0)  but as far as I can see, PIT_CH0 is never used
again, specifically, PIT_CH0 is not used when handling a timer
interrupt.  

Instead, in xen/arch/x86/time.c, when Xen uses PIT as the platform timer,
it runs pit_read_counter() which gets a count from PIT_CH2, which was
used during calibrate_boot_tsc() but in mode 0.

I don't fully understand the different modes of the PIT, but looking at
the some intel [1]documentation I see:

    MODE 0: INTERRUPT ON TERMINAL COUNT
    Mode 0 is typically used for event counting After the Control Word
    is written OUT is initially low and will remain low until the
    Counter reaches zero OUT then goes high and remains high until a new
    count or a new Mode 0 Control Word is written into the Counter 

    MODE 2 RATE GENERATOR 
    This Mode functions like a divide-by-N counter It is typicially used
    to generate a Real Time Clock interrupt OUT will initially be high
    When the initial count has decremented to 1 OUT goes low for one CLK
    pulse OUT then goes high again the Counter reloads the initial count
    and the process is repeated Mode 2 is periodic the same sequence is
    repeated indefinitely For an initial count of N the sequence repeats
    every N CLK cycles 

Why does Xen chose to use mode 0, on PIT CH2 for calculating how much
time has passed rather than how Linux using PIT_CH0 in mode 2?  Are
there some trade offs?

1. http://www.cs.utexas.edu/users/dahlin/Classes/UGOS/reading/82C54.pdf

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@xxxxxxxxxx

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>