mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
spinlock change
add a pause instruction in order to not completely demolish the system bus in a lock
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
#ifndef _SPINLOCK_H_INCLUDE
|
#ifndef _SPINLOCK_H_INCLUDE
|
||||||
#define _SPINLOCK_H_INCLUDE
|
#define _SPINLOCK_H_INCLUDE
|
||||||
|
|
||||||
|
// TODO rewrite this in a more arch independent way
|
||||||
|
|
||||||
static inline void spinlock_acquire(int *lock){
|
static inline void spinlock_acquire(int *lock){
|
||||||
while(!__sync_bool_compare_and_swap(lock, 0, 1));
|
while(!__sync_bool_compare_and_swap(lock, 0, 1)) asm("pause");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void spinlock_release(int *lock){
|
static inline void spinlock_release(int *lock){
|
||||||
|
|||||||
Reference in New Issue
Block a user