Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

6 May, 2024: The networking issue during the past two days has been identified and appears to be fixed. Will keep monitoring.


devel / comp.arch / Re: Precision timers

SubjectAuthor
* Precision timersrobf...@gmail.com
+- Re: Precision timersTerje Mathisen
+* Re: Precision timersMitchAlsup
|`- Re: Precision timersEricP
+* Re: Precision timersEricP
|+* Re: Precision timersrobf...@gmail.com
||+- Re: Precision timersMitchAlsup
||`- Re: Precision timersEricP
|`- Re: Precision timersMichael S
`* Re: Precision timersStephen Fuld
 `* Re: Precision timersMitchAlsup
  `* Re: Precision timersrobf...@gmail.com
   `* Re: Precision timersThomas Koenig
    `* Re: Precision timersEricP
     `* Re: Precision timersMitchAlsup
      +* Re: Precision timersEricP
      |`* Re: Precision timersMitchAlsup
      | `- Re: Precision timersEricP
      `* Re: Precision timersTerje Mathisen
       +* Re: Precision timersStephen Fuld
       |`- Re: Precision timersTerje Mathisen
       +* Re: Precision timersrobf...@gmail.com
       |+- Re: Precision timersStephen Fuld
       |+- Re: Precision timersEricP
       |`- Re: Precision timersTerje Mathisen
       `* Re: Precision timersEricP
        +* Re: Precision timersStefan Monnier
        |`- Re: Precision timersMitchAlsup
        +* Re: Precision timersMitchAlsup
        |`- Re: Precision timersMichael S
        `* Re: Precision timersTerje Mathisen
         `* Re: Precision timersMichael S
          +* Re: Precision timersTerje Mathisen
          |`* Re: Precision timersMichael S
          | `- Re: Precision timersTerje Mathisen
          `* Re: Precision timersMitchAlsup
           `* Re: Precision timersrobf...@gmail.com
            +- Re: Precision timersMitchAlsup
            `* Re: Precision timersScott Lurndal
             `* Re: Precision timersrobf...@gmail.com
              `- Re: Precision timersrobf...@gmail.com

Pages:12
Re: Precision timers

<3e33280c-6877-4837-b961-c114f965e083n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27393&group=comp.arch#27393

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:c88:b0:496:b2ee:370a with SMTP id r8-20020a0562140c8800b00496b2ee370amr4437650qvr.66.1660859259680;
Thu, 18 Aug 2022 14:47:39 -0700 (PDT)
X-Received: by 2002:a05:620a:2728:b0:6ba:e857:9375 with SMTP id
b40-20020a05620a272800b006bae8579375mr3539339qkp.728.1660859259526; Thu, 18
Aug 2022 14:47:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Thu, 18 Aug 2022 14:47:39 -0700 (PDT)
In-Reply-To: <TQvLK.163392$%i2.22546@fx48.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:a912:3a48:1ebc:2842;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:a912:3a48:1ebc:2842
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me> <253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com> <tdifiv$tkh$3@newsreader4.netcologne.de>
<wJ6LK.734298$5fVf.97913@fx09.iad> <54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3e33280c-6877-4837-b961-c114f965e083n@googlegroups.com>
Subject: Re: Precision timers
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 18 Aug 2022 21:47:39 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 40
 by: MitchAlsup - Thu, 18 Aug 2022 21:47 UTC

On Thursday, August 18, 2022 at 1:49:27 PM UTC-5, EricP wrote:
> Terje Mathisen wrote:
> >
> > diff = next_event_count - current_tick_count;
> > if ((signed) diff <= 0) fire();
> Unlike the system clock, the period counter resets to zero at boot.
<
> With a 1 ns tick a 64 bit counter wraps after 584 years of
> continuous up-time so it wouldn't need any extra handling.
<
At least the person who turned the system on won't have to listen
to the complaints of bad-SW when the timer does roll over.
>
> However if the counter or trigger is smaller, say 32 or 48 bits,
> or the ticks smaller, say 1 ps, then the counter wrap generates
> an interrupt that increments an epoch number in memory.
<
So, in effect, you are arguing that the timer resolution should
be better than 1ns and worse than 1ps. 1ps rolls a 64-bit counter
over every ½ year, 10ps every 5.8 years, 100 ps every 58 years.
>
> >
> The original spec also had design options like whether the counter
> or comparators were 32 or 64 bits, and if 64 bits are they read and
> written atomically or as two separate 32 bit values.
<
In this day and age, why would anyone want something smaller than
a 64-bit counter ???
<
> Software had to take all these variations into account.
>
> One of the interactions the Linux folks seemed concerned
> about is that an interrupt is generated when the counter wraps,
> and this can interact with power state management.
> A 32 bit counter with 1 ns resolution tick would overflow every
> 4 seconds and wake up the processor out of power down.
> Another reason to require 64 bit timer components.
<
I repeat::
In this day and age, why would anyone want something smaller than
a 64-bit counter ???

Re: Precision timers

<65997cab-b0ae-417e-8d99-068b29ba75d6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27394&group=comp.arch#27394

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:f13:b0:6b5:b956:c1f1 with SMTP id v19-20020a05620a0f1300b006b5b956c1f1mr3642232qkl.691.1660859319403;
Thu, 18 Aug 2022 14:48:39 -0700 (PDT)
X-Received: by 2002:a05:620a:2181:b0:6bb:50a1:222e with SMTP id
g1-20020a05620a218100b006bb50a1222emr3632463qka.151.1660859319255; Thu, 18
Aug 2022 14:48:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Thu, 18 Aug 2022 14:48:39 -0700 (PDT)
In-Reply-To: <jwva6815pjl.fsf-monnier+comp.arch@gnu.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:a912:3a48:1ebc:2842;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:a912:3a48:1ebc:2842
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me> <253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com> <tdifiv$tkh$3@newsreader4.netcologne.de>
<wJ6LK.734298$5fVf.97913@fx09.iad> <54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad> <jwva6815pjl.fsf-monnier+comp.arch@gnu.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <65997cab-b0ae-417e-8d99-068b29ba75d6n@googlegroups.com>
Subject: Re: Precision timers
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 18 Aug 2022 21:48:39 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 10
 by: MitchAlsup - Thu, 18 Aug 2022 21:48 UTC

On Thursday, August 18, 2022 at 2:19:12 PM UTC-5, Stefan Monnier wrote:
> > However if the counter or trigger is smaller, say 32 or 48 bits,
> > or the ticks smaller, say 1 ps, then the counter wrap generates
> > an interrupt that increments an epoch number in memory.
> You'll want to make sure this epoch-interrupt is triggered often enough
> to be tested sufficiently to be reliable.
<
Initialize the counter value so that it rolls over within the current day.
>
>
> Stefan

Re: Precision timers

<tdna6h$1vde$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27400&group=comp.arch#27400

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!10O9MudpjwoXIahOJRbDvA.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Precision timers
Date: Fri, 19 Aug 2022 08:22:13 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tdna6h$1vde$1@gioia.aioe.org>
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me>
<253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com>
<tdifiv$tkh$3@newsreader4.netcologne.de> <wJ6LK.734298$5fVf.97913@fx09.iad>
<54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <tdlmtf$1347f$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="64942"; posting-host="10O9MudpjwoXIahOJRbDvA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.13
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 19 Aug 2022 06:22 UTC

Stephen Fuld wrote:
> On 8/18/2022 12:18 AM, Terje Mathisen wrote:
>> MitchAlsup wrote:
>>> On Wednesday, August 17, 2022 at 9:14:55 AM UTC-5, EricP wrote:
>>>> Thomas Koenig wrote:
>>>>> robf...@gmail.com <robf...@gmail.com> schrieb:
>>>>>
>>>>>> 30+ comparators per core (300 comparators?) might allow every
>>>>>> process to have its own comparator. Which would not need to be
>>>>>> managed by the OS.
>>>>>
>>>>> Hmm... do you want to restrict the core to 300 processes? Hard
>>>>> limits have a habit of coming around and biting the user when it
>>>>> least expected (for example when an attacker or a buggy process
>>>>> does a few forks() and uses up all of them).
>>>>>
>>>>> And you would need the OS anyway to schedule access to them so
>>>>> so it is guaranteed that no two processes use the same timer.
>>> <
>>>> You don't need to dedicate a high resolution timer to a process.
>>>> That wouldn't do much good as processes can have many timers
>>>> and software within a single process won't know about other timers.
>>>>
>>>> Each one-shot HW hr-comparator manages a queue of requests.
>>> <
>>> Yes, obviously...
>>> <
>>>> The queue can be a linked list or binary tree in ascending order
>>>> of absolute timeout hr-tick time. The earliest timeout timestamp
>>>> is written into the trigger register, or 0 to disable the trigger
>>>> if the queue is empty.
>>> <
>>> What does SW do in managing this list of event-times when one
>>> event fires, and the next event is 1 tick farther down in time ?
>>> It seems to me that the only way for SW to manage such a queue
>>> would be to have large timer-quanta.
>>
>> I think that there are only two ways it can work:
>>
>> a) Make the comparator >= so that when the next value is written, it
>> immediately causes a timeout since the tick count has passed. This
>> does require that comparator to separate between a recent rollower and
>> a long time to go, typically using 2^63 as the boundary:
>>
>>  Â  diff = next_event_count - current_tick_count;
>>  Â  if ((signed) diff <= 0) fire();
>>
>> b) Do the same in SW with a polled approach:
>>
>> When a event count triggers, the handler dispatches it, then grabs the
>> next count in the queue and inserts it before immediately reading the
>> current count to check if the time has already passed, if so, handle
>> it and repeat. The big problem here is of course that there will
>> always be a tiny window between writing the next comparator value and
>> reading the current count to check for an overrun. Fixing that adds a
>> lot of hair, you either need the (HW) ability to get the current count
>> at the same time as you write the comparator, or some kind of status
>> register to report on any currently pending timeout.
>>
>> It is very easy to see why the hw people would prefer a plain ==
>> comparator, but it does lead to even more issues in software. :-(
>
> I have seen timers that append a few bit field to the timer.  This field
> is returned as the low end of the value when one reads the timer.  The
> contents of this field are incremented each time the timer is read, and
> reset to zero each time the timer ticks.  The result guarantees a unique
> value returned, but does give a value where the bits below the specified
> minimum accuracy of the timer may not be accurate.
>
> For example, suppose you have a timer granularity of 1ns, and four bits
> in the new field.  Someone reading the timer would see a value specified
> in 16ths of a ns, but only the bits at or above 1 ns would be accurate.
> Thus someone reading the counter will usually get an accurate value (the
> extra bits zero), but occasionally it will be off by a small number of
> 16ths of a nanosecond.
>
> I thought this was an interesting tradeoff.

Very interesting, and possibly cheaper than just having a timer which
increments at least as fast as it can be read. I.e. RDTSC these days
gets you a cpu-fixed "base frequency" somewhere in the 2-5 GHz region,
but it takes multiple ns to read it. Here the issue is more related to
keeping that timer in sync across all the cores and possibly also across
cpus on a system with several.

A common bus-level counter typically incurs far more latency than RDTSC
and similar on-chip counters.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Precision timers

<tdnbcj$bov$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27401&group=comp.arch#27401

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!10O9MudpjwoXIahOJRbDvA.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Precision timers
Date: Fri, 19 Aug 2022 08:42:32 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tdnbcj$bov$1@gioia.aioe.org>
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me>
<253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com>
<tdifiv$tkh$3@newsreader4.netcologne.de> <wJ6LK.734298$5fVf.97913@fx09.iad>
<54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org>
<5a63de4b-cb56-4646-a26f-23283f690b9bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="12063"; posting-host="10O9MudpjwoXIahOJRbDvA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.13
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 19 Aug 2022 06:42 UTC

robf...@gmail.com wrote:
> On Thursday, August 18, 2022 at 3:18:32 AM UTC-4, Terje Mathisen wrote:
>> MitchAlsup wrote:
>>> On Wednesday, August 17, 2022 at 9:14:55 AM UTC-5, EricP wrote:
>>>> Thomas Koenig wrote:
>>>>> robf...@gmail.com <robf...@gmail.com> schrieb:
>>>>>
>>>>>> 30+ comparators per core (300 comparators?) might allow every
>>>>>> process to have its own comparator. Which would not need to be
>>>>>> managed by the OS.
>>>>>
>>>>> Hmm... do you want to restrict the core to 300 processes? Hard
>>>>> limits have a habit of coming around and biting the user when it
>>>>> least expected (for example when an attacker or a buggy process
>>>>> does a few forks() and uses up all of them).
>>>>>
>>>>> And you would need the OS anyway to schedule access to them so
>>>>> so it is guaranteed that no two processes use the same timer.
>
> With enough timers the process ID could be used to determine which
> timer to use, so the OS does not need to schedule one. There are only
> about 250 process running on my Windows machine (3,000 threads).
> I think a timer component is not very large so there could be a lot of
> them.
>
>>> <
>>>> You don't need to dedicate a high resolution timer to a process.
>>>> That wouldn't do much good as processes can have many timers
>>>> and software within a single process won't know about other timers.
>>>>
>>>> Each one-shot HW hr-comparator manages a queue of requests.
>>> <
>>> Yes, obviously...
>>> <
>>>> The queue can be a linked list or binary tree in ascending order
>>>> of absolute timeout hr-tick time. The earliest timeout timestamp
>>>> is written into the trigger register, or 0 to disable the trigger
>>>> if the queue is empty.
>>> <
>>> What does SW do in managing this list of event-times when one
>>> event fires, and the next event is 1 tick farther down in time ?
>>> It seems to me that the only way for SW to manage such a queue
>>> would be to have large timer-quanta.
>> I think that there are only two ways it can work:
>>
>> a) Make the comparator >= so that when the next value is written, it
>> immediately causes a timeout since the tick count has passed. This does
>> require that comparator to separate between a recent rollower and a long
>> time to go, typically using 2^63 as the boundary:
>>
>> diff = next_event_count - current_tick_count;
>> if ((signed) diff <= 0) fire();
>>
>> b) Do the same in SW with a polled approach:
>>
>> When a event count triggers, the handler dispatches it, then grabs the
>> next count in the queue and inserts it before immediately reading the
>> current count to check if the time has already passed, if so, handle it
>> and repeat. The big problem here is of course that there will always be
>> a tiny window between writing the next comparator value and reading the
>> current count to check for an overrun. Fixing that adds a lot of hair,
>> you either need the (HW) ability to get the current count at the same
>> time as you write the comparator, or some kind of status register to
>> report on any currently pending timeout.
>>
>> It is very easy to see why the hw people would prefer a plain ==
>> comparator, but it does lead to even more issues in software. :-(
>> Terje
>>
>> --
>> - <Terje.Mathisen at tmsw.no>
>> "almost all programming can be viewed as an exercise in caching"
>
> How about writing the increment amount to the comparator instead
> of the absolute value? The current compare value would not need to be
> read then. The store operation would just automatically add to the current
> count.

That is actually very nice!

It puts all the slow/hard to check logic inside the write path where it
is trivial to determine if the new value will be less than the current
counts, and if so, latch a new interrupt to be triggered immeditely.

This way the on-the-fly trigger can stay a pure == which is of course
significantly less costly than >=.
>
> What about having two comparator types, one for high precision timing
> that works down to ns range and a second type that works on the range
> shifted over a number of bits, eight for example, to give a range of value
> that can be used to time events into the years? And then use a 72-bit
> counter.

I don't think this is needed in HW, it can easily be synthesized by the
driver.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Precision timers

<tdndsh$18u1$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27402&group=comp.arch#27402

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!10O9MudpjwoXIahOJRbDvA.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Precision timers
Date: Fri, 19 Aug 2022 09:25:09 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tdndsh$18u1$1@gioia.aioe.org>
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me>
<253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com>
<tdifiv$tkh$3@newsreader4.netcologne.de> <wJ6LK.734298$5fVf.97913@fx09.iad>
<54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="41921"; posting-host="10O9MudpjwoXIahOJRbDvA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.13
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 19 Aug 2022 07:25 UTC

EricP wrote:
> Terje Mathisen wrote:
>> MitchAlsup wrote:
>>> On Wednesday, August 17, 2022 at 9:14:55 AM UTC-5, EricP wrote:
>>>> Thomas Koenig wrote:
>>>>> robf...@gmail.com <robf...@gmail.com> schrieb:
>>>>>
>>>>>> 30+ comparators per core (300 comparators?) might allow every
>>>>>> process to have its own comparator. Which would not need to be
>>>>>> managed by the OS.
>>>>>
>>>>> Hmm... do you want to restrict the core to 300 processes? Hard
>>>>> limits have a habit of coming around and biting the user when it
>>>>> least expected (for example when an attacker or a buggy process
>>>>> does a few forks() and uses up all of them).
>>>>>
>>>>> And you would need the OS anyway to schedule access to them so
>>>>> so it is guaranteed that no two processes use the same timer.
>>> <
>>>> You don't need to dedicate a high resolution timer to a process.
>>>> That wouldn't do much good as processes can have many timers
>>>> and software within a single process won't know about other timers.
>>>>
>>>> Each one-shot HW hr-comparator manages a queue of requests.
>>> <
>>> Yes, obviously...
>>> <
>>>> The queue can be a linked list or binary tree in ascending order
>>>> of absolute timeout hr-tick time. The earliest timeout timestamp
>>>> is written into the trigger register, or 0 to disable the trigger
>>>> if the queue is empty.
>>> <
>>> What does SW do in managing this list of event-times when one
>>> event fires, and the next event is 1 tick farther down in time ?
>>> It seems to me that the only way for SW to manage such a queue
>>> would be to have large timer-quanta.
>>
>> I think that there are only two ways it can work:
>>
>> a) Make the comparator >= so that when the next value is written, it
>> immediately causes a timeout since the tick count has passed. This
>> does require that comparator to separate between a recent rollower and
>> a long time to go, typically using 2^63 as the boundary:
>>
>>   diff = next_event_count - current_tick_count;
>>   if ((signed) diff <= 0) fire();
>
> Unlike the system clock, the period counter resets to zero at boot.
> With a 1 ns tick a 64 bit counter wraps after 584 years of
> continuous up-time so it wouldn't need any extra handling.

