Changeset 5110d0a in mainline for kernel/generic/src/synch/semaphore.c
- Timestamp:
- 2023-02-07T16:02:50Z (14 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7c5320c
- Parents:
- 8a55346
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-06 16:44:26)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-07 16:02:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/semaphore.c
r8a55346 r5110d0a 53 53 { 54 54 waitq_initialize(&sem->wq); 55 waitq_count_set(&sem->wq, val); 55 if (val != 0) 56 waitq_count_set(&sem->wq, val); 56 57 } 57 58 58 /** Semaphore down 59 * 60 * Semaphore down. 61 * Conditional mode and mode with timeout can be requested. 59 errno_t _semaphore_down_timeout(semaphore_t *sem, uint32_t usec, unsigned flags) 60 { 61 errno_t rc = waitq_sleep_timeout(&sem->wq, usec, flags, NULL); 62 assert(rc == EOK || rc == ETIMEOUT || rc == EAGAIN); 63 return rc; 64 } 65 66 errno_t semaphore_trydown(semaphore_t *sem) 67 { 68 return _semaphore_down_timeout(sem, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING); 69 } 70 71 /** Semaphore down with timeout 62 72 * 63 73 * @param sem Semaphore. 64 74 * @param usec Timeout in microseconds. 65 * @param flags Select mode of operation.66 *67 * For exact description of possible combinations of68 * usec and flags, see comment for waitq_sleep_timeout().69 75 * 70 76 * @return See comment for waitq_sleep_timeout(). 71 77 * 72 78 */ 73 errno_t _semaphore_down_timeout(semaphore_t *sem, uint32_t usec, unsigned int flags)79 errno_t semaphore_down_timeout(semaphore_t *sem, uint32_t usec) 74 80 { 75 return waitq_sleep_timeout(&sem->wq, usec, flags, NULL); 81 return _semaphore_down_timeout(sem, usec, SYNCH_FLAGS_NON_BLOCKING); 82 } 83 84 void semaphore_down(semaphore_t *sem) 85 { 86 errno_t rc = waitq_sleep(&sem->wq); 87 assert(rc == EOK); 76 88 } 77 89
Note:
See TracChangeset
for help on using the changeset viewer.