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


Ignore:
Timestamp:
2019-02-01T22:30:53Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Parents:
1a37496
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-01 22:12:04)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-01 22:30:53)
Message:

Change the meaning of counter in fibril mutex

Previously analogous to semaphore tokens, initially 1 and
counting downward into negative numbers.

Now the number of fibrils currently accessing or waiting for access
to the critical sections. Initially 0 (unlocked mutex), and counting
up. Never negative when used correctly. Also consistent with
readers/writers counts in rwlock.

This way is IMO easier to understand.

File:
1 edited

Legend:

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

    r1a37496 r3ede440  
    4444typedef struct {
    4545        fibril_owner_info_t oi;  /**< Keep this the first thing. */
    46         int counter;
     46        int counter;  /**< # of fibrils currently waiting for or running in the critical section. */
    4747        list_t waiters;
    4848} fibril_mutex_t;
     
    5353                        .owned_by = NULL \
    5454                }, \
    55                 .counter = 1, \
     55                .counter = 0, \
    5656                .waiters = LIST_INITIALIZER((name).waiters), \
    5757        }
Note: See TracChangeset for help on using the changeset viewer.