that is a very good, and probably sufficient, reason for making such a
counter 64-bit only. If you need the ability to work in a 32-bit
environment, then reading or writing the lower 32 bits would have to
latch the upper part as well, holding it until the next instruction is done.
>
> However if the counter or trigger is smaller, say 32 or 48 bits,
> or the ticks smaller, say 1 ps, then the counter wrap generates
> an interrupt that increments an epoch number in memory.
>
> The trigger register for the youngest timer at the head of the queue
> is only set when the current epoch number >= that timers' epoch.
> Otherwise the trigger is disabled.

OK.

>
>> b) Do the same in SW with a polled approach:
>>
>> When a event count triggers, the handler dispatches it, then grabs the
>> next count in the queue and inserts it before immediately reading the
>> current count to check if the time has already passed, if so, handle
>> it and repeat. The big problem here is of course that there will
>> always be a tiny window between writing the next comparator value and
>> reading the current count to check for an overrun. Fixing that adds a
>> lot of hair, you either need the (HW) ability to get the current count
>> at the same time as you write the comparator, or some kind of status
>> register to report on any currently pending timeout.
>>
>> It is very easy to see why the hw people would prefer a plain ==
>> comparator, but it does lead to even more issues in software. :-(
>
> The original spec also had design options like whether the counter
> or comparators were 32 or 64 bits, and if 64 bits are they read and
> written atomically or as two separate 32 bit values.
> Software had to take all these variations into account.
>
> One of the interactions the Linux folks seemed concerned
> about is that an interrupt is generated when the counter wraps,
> and this can interact with power state management.
> A 32 bit counter with 1 ns resolution tick would overflow every
> 4 seconds and wake up the processor out of power down.
> Another reason to require 64 bit timer components.

I agree 100%.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Precision timers

<c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27404&group=comp.arch#27404

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a0c:b203:0:b0:496:1420:7a78 with SMTP id x3-20020a0cb203000000b0049614207a78mr5533375qvd.57.1660903569488;
Fri, 19 Aug 2022 03:06:09 -0700 (PDT)
X-Received: by 2002:a05:6214:262f:b0:477:734:3177 with SMTP id
gv15-20020a056214262f00b0047707343177mr5793675qvb.67.1660903569252; Fri, 19
Aug 2022 03:06:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 19 Aug 2022 03:06:09 -0700 (PDT)
In-Reply-To: <tdndsh$18u1$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:65dd:bb7:48b5:b678;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:65dd:bb7:48b5:b678
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me> <253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com> <tdifiv$tkh$3@newsreader4.netcologne.de>
<wJ6LK.734298$5fVf.97913@fx09.iad> <54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad> <tdndsh$18u1$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com>
Subject: Re: Precision timers
From: already5...@yahoo.com (Michael S)
Injection-Date: Fri, 19 Aug 2022 10:06:09 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 7008
 by: Michael S - Fri, 19 Aug 2022 10:06 UTC

On Friday, August 19, 2022 at 10:25:13 AM UTC+3, Terje Mathisen wrote:
> EricP wrote:
> > Terje Mathisen wrote:
> >> MitchAlsup wrote:
> >>> On Wednesday, August 17, 2022 at 9:14:55 AM UTC-5, EricP wrote:
> >>>> Thomas Koenig wrote:
> >>>>> robf...@gmail.com <robf...@gmail.com> schrieb:
> >>>>>
> >>>>>> 30+ comparators per core (300 comparators?) might allow every
> >>>>>> process to have its own comparator. Which would not need to be
> >>>>>> managed by the OS.
> >>>>>
> >>>>> Hmm... do you want to restrict the core to 300 processes? Hard
> >>>>> limits have a habit of coming around and biting the user when it
> >>>>> least expected (for example when an attacker or a buggy process
> >>>>> does a few forks() and uses up all of them).
> >>>>>
> >>>>> And you would need the OS anyway to schedule access to them so
> >>>>> so it is guaranteed that no two processes use the same timer.
> >>> <
> >>>> You don't need to dedicate a high resolution timer to a process.
> >>>> That wouldn't do much good as processes can have many timers
> >>>> and software within a single process won't know about other timers.
> >>>>
> >>>> Each one-shot HW hr-comparator manages a queue of requests.
> >>> <
> >>> Yes, obviously...
> >>> <
> >>>> The queue can be a linked list or binary tree in ascending order
> >>>> of absolute timeout hr-tick time. The earliest timeout timestamp
> >>>> is written into the trigger register, or 0 to disable the trigger
> >>>> if the queue is empty.
> >>> <
> >>> What does SW do in managing this list of event-times when one
> >>> event fires, and the next event is 1 tick farther down in time ?
> >>> It seems to me that the only way for SW to manage such a queue
> >>> would be to have large timer-quanta.
> >>
> >> I think that there are only two ways it can work:
> >>
> >> a) Make the comparator >= so that when the next value is written, it
> >> immediately causes a timeout since the tick count has passed. This
> >> does require that comparator to separate between a recent rollower and
> >> a long time to go, typically using 2^63 as the boundary:
> >>
> >> diff = next_event_count - current_tick_count;
> >> if ((signed) diff <= 0) fire();
> >
> > Unlike the system clock, the period counter resets to zero at boot.
> > With a 1 ns tick a 64 bit counter wraps after 584 years of
> > continuous up-time so it wouldn't need any extra handling.
> that is a very good, and probably sufficient, reason for making such a
> counter 64-bit only. If you need the ability to work in a 32-bit
> environment, then reading or writing the lower 32 bits would have to
> latch the upper part as well, holding it until the next instruction is done.

If we want reading from user process, which we likely do, then your
suggestion sound dangerous. I don't want to start to think what
happens if task switch hits between two halves of read. May be,
nothing wrong, but proving it causes headaches.

I see nothing particularly wrong with reading pair of registers in loop
hi = ReadHi()
lo = ReadLo()
while ((repHi = readHi()) != hi) {
lo = ReadLo()
hi = repHi
}

It's just a little slower, but painless.

Or, if you insist on reading lower half first:
lo = ReadLo()
hi = ReadHi()
while ((repLo = readLo()) < lo) {
hi = ReadHi()
lo = repLo
}

> >
> > However if the counter or trigger is smaller, say 32 or 48 bits,
> > or the ticks smaller, say 1 ps, then the counter wrap generates
> > an interrupt that increments an epoch number in memory.
> >
> > The trigger register for the youngest timer at the head of the queue
> > is only set when the current epoch number >= that timers' epoch.
> > Otherwise the trigger is disabled.
> OK.
> >
> >> b) Do the same in SW with a polled approach:
> >>
> >> When a event count triggers, the handler dispatches it, then grabs the
> >> next count in the queue and inserts it before immediately reading the
> >> current count to check if the time has already passed, if so, handle
> >> it and repeat. The big problem here is of course that there will
> >> always be a tiny window between writing the next comparator value and
> >> reading the current count to check for an overrun. Fixing that adds a
> >> lot of hair, you either need the (HW) ability to get the current count
> >> at the same time as you write the comparator, or some kind of status
> >> register to report on any currently pending timeout.
> >>
> >> It is very easy to see why the hw people would prefer a plain ==
> >> comparator, but it does lead to even more issues in software. :-(
> >
> > The original spec also had design options like whether the counter
> > or comparators were 32 or 64 bits, and if 64 bits are they read and
> > written atomically or as two separate 32 bit values.
> > Software had to take all these variations into account.
> >
> > One of the interactions the Linux folks seemed concerned
> > about is that an interrupt is generated when the counter wraps,
> > and this can interact with power state management.
> > A 32 bit counter with 1 ns resolution tick would overflow every
> > 4 seconds and wake up the processor out of power down.
> > Another reason to require 64 bit timer components.
> I agree 100%.
> Terje
>
> --
> - <Terje.Mathisen at tmsw.no>
> "almost all programming can be viewed as an exercise in caching"

Re: Precision timers

<tdnp5f$1sq7$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27406&group=comp.arch#27406

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!10O9MudpjwoXIahOJRbDvA.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Precision timers
Date: Fri, 19 Aug 2022 12:37:40 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tdnp5f$1sq7$1@gioia.aioe.org>
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me>
<253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com>
<tdifiv$tkh$3@newsreader4.netcologne.de> <wJ6LK.734298$5fVf.97913@fx09.iad>
<54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad>
<tdndsh$18u1$1@gioia.aioe.org>
<c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62279"; posting-host="10O9MudpjwoXIahOJRbDvA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.13
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 19 Aug 2022 10:37 UTC

Michael S wrote:
> On Friday, August 19, 2022 at 10:25:13 AM UTC+3, Terje Mathisen wrote:
>> EricP wrote:
>>> Terje Mathisen wrote:
>>>> MitchAlsup wrote:
>>>>> On Wednesday, August 17, 2022 at 9:14:55 AM UTC-5, EricP wrote:
>>>>>> Thomas Koenig wrote:
>>>>>>> robf...@gmail.com <robf...@gmail.com> schrieb:
>>>>>>>
>>>>>>>> 30+ comparators per core (300 comparators?) might allow every
>>>>>>>> process to have its own comparator. Which would not need to be
>>>>>>>> managed by the OS.
>>>>>>>
>>>>>>> Hmm... do you want to restrict the core to 300 processes? Hard
>>>>>>> limits have a habit of coming around and biting the user when it
>>>>>>> least expected (for example when an attacker or a buggy process
>>>>>>> does a few forks() and uses up all of them).
>>>>>>>
>>>>>>> And you would need the OS anyway to schedule access to them so
>>>>>>> so it is guaranteed that no two processes use the same timer.
>>>>> <
>>>>>> You don't need to dedicate a high resolution timer to a process.
>>>>>> That wouldn't do much good as processes can have many timers
>>>>>> and software within a single process won't know about other timers.
>>>>>>
>>>>>> Each one-shot HW hr-comparator manages a queue of requests.
>>>>> <
>>>>> Yes, obviously...
>>>>> <
>>>>>> The queue can be a linked list or binary tree in ascending order
>>>>>> of absolute timeout hr-tick time. The earliest timeout timestamp
>>>>>> is written into the trigger register, or 0 to disable the trigger
>>>>>> if the queue is empty.
>>>>> <
>>>>> What does SW do in managing this list of event-times when one
>>>>> event fires, and the next event is 1 tick farther down in time ?
>>>>> It seems to me that the only way for SW to manage such a queue
>>>>> would be to have large timer-quanta.
>>>>
>>>> I think that there are only two ways it can work:
>>>>
>>>> a) Make the comparator >= so that when the next value is written, it
>>>> immediately causes a timeout since the tick count has passed. This
>>>> does require that comparator to separate between a recent rollower and
>>>> a long time to go, typically using 2^63 as the boundary:
>>>>
>>>> diff = next_event_count - current_tick_count;
>>>> if ((signed) diff <= 0) fire();
>>>
>>> Unlike the system clock, the period counter resets to zero at boot.
>>> With a 1 ns tick a 64 bit counter wraps after 584 years of
>>> continuous up-time so it wouldn't need any extra handling.
>> that is a very good, and probably sufficient, reason for making such a
>> counter 64-bit only. If you need the ability to work in a 32-bit
>> environment, then reading or writing the lower 32 bits would have to
>> latch the upper part as well, holding it until the next instruction is done.
>
> If we want reading from user process, which we likely do, then your
> suggestion sound dangerous. I don't want to start to think what
> happens if task switch hits between two halves of read. May be,
> nothing wrong, but proving it causes headaches.
>
> I see nothing particularly wrong with reading pair of registers in loop
> hi = ReadHi()
> lo = ReadLo()
> while ((repHi = readHi()) != hi) {
> lo = ReadLo()
> hi = repHi
> }
>
> It's just a little slower, but painless.
>
> Or, if you insist on reading lower half first:
> lo = ReadLo()
> hi = ReadHi()
> while ((repLo = readLo()) < lo) {
> hi = ReadHi()
> lo = repLo
> }

