Issue created by Sebastian Huber: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5806



`rtems_counter_ticks_to_sbintime()` and `rtems_counter_ticks_to_nanoseconds()` 
in `cpukit/sapi/src/cpucounterconverter.c` multiply the counter ticks with a 
64-bit scaler. The 64-bit product overflows.

| Function | Wrong result from |
| -------- | ----------------- |
| `rtems_counter_ticks_to_sbintime()` | 2 s |
| `rtems_counter_ticks_to_nanoseconds()` | 4.29 s, where the cast to 32 bits 
also truncates the result |

The test framework measures durations with `rtems_counter_ticks_to_sbintime()`. 
On a 25 MHz counter, the performance test suite reported 107 s for a run of 731 
s. On the 62.5 MHz counter of Qemu `xlnx-zcu102`, 
`rtems_counter_ticks_to_nanoseconds()` returns a wrong value for the maximum 
counter ticks.

The test `spcpucounter01` checks the conversions at one second alone.

Found while measuring the runtime of the red-black tree on several boards. This 
description was created with Claude Code assistance.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5806
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/namespace/49/sent_notifications/6-3vrcr1zqfpcjl9ttscxypo5h2-1d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to