Changeset 5110d0a in mainline for kernel/generic/src/synch/condvar.c


Ignore:
Timestamp:
2023-02-07T16:02:50Z (15 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
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)
Message:

Turn a bunch of macros into regular functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/condvar.c

    r8a55346 r5110d0a  
    7676 * @param mtx           Mutex.
    7777 * @param usec          Timeout value in microseconds.
    78  * @param flags         Select mode of operation.
    79  *
    80  * For exact description of meaning of possible combinations of usec and flags,
    81  * see comment for waitq_sleep_timeout().  Note that when
    82  * SYNCH_FLAGS_NON_BLOCKING is specified here, EAGAIN is always
    83  * returned.
    8478 *
    8579 * @return              See comment for waitq_sleep_timeout().
    8680 */
    87 errno_t _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, int flags)
     81errno_t condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec)
    8882{
    8983        errno_t rc;
     
    9690
    9791        cv->wq.missed_wakeups = 0;      /* Enforce blocking. */
    98         rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, flags, &blocked);
     92        rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, SYNCH_FLAGS_NON_BLOCKING, &blocked);
     93        assert(blocked || rc != EOK);
     94
     95        waitq_sleep_finish(&cv->wq, blocked, ipl);
     96        /* Lock only after releasing the waitq to avoid a possible deadlock. */
     97        mutex_lock(mtx);
     98
     99        return rc;
     100}
     101
     102errno_t condvar_wait(condvar_t *cv, mutex_t *mtx)
     103{
     104        errno_t rc;
     105        ipl_t ipl;
     106        bool blocked;
     107
     108        ipl = waitq_sleep_prepare(&cv->wq);
     109        /* Unlock only after the waitq is locked so we don't miss a wakeup. */
     110        mutex_unlock(mtx);
     111
     112        cv->wq.missed_wakeups = 0;      /* Enforce blocking. */
     113        rc = waitq_sleep_unsafe(&cv->wq, &blocked);
    99114        assert(blocked || rc != EOK);
    100115
Note: See TracChangeset for help on using the changeset viewer.