We've discussed this a few years ago, you can even do it when the HW
always require you to read both halves, i.e.

prelo = ReadLo();
prehi = ReadHi();
do {
lo = ReadLo();
hi = ReadHi();
} while (hi != prehi);

You suffer the latency of two full reads and then you have odds of
approx 2^-32 of having to repeat the loop one more time.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Precision timers

<1e62dab7-2aed-456f-b86b-f61e4404068dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27407&group=comp.arch#27407

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:daf:b0:476:49c7:af8 with SMTP id h15-20020a0562140daf00b0047649c70af8mr5613501qvh.40.1660905798397;
Fri, 19 Aug 2022 03:43:18 -0700 (PDT)
X-Received: by 2002:a05:620a:4482:b0:6bb:c315:9597 with SMTP id
x2-20020a05620a448200b006bbc3159597mr3749055qkp.423.1660905798245; Fri, 19
Aug 2022 03:43:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 19 Aug 2022 03:43:18 -0700 (PDT)
In-Reply-To: <3e33280c-6877-4837-b961-c114f965e083n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:65dd:bb7:48b5:b678;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:65dd:bb7:48b5:b678
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me> <253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com> <tdifiv$tkh$3@newsreader4.netcologne.de>
<wJ6LK.734298$5fVf.97913@fx09.iad> <54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad> <3e33280c-6877-4837-b961-c114f965e083n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1e62dab7-2aed-456f-b86b-f61e4404068dn@googlegroups.com>
Subject: Re: Precision timers
From: already5...@yahoo.com (Michael S)
Injection-Date: Fri, 19 Aug 2022 10:43:18 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3896
 by: Michael S - Fri, 19 Aug 2022 10:43 UTC

On Friday, August 19, 2022 at 12:47:40 AM UTC+3, MitchAlsup wrote:
> On Thursday, August 18, 2022 at 1:49:27 PM UTC-5, EricP wrote:
> > Terje Mathisen wrote:
> > >
> > > diff = next_event_count - current_tick_count;
> > > if ((signed) diff <= 0) fire();
> > Unlike the system clock, the period counter resets to zero at boot.
> <
> > With a 1 ns tick a 64 bit counter wraps after 584 years of
> > continuous up-time so it wouldn't need any extra handling.
> <
> At least the person who turned the system on won't have to listen
> to the complaints of bad-SW when the timer does roll over.
> >
> > However if the counter or trigger is smaller, say 32 or 48 bits,
> > or the ticks smaller, say 1 ps, then the counter wrap generates
> > an interrupt that increments an epoch number in memory.
> <
> So, in effect, you are arguing that the timer resolution should
> be better than 1ns and worse than 1ps. 1ps rolls a 64-bit counter
> over every ½ year, 10ps every 5.8 years, 100 ps every 58 years.
> >
> > >
> > The original spec also had design options like whether the counter
> > or comparators were 32 or 64 bits, and if 64 bits are they read and
> > written atomically or as two separate 32 bit values.
> <
> In this day and age, why would anyone want something smaller than
> a 64-bit counter ???
> <
> > Software had to take all these variations into account.
> >
> > One of the interactions the Linux folks seemed concerned
> > about is that an interrupt is generated when the counter wraps,
> > and this can interact with power state management.
> > A 32 bit counter with 1 ns resolution tick would overflow every
> > 4 seconds and wake up the processor out of power down.
> > Another reason to require 64 bit timer components.
> <
> I repeat::
> In this day and age, why would anyone want something smaller than
> a 64-bit counter ???

That's a good question :(

As a matter of fact, a 32-bit MCU that I was working on in recent weeks
(fixing obscure bug left here by former employee) has 14 timers. Only
2 of them are 32-bit. The rest is 16 bit.

Another bit of trivia - in ARMv7M architecture SysTick timer is 24-bit.

Re: Precision timers

<3bdb7858-8e9f-4cf7-8620-9781ccb4433cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27408&group=comp.arch#27408

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:622a:15ce:b0:343:6a12:39c with SMTP id d14-20020a05622a15ce00b003436a12039cmr5888309qty.676.1660906822568;
Fri, 19 Aug 2022 04:00:22 -0700 (PDT)
X-Received: by 2002:a05:6214:29c7:b0:496:c413:9229 with SMTP id
gh7-20020a05621429c700b00496c4139229mr2100706qvb.127.1660906822383; Fri, 19
Aug 2022 04:00:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 19 Aug 2022 04:00:22 -0700 (PDT)
In-Reply-To: <tdnp5f$1sq7$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:65dd:bb7:48b5:b678;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:65dd:bb7:48b5:b678
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me> <253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com> <tdifiv$tkh$3@newsreader4.netcologne.de>
<wJ6LK.734298$5fVf.97913@fx09.iad> <54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad>
<tdndsh$18u1$1@gioia.aioe.org> <c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com>
<tdnp5f$1sq7$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3bdb7858-8e9f-4cf7-8620-9781ccb4433cn@googlegroups.com>
Subject: Re: Precision timers
From: already5...@yahoo.com (Michael S)
Injection-Date: Fri, 19 Aug 2022 11:00:22 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 6085
 by: Michael S - Fri, 19 Aug 2022 11:00 UTC

On Friday, August 19, 2022 at 1:37:38 PM UTC+3, Terje Mathisen wrote:
> Michael S wrote:
> > On Friday, August 19, 2022 at 10:25:13 AM UTC+3, Terje Mathisen wrote:
> >> EricP wrote:
> >>> Terje Mathisen wrote:
> >>>> MitchAlsup wrote:
> >>>>> On Wednesday, August 17, 2022 at 9:14:55 AM UTC-5, EricP wrote:
> >>>>>> Thomas Koenig wrote:
> >>>>>>> robf...@gmail.com <robf...@gmail.com> schrieb:
> >>>>>>>
> >>>>>>>> 30+ comparators per core (300 comparators?) might allow every
> >>>>>>>> process to have its own comparator. Which would not need to be
> >>>>>>>> managed by the OS.
> >>>>>>>
> >>>>>>> Hmm... do you want to restrict the core to 300 processes? Hard
> >>>>>>> limits have a habit of coming around and biting the user when it
> >>>>>>> least expected (for example when an attacker or a buggy process
> >>>>>>> does a few forks() and uses up all of them).
> >>>>>>>
> >>>>>>> And you would need the OS anyway to schedule access to them so
> >>>>>>> so it is guaranteed that no two processes use the same timer.
> >>>>> <
> >>>>>> You don't need to dedicate a high resolution timer to a process.
> >>>>>> That wouldn't do much good as processes can have many timers
> >>>>>> and software within a single process won't know about other timers.
> >>>>>>
> >>>>>> Each one-shot HW hr-comparator manages a queue of requests.
> >>>>> <
> >>>>> Yes, obviously...
> >>>>> <
> >>>>>> The queue can be a linked list or binary tree in ascending order
> >>>>>> of absolute timeout hr-tick time. The earliest timeout timestamp
> >>>>>> is written into the trigger register, or 0 to disable the trigger
> >>>>>> if the queue is empty.
> >>>>> <
> >>>>> What does SW do in managing this list of event-times when one
> >>>>> event fires, and the next event is 1 tick farther down in time ?
> >>>>> It seems to me that the only way for SW to manage such a queue
> >>>>> would be to have large timer-quanta.
> >>>>
> >>>> I think that there are only two ways it can work:
> >>>>
> >>>> a) Make the comparator >= so that when the next value is written, it
> >>>> immediately causes a timeout since the tick count has passed. This
> >>>> does require that comparator to separate between a recent rollower and
> >>>> a long time to go, typically using 2^63 as the boundary:
> >>>>
> >>>> diff = next_event_count - current_tick_count;
> >>>> if ((signed) diff <= 0) fire();
> >>>
> >>> Unlike the system clock, the period counter resets to zero at boot.
> >>> With a 1 ns tick a 64 bit counter wraps after 584 years of
> >>> continuous up-time so it wouldn't need any extra handling.
> >> that is a very good, and probably sufficient, reason for making such a
> >> counter 64-bit only. If you need the ability to work in a 32-bit
> >> environment, then reading or writing the lower 32 bits would have to
> >> latch the upper part as well, holding it until the next instruction is done.
> >
> > If we want reading from user process, which we likely do, then your
> > suggestion sound dangerous. I don't want to start to think what
> > happens if task switch hits between two halves of read. May be,
> > nothing wrong, but proving it causes headaches.
> >
> > I see nothing particularly wrong with reading pair of registers in loop
> > hi = ReadHi()
> > lo = ReadLo()
> > while ((repHi = readHi()) != hi) {
> > lo = ReadLo()
> > hi = repHi
> > }
> >
> > It's just a little slower, but painless.
> >
> > Or, if you insist on reading lower half first:
> > lo = ReadLo()
> > hi = ReadHi()
> > while ((repLo = readLo()) < lo) {
> > hi = ReadHi()
> > lo = repLo
> > }
> We've discussed this a few years ago, you can even do it when the HW
> always require you to read both halves, i.e.
>
> prelo = ReadLo();
> prehi = ReadHi();
> do {
> lo = ReadLo();
> hi = ReadHi();
> } while (hi != prehi);
>
> You suffer the latency of two full reads and then you have odds of
> approx 2^-32 of having to repeat the loop one more time.

So, don't build HW that requires reading of both halves!
It's a bad idea for few other reasons except latency of the 2nd read.

If you ask me, don't build HW with non-idempotent reads. Period.

BTW, the code above does not work. It lacks update of prehi.

> Terje
>
> --
> - <Terje.Mathisen at tmsw.no>
> "almost all programming can be viewed as an exercise in caching"

Re: Precision timers

<tdnvul$nfc$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27412&group=comp.arch#27412

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!10O9MudpjwoXIahOJRbDvA.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Precision timers
Date: Fri, 19 Aug 2022 14:33:32 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tdnvul$nfc$1@gioia.aioe.org>
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me>
<253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com>
<tdifiv$tkh$3@newsreader4.netcologne.de> <wJ6LK.734298$5fVf.97913@fx09.iad>
<54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad>
<tdndsh$18u1$1@gioia.aioe.org>
<c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com>
<tdnp5f$1sq7$1@gioia.aioe.org>
<3bdb7858-8e9f-4cf7-8620-9781ccb4433cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="24044"; posting-host="10O9MudpjwoXIahOJRbDvA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.13
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 19 Aug 2022 12:33 UTC

Michael S wrote:
> On Friday, August 19, 2022 at 1:37:38 PM UTC+3, Terje Mathisen wrote:
>> Michael S wrote:
>>> I see nothing particularly wrong with reading pair of registers in loop
>>> hi = ReadHi()
>>> lo = ReadLo()
>>> while ((repHi = readHi()) != hi) {
>>> lo = ReadLo()
>>> hi = repHi
>>> }
>>>
>>> It's just a little slower, but painless.
>>>
>>> Or, if you insist on reading lower half first:
>>> lo = ReadLo()
>>> hi = ReadHi()
>>> while ((repLo = readLo()) < lo) {
>>> hi = ReadHi()
>>> lo = repLo
>>> }
>> We've discussed this a few years ago, you can even do it when the HW
>> always require you to read both halves, i.e.
>>
>> prelo = ReadLo();
>> prehi = ReadHi();
>> do {
>> lo = ReadLo();
>> hi = ReadHi();
>> } while (hi != prehi);
>>
>> You suffer the latency of two full reads and then you have odds of
>> approx 2^-32 of having to repeat the loop one more time.
>
> So, don't build HW that requires reading of both halves!
> It's a bad idea for few other reasons except latency of the 2nd read.
>
> If you ask me, don't build HW with non-idempotent reads. Period.

Strong YES!

>
> BTW, the code above does not work. It lacks update of prehi.

Yeah, I realized that shortly after posting but was going to allow you
to point it out. :-)

lo = ReadLo();
hi = ReadHi();
do {
prelo = lo; prehi = hi;
lo = ReadLo();
hi = ReadHi();
} while (hi != prehi);

is much cleaner looking as well.

If I was forced to work with such a timer I would still prefer the
interface to be 64-bit, i.e. hide the ugly re-read loop inside a system
library:

uint64_t readCounter()
{ uint64_t r;
uint32_t lo, hi, prelo, prehi;
lo = ReadLo(); hi = ReadHi();
do {
prelo = lo; prehi = hi;
lo = ReadLo();
hi = ReadHi();
r = hi;
} while (hi != prehi);
r = (r << 32) | lo;
return r;
}

This way you can keep the interface when you get a working (64-bit)
hardware interface.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Precision timers

<cacd318a-2c64-48f3-a8ba-298878c1d3f1n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27419&group=comp.arch#27419

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ae9:e903:0:b0:6ba:e5aa:d59e with SMTP id x3-20020ae9e903000000b006bae5aad59emr5767840qkf.214.1660932880581;
Fri, 19 Aug 2022 11:14:40 -0700 (PDT)
X-Received: by 2002:ad4:5ba5:0:b0:47b:4f54:cd1f with SMTP id
5-20020ad45ba5000000b0047b4f54cd1fmr7416549qvq.38.1660932880461; Fri, 19 Aug
2022 11:14:40 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 19 Aug 2022 11:14:40 -0700 (PDT)
In-Reply-To: <c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:c0e7:15da:982f:7a37;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:c0e7:15da:982f:7a37
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me> <253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com> <tdifiv$tkh$3@newsreader4.netcologne.de>
<wJ6LK.734298$5fVf.97913@fx09.iad> <54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad>
<tdndsh$18u1$1@gioia.aioe.org> <c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cacd318a-2c64-48f3-a8ba-298878c1d3f1n@googlegroups.com>
Subject: Re: Precision timers
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Fri, 19 Aug 2022 18:14:40 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2271
 by: MitchAlsup - Fri, 19 Aug 2022 18:14 UTC

