Rev 81 | Rev 86 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 81 | Rev 82 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?xml version="1.0" encoding="UTF-8"?> |
1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <chapter id="sync"> |
2 | <chapter id="sync"> |
3 | <?dbhtml filename="sync.html"?> |
3 | <?dbhtml filename="sync.html"?> |
4 | 4 | ||
5 | <title>Mutual exclusion and synchronization</title> |
5 | <title>Synchronization</title> |
6 | 6 | ||
7 | <section> |
7 | <section> |
8 | <title>Introduction</title> |
8 | <title>Introduction</title> |
9 | 9 | ||
10 | <para>The HelenOS operating system is designed to make use of the |
10 | <para>The HelenOS operating system is designed to make use of the |
Line 509... | Line 509... | ||
509 | win the futex to sleep until the winner wakes one of them up.</para> |
509 | win the futex to sleep until the winner wakes one of them up.</para> |
510 | 510 | ||
511 | <para>A futex should be initialized by setting its userspace counter to |
511 | <para>A futex should be initialized by setting its userspace counter to |
512 | one before it is used. When locking the futex via userspace library |
512 | one before it is used. When locking the futex via userspace library |
513 | function <code>futex_down_timeout</code>, the library code atomically |
513 | function <code>futex_down_timeout</code>, the library code atomically |
514 | decrements the futex counter and tests if it droped below zero. If it |
514 | decrements the futex counter and tests if it dropped below zero. If it |
515 | did, then the futex is locked by another thread and the library uses the |
515 | did, then the futex is locked by another thread and the library uses the |
516 | <constant>SYS_FUTEX_SLEEP</constant> syscall to put the thread asleep. |
516 | <constant>SYS_FUTEX_SLEEP</constant> syscall to put the thread asleep. |
517 | If the counter decreased to 0, then there was no contention and the |
517 | If the counter decreased to 0, then there was no contention and the |
518 | thread can enter the critical section protected by the futex. When the |
518 | thread can enter the critical section protected by the futex. When the |
519 | thread later leaves that critical section, it, using library function |
519 | thread later leaves that critical section, it, using library function |