Inline nops in spinlock spin routine
This commit is contained in:
parent
ee2ddd7e8c
commit
265a388c93
2 changed files with 1 additions and 2 deletions
|
@ -19,7 +19,7 @@ void spin_unlock(spinlock_t *l) {
|
||||||
|
|
||||||
// Optional: tiny pause/backoff (works even if Zihintpause isn't present).
|
// Optional: tiny pause/backoff (works even if Zihintpause isn't present).
|
||||||
// See: https://github.com/riscv/riscv-isa-manual/blob/main/src/zihintpause.adoc
|
// See: https://github.com/riscv/riscv-isa-manual/blob/main/src/zihintpause.adoc
|
||||||
void cpu_relax(void) {
|
static inline void cpu_relax(void) {
|
||||||
#if defined(__riscv_zihintpause)
|
#if defined(__riscv_zihintpause)
|
||||||
__asm__ volatile("pause");
|
__asm__ volatile("pause");
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -8,5 +8,4 @@ typedef struct {
|
||||||
void spinlock_init(spinlock_t *l);
|
void spinlock_init(spinlock_t *l);
|
||||||
bool spin_trylock(spinlock_t *l);
|
bool spin_trylock(spinlock_t *l);
|
||||||
void spin_unlock(spinlock_t *l);
|
void spin_unlock(spinlock_t *l);
|
||||||
void cpu_relax(void);
|
|
||||||
void spin_lock(spinlock_t *l);
|
void spin_lock(spinlock_t *l);
|
||||||
|
|
Loading…
Add table
Reference in a new issue