Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libc/semaphore: Read semaphore value by using NXSEM_COUNT macro #16149

Merged
merged 1 commit into from
Apr 8, 2025

Conversation

jlaitine
Copy link
Contributor

@jlaitine jlaitine commented Apr 7, 2025

Summary

This is a small cleanup for libc nxsem_get_value, to use the provided macro to fetch the semaphore value instead of accessing semaphore internals directly outside of sched/semaphore.

Impact

No functional impact

Testing

This has obviously no functional impact, however, it has been tested together with all the changes in PR #16148 (in qemu and in real hardware).

@github-actions github-actions bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Apr 7, 2025
@lupyuen
Copy link
Member

lupyuen commented Apr 7, 2025

@nuttxpr test avaota-a1:nsh

@nuttxpr
Copy link

nuttxpr commented Apr 7, 2025

[Experimental Bot, please feedback here]

Build and Test Successful (avaota-a1:nsh)
https://gitlab.com/lupyuen/nuttx-build-log/-/snippets/4832312

$ git clone https://github.com/tiiuae/nuttx nuttx --branch libc_small_semaphore_cleanup
$ git clone https://github.com/apache/nuttx-apps apps --branch master
$ pushd nuttx
$ git reset --hard HEAD
HEAD is now at 503534e496 libc/semaphore: Read semaphore value by using NXSEM_COUNT macro
$ popd
$ pushd apps
$ git reset --hard HEAD
HEAD is now at 61551aa84 system/dd: Implement conv=notrunc
$ popd
NuttX Source: https://github.com/apache/nuttx/tree/503534e4967abe907a584637a4e958e46f6c3299
NuttX Apps: https://github.com/apache/nuttx-apps/tree/61551aa8490236bf0dc2c96e36071b935c6d1252
$ cd nuttx
$ tools/configure.sh avaota-a1:nsh
$ make -j
$ make -j export
$ pushd ../apps
$ ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-10.4.0.tar.gz
$ make -j import
$ popd
$ genromfs -f initrd -d ../apps/bin -V NuttXBootVol
$ head -c 65536 /dev/zero
$ cat nuttx.bin /tmp/nuttx.pad initrd
$ scp Image thinkcentre:/tmp/Image
$ ssh thinkcentre sudo /home/user/copy-image.sh
$ sd-mux-ctrl --device-serial=sd-wire_02-09 --ts
$ mkdir -p /tmp/sda1
$ mount /dev/sda1 /tmp/sda1
$ cp /tmp/Image /tmp/sda1/
$ rm /tmp/Image
$ umount /tmp/sda1
$ sd-mux-ctrl --device-serial=sd-wire_02-09 --dut
$ cd /home/luppy/nuttx-build-farm
$ ssh thinkcentre
nsh> uname -a
NuttX 10.4.0 503534e496 Apr  7 2025 17:30:54 arm64 avaota-a1
nsh> ostest
arena        a000    28000
ordblks         2        4
mxordblk     5ff8    1bff8
uordblks     27e8     6700
fordblks     7818    21900
user_main: Exiting
ostest_main: Exiting with status 0
nsh> Now running https://github.com/lupyuen/nuttx-build-farm/blob/main/avaota-power.sh off
----- Power off Avaota-A1
[]

@lupyuen
Copy link
Member

lupyuen commented Apr 7, 2025

@nuttxpr test milkv_duos:nsh

@nuttxpr
Copy link

nuttxpr commented Apr 7, 2025

[Experimental Bot, please feedback here]

Build and Test Successful (milkv_duos:nsh)
https://gitlab.com/lupyuen/nuttx-build-log/-/snippets/4832315

$ git clone https://github.com/tiiuae/nuttx nuttx --branch libc_small_semaphore_cleanup
$ git clone https://github.com/apache/nuttx-apps apps --branch master
$ pushd nuttx
$ git reset --hard HEAD
HEAD is now at 503534e496 libc/semaphore: Read semaphore value by using NXSEM_COUNT macro
$ popd
$ pushd apps
$ git reset --hard HEAD
HEAD is now at 61551aa84 system/dd: Implement conv=notrunc
$ popd
NuttX Source: https://github.com/apache/nuttx/tree/503534e4967abe907a584637a4e958e46f6c3299
NuttX Apps: https://github.com/apache/nuttx-apps/tree/61551aa8490236bf0dc2c96e36071b935c6d1252
$ cd nuttx
$ tools/configure.sh milkv_duos:nsh
$ make -j
$ make -j export
$ pushd ../apps
$ ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-10.4.0.tar.gz
$ make -j import
$ popd
$ genromfs -f initrd -d ../apps/bin -V NuttXBootVol
$ head -c 65536 /dev/zero
$ cat nuttx.bin /tmp/nuttx.pad initrd
$ scp Image tftpserver:/tftpboot/Image-sg2000
$ cd /home/luppy/nuttx-build-farm
$ ssh tftpserver
OpenSBI v0.9
nsh> uname -a
NuttX 10.4.0 503534e496 Apr  7 2025 17:37:10 risc-v milkv_duos
nsh> ostest
arena       81000    81000
ordblks         2        3
mxordblk    7cff8    78ff8
uordblks     2660     4570
fordblks    7e9a0    7ca90
user_main: Exiting
ostest_main: Exiting with status 0
nsh> Now running https://github.com/lupyuen/nuttx-build-farm/blob/main/oz64-power.sh off
----- Power off Oz64
[]

Copy link
Member

@lupyuen lupyuen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested OK with OSTest on Avaota-A1 A527 Arm64 SBC and Oz64 SG2000 64-bit RISC-V SBC. Thanks :-)

@lupyuen
Copy link
Member

lupyuen commented Apr 7, 2025

@jlaitine Please remember to fill in the Commit Description. Thanks :-)

We should not access semaphore internals directly outside sched/semaphore.

Just read it via the NXSEM_COUNT macro provided.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
@jlaitine jlaitine force-pushed the libc_small_semaphore_cleanup branch from 503534e to 27d09ac Compare April 8, 2025 05:05
@lupyuen lupyuen merged commit 84cb217 into apache:master Apr 8, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants