|
ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
|
ICARUS Semaphore - Counting Semaphores. More...
#include <stdint.h>#include <stdbool.h>Go to the source code of this file.
Functions | |
| bool | semaphore_init (uint8_t semaphore_idx, uint32_t semaphore_count) |
| Initialize a counting semaphore. | |
| bool | semaphore_feed (uint8_t semaphore_idx) |
| Increment semaphore count (V operation / signal) | |
| bool | semaphore_consume (uint8_t semaphore_idx) |
| Decrement semaphore count (P operation / wait) | |
| bool | semaphore_consume_timeout (uint8_t semaphore_idx, uint32_t max_ticks) |
| Decrement semaphore count with timeout (timed P / wait). | |
| uint32_t | semaphore_get_count (uint8_t semaphore_idx) |
| Get current semaphore count. | |
| uint32_t | semaphore_get_max_count (uint8_t semaphore_idx) |
| Get semaphore maximum count. | |
| bool | sem_can_feed (uint8_t semaphore_idx) |
| Check if semaphore can accept a feed (SVC call gate) | |
| bool | sem_can_consume (uint8_t semaphore_idx) |
| Check if semaphore can be consumed (SVC call gate) | |
| void | sem_increment (uint8_t semaphore_idx) |
| Increment semaphore count (SVC call gate) | |
| void | sem_decrement (uint8_t semaphore_idx) |
| Decrement semaphore count (SVC call gate) | |
| bool | __semaphore_init (uint8_t semaphore_idx, uint32_t semaphore_count) |
| Privileged implementation of semaphore_init. | |
| bool | __semaphore_feed (uint8_t semaphore_idx) |
| Privileged implementation of semaphore_feed. | |
| bool | __semaphore_consume (uint8_t semaphore_idx) |
| Privileged implementation of semaphore_consume. | |
| bool | __semaphore_consume_timeout (uint8_t semaphore_idx, uint32_t max_ticks) |
| Privileged implementation of semaphore_consume_timeout. | |
| uint32_t | __semaphore_get_count (uint8_t semaphore_idx) |
| Privileged implementation of semaphore_get_count. | |
| uint32_t | __semaphore_get_max_count (uint8_t semaphore_idx) |
| Privileged implementation of semaphore_get_max_count. | |
| bool | __sem_can_feed (uint8_t semaphore_idx) |
| Privileged call gate: can semaphore accept a feed? | |
| bool | __sem_can_consume (uint8_t semaphore_idx) |
| Privileged call gate: can semaphore be consumed? | |
| void | __sem_increment (uint8_t semaphore_idx) |
| Privileged write gate: increment semaphore count. | |
| void | __sem_decrement (uint8_t semaphore_idx) |
| Privileged write gate: decrement semaphore count. | |
ICARUS Semaphore - Counting Semaphores.
Counting semaphore implementation for task synchronization.
Definition in file semaphore.h.
| bool __sem_can_consume | ( | uint8_t | semaphore_idx | ) |
Privileged call gate: can semaphore be consumed?
Definition at line 186 of file semaphore.c.
References icarus_semaphore_t::count, ICARUS_MAX_SEMAPHORES, and semaphore_list.
Referenced by sem_can_consume(), and SVC_Handler_C().
| bool __sem_can_feed | ( | uint8_t | semaphore_idx | ) |
Privileged call gate: can semaphore accept a feed?
Definition at line 172 of file semaphore.c.
References icarus_semaphore_t::count, ICARUS_MAX_SEMAPHORES, icarus_semaphore_t::max_count, and semaphore_list.
Referenced by sem_can_feed(), and SVC_Handler_C().
| void __sem_decrement | ( | uint8_t | semaphore_idx | ) |
Privileged write gate: decrement semaphore count.
Definition at line 213 of file semaphore.c.
References icarus_semaphore_t::count, ICARUS_MAX_SEMAPHORES, os_tick_count, semaphore_list, and icarus_semaphore_t::tick_updated_at.
Referenced by sem_decrement(), and SVC_Handler_C().
| void __sem_increment | ( | uint8_t | semaphore_idx | ) |
Privileged write gate: increment semaphore count.
Definition at line 199 of file semaphore.c.
References icarus_semaphore_t::count, ICARUS_MAX_SEMAPHORES, os_tick_count, semaphore_list, and icarus_semaphore_t::tick_updated_at.
Referenced by sem_increment(), and SVC_Handler_C().
| bool __semaphore_consume | ( | uint8_t | semaphore_idx | ) |
Privileged implementation of semaphore_consume.
Definition at line 81 of file semaphore.c.
References ICARUS_MAX_SEMAPHORES, sem_can_consume(), sem_decrement(), semaphore_list, and task_active_sleep().
Referenced by semaphore_consume().
| bool __semaphore_consume_timeout | ( | uint8_t | semaphore_idx, |
| uint32_t | max_ticks | ||
| ) |
Privileged implementation of semaphore_consume_timeout.
Spins with task_active_sleep(1) checking sem_can_consume() each tick. Returns false if max_ticks elapse without the semaphore becoming available. max_ticks == 0 is a non-blocking try (check once, return immediately).
| semaphore_idx | Semaphore index. |
| max_ticks | Maximum ticks to wait. |
| true | Acquired. |
| false | Timeout or invalid. |
Definition at line 116 of file semaphore.c.
References ICARUS_MAX_SEMAPHORES, sem_can_consume(), sem_decrement(), semaphore_list, and task_active_sleep().
Referenced by semaphore_consume_timeout(), and SVC_Handler_C().
| bool __semaphore_feed | ( | uint8_t | semaphore_idx | ) |
Privileged implementation of semaphore_feed.
Definition at line 54 of file semaphore.c.
References ICARUS_MAX_SEMAPHORES, sem_can_feed(), sem_increment(), semaphore_list, and task_active_sleep().
Referenced by semaphore_feed().
| uint32_t __semaphore_get_count | ( | uint8_t | semaphore_idx | ) |
Privileged implementation of semaphore_get_count.
Definition at line 146 of file semaphore.c.
References icarus_semaphore_t::count, ICARUS_MAX_SEMAPHORES, and semaphore_list.
Referenced by semaphore_get_count(), and SVC_Handler_C().
| uint32_t __semaphore_get_max_count | ( | uint8_t | semaphore_idx | ) |
Privileged implementation of semaphore_get_max_count.
Definition at line 158 of file semaphore.c.
References ICARUS_MAX_SEMAPHORES, icarus_semaphore_t::max_count, and semaphore_list.
Referenced by semaphore_get_max_count(), and SVC_Handler_C().
| bool __semaphore_init | ( | uint8_t | semaphore_idx, |
| uint32_t | semaphore_count | ||
| ) |
Privileged implementation of semaphore_init.
Definition at line 35 of file semaphore.c.
References icarus_semaphore_t::count, icarus_semaphore_t::engaged, ICARUS_MAX_SEMAPHORES, icarus_semaphore_t::max_count, os_tick_count, semaphore_list, and icarus_semaphore_t::tick_updated_at.
Referenced by semaphore_init(), and SVC_Handler_C().
| bool sem_can_consume | ( | uint8_t | semaphore_idx | ) |
Check if semaphore can be consumed (SVC call gate)
| semaphore_idx | Semaphore index |
Check if semaphore can be consumed (SVC call gate)
Definition at line 967 of file svc.c.
References __sem_can_consume(), and SVC_SEM_CAN_CONSUME.
Referenced by __semaphore_consume(), and __semaphore_consume_timeout().
| bool sem_can_feed | ( | uint8_t | semaphore_idx | ) |
Check if semaphore can accept a feed (SVC call gate)
| semaphore_idx | Semaphore index |
Check if semaphore can accept a feed (SVC call gate)
Definition at line 946 of file svc.c.
References __sem_can_feed(), and SVC_SEM_CAN_FEED.
Referenced by __semaphore_feed().
| void sem_decrement | ( | uint8_t | semaphore_idx | ) |
Decrement semaphore count (SVC call gate)
| semaphore_idx | Semaphore index |
Decrement semaphore count (SVC call gate)
Definition at line 1056 of file svc.c.
References __sem_decrement(), and SVC_SEM_DECREMENT.
Referenced by __semaphore_consume(), and __semaphore_consume_timeout().
| void sem_increment | ( | uint8_t | semaphore_idx | ) |
Increment semaphore count (SVC call gate)
| semaphore_idx | Semaphore index |
Increment semaphore count (SVC call gate)
Definition at line 1038 of file svc.c.
References __sem_increment(), and SVC_SEM_INCREMENT.
Referenced by __semaphore_feed().
| bool semaphore_consume | ( | uint8_t | semaphore_idx | ) |
Decrement semaphore count (P operation / wait)
| semaphore_idx | Semaphore index |
Decrement semaphore count (P operation / wait)
Definition at line 807 of file svc.c.
References __semaphore_consume().
| bool semaphore_consume_timeout | ( | uint8_t | semaphore_idx, |
| uint32_t | max_ticks | ||
| ) |
Decrement semaphore count with timeout (timed P / wait).
| semaphore_idx | Semaphore index. |
| max_ticks | Maximum ticks to wait. 0 = non-blocking try. |
| true | Semaphore was acquired within the timeout. |
| false | Timeout expired without acquiring, or invalid index. |
Decrement semaphore count with timeout (timed P / wait).
Definition at line 814 of file svc.c.
References __semaphore_consume_timeout().
| bool semaphore_feed | ( | uint8_t | semaphore_idx | ) |
Increment semaphore count (V operation / signal)
| semaphore_idx | Semaphore index |
Increment semaphore count (V operation / signal)
Definition at line 800 of file svc.c.
References __semaphore_feed().
| uint32_t semaphore_get_count | ( | uint8_t | semaphore_idx | ) |
Get current semaphore count.
| semaphore_idx | Semaphore index |
Definition at line 821 of file svc.c.
References __semaphore_get_count(), and SVC_SEMAPHORE_GET_COUNT.
| uint32_t semaphore_get_max_count | ( | uint8_t | semaphore_idx | ) |
Get semaphore maximum count.
| semaphore_idx | Semaphore index |
Definition at line 841 of file svc.c.
References __semaphore_get_max_count(), and SVC_SEMAPHORE_GET_MAX_COUNT.
| bool semaphore_init | ( | uint8_t | semaphore_idx, |
| uint32_t | semaphore_count | ||
| ) |
Initialize a counting semaphore.
| semaphore_idx | Semaphore index (0 to ICARUS_MAX_SEMAPHORES-1) |
| semaphore_count | Initial and maximum count |
Definition at line 778 of file svc.c.
References __semaphore_init(), and SVC_SEMAPHORE_INIT.