Skip to content

Add semaphore primitives to SAL RTOS interface#302

Merged
JohnAmadis merged 2 commits into
developfrom
copilot/dodac-semafory-do-sal
Jun 3, 2026
Merged

Add semaphore primitives to SAL RTOS interface#302
JohnAmadis merged 2 commits into
developfrom
copilot/dodac-semafory-do-sal

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 3, 2026

SAL exposed mutex primitives but had no semaphore support, which left synchronization incomplete for RTOS-style usage. This change adds semaphore APIs to the SAL contract and default system-side implementation.

  • SAL API surface (RTOS section)

    • Added new built-in SAL functions in inc/dmod_sal.h:
      • Dmod_Semaphore_New(uint32_t InitialValue)
      • Dmod_Semaphore_Wait(void* Semaphore)
      • Dmod_Semaphore_Post(void* Semaphore)
      • Dmod_Semaphore_Delete(void* Semaphore)
  • Default system implementation (weak symbols)

    • Implemented semaphore primitives in src/system/if/dmod_if_rtos.c using POSIX semaphores (sem_t).
    • Matched existing SAL conventions for:
      • allocation/free lifecycle
      • null-handle validation
      • error-path logging
      • fallback behavior when pthread support is disabled
  • Public system tests

    • Added tests/system/public/tests_dmod_semaphore.cpp and registered it in tests/system/public/CMakeLists.txt.
    • Covers nominal semaphore lifecycle and null-handle behavior.
  • Integration docs

    • Extended SAL recommendation table in README.md to include semaphore primitives alongside mutexes.
void* sem = Dmod_Semaphore_New(1);
Dmod_Semaphore_Wait(sem);
/* critical section */
Dmod_Semaphore_Post(sem);
Dmod_Semaphore_Delete(sem);

Copilot AI linked an issue Jun 3, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add semaphores to SAL Add semaphore primitives to SAL RTOS interface Jun 3, 2026
Copilot AI requested a review from JohnAmadis June 3, 2026 09:37
@JohnAmadis JohnAmadis marked this pull request as ready for review June 3, 2026 10:02
@JohnAmadis JohnAmadis merged commit 720c596 into develop Jun 3, 2026
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dodać semafory do SAL

2 participants