casaroli opened a new pull request, #3864:
URL: https://github.com/apache/nuttx-apps/pull/3864

   ## Summary
   
   `rr_test` passed when the first thread did not finish all its runs before 
the second thread finished one run. When one run is much shorter than 
`CONFIG_RR_INTERVAL`, the first thread finishes all its runs in its first time 
slice, and the test fails (`roundrobin.c:281`) although round-robin scheduling 
works. This happens on fast targets, and on QEMU when the host is busy.
   
   This PR counts the time slices of each thread instead:
   
   - Each thread searches for primes one number at a time, and starts a new 
time slice when the other thread ran after its last number.
   - The test ends when each thread had `CONFIG_TESTING_OSTEST_RR_RUNS` time 
slices, and passes when the two counts differ by at most one.
   - If the time slices do not come, the ostest thread, which has a higher 
priority, stops the two threads after a time limit, and the test fails.
   
   The Kconfig options keep their names. `CONFIG_TESTING_OSTEST_RR_RUNS` is now 
the number of time slices of each thread. With the defaults, the test takes 
about 4 seconds.
   
   ## Impact
   
   `testing/ostest` only. The nuttx documentation of the two options is updated 
in apache/nuttx#NNNNN.
   
   ## Testing
   
   `qemu-armv8a:knsh` and `qemu-armv8a:nsh` (QEMU 11 with HVF on an Apple M4, 
busy host):
   
   - Master: on this busy host, `rr_test` failed at `roundrobin.c:281` in every 
ostest run of the last hour (master on knsh and nsh, and four other branches).
   - This PR: `rr_test: thread 1 ran 11 time slices, thread 2 ran 10`, 
`rr_test: Done`, and `ostest_main: Exiting with status 0` on both 
configurations.
   - This PR with `SCHED_FIFO` instead of `SCHED_RR` (a local test-only 
change): `thread 1 ran 1 time slices, thread 2 ran 0`, `rr_test: Roundrobin 
Failed` after the time limit, with no hang.
   
   Build: `lm3s6965-ek:qemu-flat` with ostest and `-Werror`. 
`tools/checkpatch.sh -f` passes on both changed files.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to