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

Semaphore does not use max_count #3

Open
claudiomalnati opened this issue Dec 5, 2024 · 2 comments
Open

Semaphore does not use max_count #3

claudiomalnati opened this issue Dec 5, 2024 · 2 comments
Assignees
Labels
bug Something isn't working internal bug tracker Issue confirmed and reported into a ticket in the internal bug tracking system mw MW-related issue or pull-request rtos RTOS-related issue or pull-request

Comments

@claudiomalnati
Copy link

Caution

The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post your report to the ST Community in the STM32 MCUs dedicated page.

Describe the set-up

any

Describe the bug (skip if none)

The CMSIS RTOS API for semaphores requires the parameter max_count for maximum number of available tokens. The current implementation however ignores this parameter making it impossible to use binary semaphores per example.

In osSemaphoreRelease(), the tx_semaphore_put() is used to release the semaphore tokens. however, this function does not account for max_count. If osSemaphoreRelease() is called more often than max_count specifies, the internal token count will exceed max_count, leading to more tokens being available, when acquireing the semaphore.

How to reproduce the bug (skip if none)

  1. Create a semaphore with osSemaphoreId_t semaphore = osSemaphoreNew(1, 1, NULL);
  2. Release the semaphore twice with osSemaphoreRelease(semaphore);
  3. Acquire the semaphore twice in a row with osSemaphoreAcquire(semaphore, 100);
  4. The second acquire should time out but is able to acquire the semaphore.

Additional context

our quick fix semaphore_max_count.patch

Screenshots

n/a

@ALABSTM ALABSTM added mw MW-related issue or pull-request rtos RTOS-related issue or pull-request labels Dec 9, 2024
@ALABSTM ALABSTM self-assigned this Dec 9, 2024
@ALABSTM ALABSTM added bug Something isn't working internal bug tracker Issue confirmed and reported into a ticket in the internal bug tracking system labels Dec 9, 2024
@ALABSTM
Copy link

ALABSTM commented Dec 9, 2024

ST Internal Reference: 198133

@ALABSTM
Copy link

ALABSTM commented Dec 9, 2024

Hi @claudiomalnati,

Thank you for this clear report. It has been forwarded to our development teams. I will keep you informed.

With regards,

@ALABSTM ALABSTM moved this from To do to Analyzed in stm32cube-mcu-mw-dashboard Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working internal bug tracker Issue confirmed and reported into a ticket in the internal bug tracking system mw MW-related issue or pull-request rtos RTOS-related issue or pull-request
Projects
Development

No branches or pull requests

2 participants