From 616b7afb724a32df41eebfaf95402d008c60b411 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 8 Sep 2010 19:13:49 -0700 Subject: 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. --- src/rt/sync/spin_lock.cpp | 48 ----------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 src/rt/sync/spin_lock.cpp (limited to 'src/rt/sync/spin_lock.cpp') diff --git a/src/rt/sync/spin_lock.cpp b/src/rt/sync/spin_lock.cpp deleted file mode 100644 index 4a113d1aef9..00000000000 --- a/src/rt/sync/spin_lock.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "../globals.h" -#include "spin_lock.h" - -/* - * Your average spin lock. - */ - -// #define TRACE - -spin_lock::spin_lock() { - unlock(); -} - -spin_lock::~spin_lock() { -} - -static inline unsigned xchg32(void *ptr, unsigned x) { - __asm__ __volatile__("xchgl %0,%1" - :"=r" ((unsigned) x) - :"m" (*(volatile unsigned *)ptr), "0" (x) - :"memory"); - return x; -} - -void spin_lock::lock() { - while (true) { - if (!xchg32(&ticket, 1)) { - return; - } - while (ticket) { - pause(); - } - } -#ifdef TRACE - printf(" lock: %d", ticket); -#endif -} - -void spin_lock::unlock() { - ticket = 0; -#ifdef TRACE - printf("unlock:"); -#endif -} - -void spin_lock::pause() { - asm volatile("pause\n" : : : "memory"); -} -- cgit 1.4.1-3-g733a5