Changeset a55d76b1 in mainline for uspace/lib/c/include/fibril_synch.h


Ignore:
Timestamp:
2018-06-13T17:07:58Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be2a20ac, c407b98
Parents:
899342e
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-13 17:04:01)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-13 17:07:58)
Message:

Implement a simple counting semaphore for fibrils.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/fibril_synch.h

    r899342e ra55d76b1  
    143143} fibril_timer_t;
    144144
     145/** A counting semaphore for fibrils. */
     146typedef struct {
     147        long count;
     148        list_t waiters;
     149} fibril_semaphore_t;
     150
     151#define FIBRIL_SEMAPHORE_INITIALIZER(name, cnt) \
     152        { \
     153                .count = (cnt), \
     154                .waiters = { \
     155                        .head = { \
     156                                .next = &(name).waiters.head, \
     157                                .prev = &(name).waiters.head, \
     158                        } \
     159                } \
     160        }
     161
     162#define FIBRIL_SEMAPHORE_INITIALIZE(name, cnt) \
     163        fibril_semaphore_t name = FIBRIL_SEMAPHORE_INITIALIZER(name, cnt)
     164
    145165extern void fibril_mutex_initialize(fibril_mutex_t *);
    146166extern void fibril_mutex_lock(fibril_mutex_t *);
     
    174194extern fibril_timer_state_t fibril_timer_clear_locked(fibril_timer_t *);
    175195
     196extern void fibril_semaphore_initialize(fibril_semaphore_t *, long);
     197extern void fibril_semaphore_up(fibril_semaphore_t *);
     198extern void fibril_semaphore_down(fibril_semaphore_t *);
     199
    176200#endif
    177201
Note: See TracChangeset for help on using the changeset viewer.