Skip to content

shell: exchange k_mutex for k_sem #93230

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

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

bjarki-andreasen
Copy link
Contributor

The mutex is being used as a simple binary semaphore. It is not
recursed so we don't need to track thread ownership nor lock count.

Exchange the mutex for a binary semaphore to save resources and
speed up shell.

Building the shell test suite for nrf54l15 using k_mutex:

Memory region         Used Size  Region Size  %age Used
           FLASH:       71592 B      1428 KB      4.90%
             RAM:        9872 B       188 KB      5.13%
        IDT_LIST:          0 GB        32 KB      0.00%

using k_sem:

Memory region         Used Size  Region Size  %age Used
           FLASH:       70204 B      1428 KB      4.80%
             RAM:        9864 B       188 KB      5.12%
        IDT_LIST:          0 GB        32 KB      0.00%

@bjarki-andreasen bjarki-andreasen marked this pull request as ready for review July 16, 2025 23:10
@github-actions github-actions bot added the area: Shell Shell subsystem label Jul 16, 2025
@github-actions github-actions bot requested a review from carlescufi July 16, 2025 23:11
@nashif nashif requested a review from jakub-uC July 16, 2025 23:38
@stephanosio stephanosio removed the request for review from jakub-uC July 16, 2025 23:40
@zephyrbot zephyrbot requested a review from jakub-uC July 16, 2025 23:56
The mutex is being used as a simple binary semaphore. It is not
recursed so we don't need to track thread ownership nor lock count.

Exchange the mutex for a binary semaphore to save resources and
speed up shell.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Copy link

@bjarki-andreasen
Copy link
Contributor Author

ping @jakub-uC

@mathieuchopstm mathieuchopstm changed the title Exchange k_mutex for k_sem shell: exchange k_mutex for k_sem Jul 24, 2025
Copy link
Contributor

@mathieuchopstm mathieuchopstm left a comment

Choose a reason for hiding this comment

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

Seems correct to me 🙂

Copy link
Member

@fabiobaltieri fabiobaltieri left a comment

Choose a reason for hiding this comment

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

cool

@fabiobaltieri fabiobaltieri merged commit 825dea6 into zephyrproject-rtos:main Jul 24, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Shell Shell subsystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants