Skip to content

testing/ostest, benchmarks/cyclictest: Prepare for the PSE52 pthread fixes. - #4049

Merged
xiaoxiang781216 merged 2 commits into
apache:masterfrom
Shanks0224:pse52-conformance
Nov 14, 2026
Merged

xiaoxiang781216 merged 2 commits into
apache:masterfrom
Shanks0224:pse52-conformance

Conversation

@Shanks0224

@Shanks0224 Shanks0224 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Note: Please adhere to Contributing Guidelines.

Summary

Two changes that the PSE52 conformance fixes in apache/nuttx need:

  • testing/ostest: the cancel test destroys a condition variable after its
    waiter was cancelled. With the nuttx change, pthread_cond_destroy()
    returns EBUSY while a thread is counted as a waiter, so broadcast the
    condition before it is destroyed.
  • benchmarks/cyclictest: the -c option used the number from the user as
    the clock ID. Map 0 and 1 to CLOCK_REALTIME and CLOCK_MONOTONIC, as
    the help text and the documentation say, so that the option keeps
    working when the clock ID values change.

Both commits also fix the nxstyle errors in the files that they touch.

Related: apache/nuttx#21834

Impact

None for users. Both changes also work with the current nuttx, so this PR
can be merged first.

Testing

  • ostest, sim:ostest, 5 loops: passes with the current nuttx master,
    and with the nuttx PR above. With the nuttx PR it also passes on
    qemu-armv7r:pnsh, qemu-armv7a:knsh and a B-L475E-IOT01A board
    (b-l475e-iot01a:nsh with CONFIG_TESTING_OSTEST=y). The cancel test
    with the nuttx PR:

    restart_thread: Broadcasting cond to clear waiters
    restart_thread: Destroying cond
    
  • cyclictest, sim:nsh with CONFIG_TIMER=y and
    CONFIG_BENCHMARK_CYCLICTEST=y: cyclictest -c 0 -l 200 and
    cyclictest -c 1 -l 200 run with the current nuttx master and with the
    nuttx PR:

    nsh> cyclictest -c 0 -l 200
    T: 0 (    9) P: 1 I:1000 C:     10 Min:   8863 Act: 8972 Avg: 8982 Max:    9036
    

    The output does not show which clock is used.

restart_thread() destroys the condition variable after the waiter
thread was cancelled.  A thread that is cancelled while it waits in
pthread_cond_wait() stays counted as a waiter, so
pthread_cond_destroy() fails with EBUSY once it checks for waiters.

Broadcast the condition before it is destroyed, so that no waiter is
counted any more.  Also fix the nxstyle errors and a typo in the file.

Assisted-by: Kiro:auto
Signed-off-by: ganjing <ganjing@xiaomi.com>
The -c option takes 0 for CLOCK_REALTIME and 1 for CLOCK_MONOTONIC,
but the code used the number as the clock ID, which only works while
the clock IDs have these values.  Map 0 and 1 to the clock names.
Also fix the nxstyle errors in the file.

Assisted-by: Kiro:auto
Signed-off-by: ganjing <ganjing@xiaomi.com>
@xiaoxiang781216
xiaoxiang781216 merged commit 1bd81b5 into apache:master Nov 14, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants