diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2010-09-08 19:13:49 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2010-09-08 19:13:49 -0700 |
| commit | 616b7afb724a32df41eebfaf95402d008c60b411 (patch) | |
| tree | 03e13578e8b43b9001cef983d1117800a6f93e65 /src/rt/sync/fair_ticket_lock.cpp | |
| parent | 13d6f874316c9f69ab3a29f120ce410da2290a64 (diff) | |
| download | rust-616b7afb724a32df41eebfaf95402d008c60b411.tar.gz rust-616b7afb724a32df41eebfaf95402d008c60b411.zip | |
Tidy up the sync dir, remove dead or mis-designed code in favour of OS primitives, switch rust_kernel to use a lock/signal pair and wait rather than spin.
Diffstat (limited to 'src/rt/sync/fair_ticket_lock.cpp')
| -rw-r--r-- | src/rt/sync/fair_ticket_lock.cpp | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/src/rt/sync/fair_ticket_lock.cpp b/src/rt/sync/fair_ticket_lock.cpp deleted file mode 100644 index 0306ee1df39..00000000000 --- a/src/rt/sync/fair_ticket_lock.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This works well as long as the number of contending threads - * is less than the number of processors. This is because of - * the fair locking scheme. If the thread that is next in line - * for acquiring the lock is not currently running, no other - * thread can acquire the lock. This is terrible for performance, - * and it seems that all fair locking schemes suffer from this - * behavior. - */ - -// #define TRACE - -fair_ticket_lock::fair_ticket_lock() { - next_ticket = now_serving = 0; -} - -fair_ticket_lock::~fair_ticket_lock() { - -} - -void fair_ticket_lock::lock() { - unsigned ticket = __sync_fetch_and_add(&next_ticket, 1); - while (now_serving != ticket) { - pause(); - } -#ifdef TRACE - printf("locked nextTicket: %d nowServing: %d", - next_ticket, now_serving); -#endif -} - -void fair_ticket_lock::unlock() { - now_serving++; -#ifdef TRACE - printf("unlocked nextTicket: %d nowServing: %d", - next_ticket, now_serving); -#endif -} - -void fair_ticket_lock::pause() { - asm volatile("pause\n" : : : "memory"); -} - |