On Friday, August 19, 2022 at 5:06:10 AM UTC-5, Michael S wrote:
> On Friday, August 19, 2022 at 10:25:13 AM UTC+3, Terje Mathisen wrote:

> I see nothing particularly wrong with reading pair of registers in loop
> hi = ReadHi()
// context switch happens here
> lo = ReadLo()
> while ((repHi = readHi()) != hi) {
> lo = ReadLo()
// context switch happens here
> hi = repHi
> }
>
> It's just a little slower, but painless.
>
> Or, if you insist on reading lower half first:
> lo = ReadLo()
// context switch happens here
> hi = ReadHi()
> while ((repLo = readLo()) < lo) {
> hi = ReadHi()
// context switch happens here
> lo = repLo
> }
>

Re: Precision timers

<0d1cbb39-838c-4972-ad74-38d92643259bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30975&group=comp.arch#30975

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:7013:0:b0:3bf:c8da:2918 with SMTP id x19-20020ac87013000000b003bfc8da2918mr297542qtm.0.1677540809976;
Mon, 27 Feb 2023 15:33:29 -0800 (PST)
X-Received: by 2002:a54:4797:0:b0:384:44a9:1247 with SMTP id
o23-20020a544797000000b0038444a91247mr328362oic.1.1677540809648; Mon, 27 Feb
2023 15:33:29 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 27 Feb 2023 15:33:29 -0800 (PST)
In-Reply-To: <cacd318a-2c64-48f3-a8ba-298878c1d3f1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=99.251.79.92; posting-account=QId4bgoAAABV4s50talpu-qMcPp519Eb
NNTP-Posting-Host: 99.251.79.92
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me> <253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com> <tdifiv$tkh$3@newsreader4.netcologne.de>
<wJ6LK.734298$5fVf.97913@fx09.iad> <54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad>
<tdndsh$18u1$1@gioia.aioe.org> <c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com>
<cacd318a-2c64-48f3-a8ba-298878c1d3f1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0d1cbb39-838c-4972-ad74-38d92643259bn@googlegroups.com>
Subject: Re: Precision timers
From: robfi...@gmail.com (robf...@gmail.com)
Injection-Date: Mon, 27 Feb 2023 23:33:29 +0000
Content-Type: text/plain; charset="UTF-8"
 by: robf...@gmail.com - Mon, 27 Feb 2023 23:33 UTC

In my test system there are two timer groups. Each group contains up to
32 timers requiring a 2kB address range. Should the timer groups be present
in the same MMU page, or should they have separate pages allocated for
each group? Using separate pages the two groups can be isolated so that
only the group being accessed is mapped and alterable. However, it may be
simpler just to map all the timers using one MMU page. It is basically the
same device broken into groups for hardware convenience.

Re: Precision timers

<2159493e-7f6c-4382-8b1d-f28dcb261784n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30976&group=comp.arch#30976

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:5ecc:0:b0:3bf:ba87:a454 with SMTP id s12-20020ac85ecc000000b003bfba87a454mr298951qtx.12.1677543187760;
Mon, 27 Feb 2023 16:13:07 -0800 (PST)
X-Received: by 2002:a05:6830:4096:b0:68d:b51a:5cf6 with SMTP id
x22-20020a056830409600b0068db51a5cf6mr303536ott.7.1677543187508; Mon, 27 Feb
2023 16:13:07 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 27 Feb 2023 16:13:07 -0800 (PST)
In-Reply-To: <0d1cbb39-838c-4972-ad74-38d92643259bn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:d8bc:125f:21e2:d3b;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:d8bc:125f:21e2:d3b
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdf5jh$3lo8i$1@dont-email.me> <253fa161-fdae-4312-a8de-a93891166dafn@googlegroups.com>
<09a5763e-38c2-439e-9cec-810c0d150ca1n@googlegroups.com> <tdifiv$tkh$3@newsreader4.netcologne.de>
<wJ6LK.734298$5fVf.97913@fx09.iad> <54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com>
<tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad>
<tdndsh$18u1$1@gioia.aioe.org> <c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com>
<cacd318a-2c64-48f3-a8ba-298878c1d3f1n@googlegroups.com> <0d1cbb39-838c-4972-ad74-38d92643259bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2159493e-7f6c-4382-8b1d-f28dcb261784n@googlegroups.com>
Subject: Re: Precision timers
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Tue, 28 Feb 2023 00:13:07 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2824
 by: MitchAlsup - Tue, 28 Feb 2023 00:13 UTC

On Monday, February 27, 2023 at 5:33:31 PM UTC-6, robf...@gmail.com wrote:
> In my test system there are two timer groups. Each group contains up to
> 32 timers requiring a 2kB address range.
<
32 sixty-four (64-bit) counters are only 256 bytes. What kind of data resides
between the counters; how big are these counters ??
<
> Should the timer groups be present
> in the same MMU page, or should they have separate pages allocated for
> each group?
<
The OS-counter-driver writer should make this decision.
<
> Using separate pages the two groups can be isolated so that
> only the group being accessed is mapped and alterable. However, it may be
> simpler just to map all the timers using one MMU page. It is basically the
> same device broken into groups for hardware convenience.
<
My context switch drags around 8 counters (on a per thread basis).
<
What are these counter/timers being used for ??

Re: Precision timers

<gNbLL.723301$t5W7.3102@fx13.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30977&group=comp.arch#30977

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Precision timers
Newsgroups: comp.arch
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com> <tdifiv$tkh$3@newsreader4.netcologne.de> <wJ6LK.734298$5fVf.97913@fx09.iad> <54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com> <tdkp46$104a$1@gioia.aioe.org> <TQvLK.163392$%i2.22546@fx48.iad> <tdndsh$18u1$1@gioia.aioe.org> <c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com> <cacd318a-2c64-48f3-a8ba-298878c1d3f1n@googlegroups.com> <0d1cbb39-838c-4972-ad74-38d92643259bn@googlegroups.com>
Lines: 14
Message-ID: <gNbLL.723301$t5W7.3102@fx13.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 28 Feb 2023 00:20:28 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 28 Feb 2023 00:20:28 GMT
X-Received-Bytes: 1697
 by: Scott Lurndal - Tue, 28 Feb 2023 00:20 UTC

"robf...@gmail.com" <robfi680@gmail.com> writes:
>In my test system there are two timer groups. Each group contains up to
>32 timers requiring a 2kB address range. Should the timer groups be present
>in the same MMU page, or should they have separate pages allocated for
>each group? Using separate pages the two groups can be isolated so that
>only the group being accessed is mapped and alterable. However, it may be
>simpler just to map all the timers using one MMU page. It is basically the
>same device broken into groups for hardware convenience.

If you want to give the timers to guest operating systems, then they
need to be spaced by the size of the largest page.

Or programmable via a PCI-like BAR.

Re: Precision timers

<e6300eed-be06-4f7c-88f7-19fe4382015en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30978&group=comp.arch#30978

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:56ea:0:b0:3bf:d520:1d59 with SMTP id 10-20020ac856ea000000b003bfd5201d59mr283163qtu.1.1677546085369;
Mon, 27 Feb 2023 17:01:25 -0800 (PST)
X-Received: by 2002:a05:6870:8c28:b0:172:59d4:26dd with SMTP id
ec40-20020a0568708c2800b0017259d426ddmr139232oab.11.1677546085027; Mon, 27
Feb 2023 17:01:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 27 Feb 2023 17:01:24 -0800 (PST)
In-Reply-To: <gNbLL.723301$t5W7.3102@fx13.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=99.251.79.92; posting-account=QId4bgoAAABV4s50talpu-qMcPp519Eb
NNTP-Posting-Host: 99.251.79.92
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdifiv$tkh$3@newsreader4.netcologne.de> <wJ6LK.734298$5fVf.97913@fx09.iad>
<54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com> <tdkp46$104a$1@gioia.aioe.org>
<TQvLK.163392$%i2.22546@fx48.iad> <tdndsh$18u1$1@gioia.aioe.org>
<c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com> <cacd318a-2c64-48f3-a8ba-298878c1d3f1n@googlegroups.com>
<0d1cbb39-838c-4972-ad74-38d92643259bn@googlegroups.com> <gNbLL.723301$t5W7.3102@fx13.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e6300eed-be06-4f7c-88f7-19fe4382015en@googlegroups.com>
Subject: Re: Precision timers
From: robfi...@gmail.com (robf...@gmail.com)
Injection-Date: Tue, 28 Feb 2023 01:01:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3546
 by: robf...@gmail.com - Tue, 28 Feb 2023 01:01 UTC

On Monday, February 27, 2023 at 7:20:32 PM UTC-5, Scott Lurndal wrote:
> "robf...@gmail.com" <robf...@gmail.com> writes:
> >In my test system there are two timer groups. Each group contains up to
> >32 timers requiring a 2kB address range. Should the timer groups be present
> >in the same MMU page, or should they have separate pages allocated for
> >each group? Using separate pages the two groups can be isolated so that
> >only the group being accessed is mapped and alterable. However, it may be
> >simpler just to map all the timers using one MMU page. It is basically the
> >same device broken into groups for hardware convenience.
> If you want to give the timers to guest operating systems, then they
> need to be spaced by the size of the largest page.
>
> Or programmable via a PCI-like BAR.

Each group has a PCI config space.
They have programmable addresses via PCI config BAR.

>32 sixty-four (64-bit) counters are only 256 bytes. What kind of data resides
>between the counters; how big are these counters ??

I have changed this to 64 counters, it is configurable up to 64.
There are four 64-bit registers associated with each counter,
current count, max count, the on time, and a control reg.

There are also eight more registers to control interrupt enable,
gating counters on and off, synchronizing counters and viewing the output
pulse. So the registers occupy a 4kB Area with a lot of unused space.

The counter registers are just holding registers, which do not update the
counter until the sync register is written. This allows all counters to be updated
at the same time.

>What are these counter/timers being used for ??
OS: time slice, garbage collect / watchdog and disk clock algorithm, games and
possibly robotics.

Four of the timers have external ports for gating and output. The 'on' time
controls the pulse width of the timer.

Re: Precision timers

<c1c0d154-20d6-4e2a-b369-7a3ab948111fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30979&group=comp.arch#30979

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:115:0:b0:3bf:c266:da24 with SMTP id e21-20020ac80115000000b003bfc266da24mr349062qtg.2.1677546910746;
Mon, 27 Feb 2023 17:15:10 -0800 (PST)
X-Received: by 2002:a9d:454a:0:b0:693:e03f:a027 with SMTP id
p10-20020a9d454a000000b00693e03fa027mr391225oti.0.1677546910481; Mon, 27 Feb
2023 17:15:10 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 27 Feb 2023 17:15:10 -0800 (PST)
In-Reply-To: <e6300eed-be06-4f7c-88f7-19fe4382015en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=99.251.79.92; posting-account=QId4bgoAAABV4s50talpu-qMcPp519Eb
NNTP-Posting-Host: 99.251.79.92
References: <b3662ae3-4e78-4af8-adb3-d397954e7bacn@googlegroups.com>
<tdifiv$tkh$3@newsreader4.netcologne.de> <wJ6LK.734298$5fVf.97913@fx09.iad>
<54940761-07c4-4b54-bdf4-4fbaf7d073ccn@googlegroups.com> <tdkp46$104a$1@gioia.aioe.org>
<TQvLK.163392$%i2.22546@fx48.iad> <tdndsh$18u1$1@gioia.aioe.org>
<c66104e5-7069-4ab8-a69b-9b1912152232n@googlegroups.com> <cacd318a-2c64-48f3-a8ba-298878c1d3f1n@googlegroups.com>
<0d1cbb39-838c-4972-ad74-38d92643259bn@googlegroups.com> <gNbLL.723301$t5W7.3102@fx13.iad>
<e6300eed-be06-4f7c-88f7-19fe4382015en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c1c0d154-20d6-4e2a-b369-7a3ab948111fn@googlegroups.com>
Subject: Re: Precision timers
From: robfi...@gmail.com (robf...@gmail.com)
Injection-Date: Tue, 28 Feb 2023 01:15:10 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3938
 by: robf...@gmail.com - Tue, 28 Feb 2023 01:15 UTC

On Monday, February 27, 2023 at 8:01:27 PM UTC-5, robf...@gmail.com wrote:
> On Monday, February 27, 2023 at 7:20:32 PM UTC-5, Scott Lurndal wrote:
> > "robf...@gmail.com" <robf...@gmail.com> writes:
> > >In my test system there are two timer groups. Each group contains up to
> > >32 timers requiring a 2kB address range. Should the timer groups be present
> > >in the same MMU page, or should they have separate pages allocated for
> > >each group? Using separate pages the two groups can be isolated so that
> > >only the group being accessed is mapped and alterable. However, it may be
> > >simpler just to map all the timers using one MMU page. It is basically the
> > >same device broken into groups for hardware convenience.
> > If you want to give the timers to guest operating systems, then they
> > need to be spaced by the size of the largest page.
> >
> > Or programmable via a PCI-like BAR.
> Each group has a PCI config space.
> They have programmable addresses via PCI config BAR.
> >32 sixty-four (64-bit) counters are only 256 bytes. What kind of data resides
> >between the counters; how big are these counters ??
> I have changed this to 64 counters, it is configurable up to 64.
> There are four 64-bit registers associated with each counter,
> current count, max count, the on time, and a control reg.
>
> There are also eight more registers to control interrupt enable,
> gating counters on and off, synchronizing counters and viewing the output
> pulse. So the registers occupy a 4kB Area with a lot of unused space.
>
> The counter registers are just holding registers, which do not update the
> counter until the sync register is written. This allows all counters to be updated
> at the same time.
> >What are these counter/timers being used for ??
> OS: time slice, garbage collect / watchdog and disk clock algorithm, games and
> possibly robotics.
>
> Four of the timers have external ports for gating and output. The 'on' time
> controls the pulse width of the timer.

I forgot, four of the timers can also be clocked by an external clock, so they can
be used to count pulses.

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor