Spinlock save cpu flags

This commit is contained in:
2026-03-12 22:48:34 +01:00
parent 19793e9126
commit 4760818118
50 changed files with 704 additions and 461 deletions

View File

@@ -2,3 +2,11 @@
/// Relax the spinlock using AMD64 pause instruction
void spin_lock_relax (void) { __asm__ volatile ("pause"); }
void spin_lock_save_flags (uint64_t* flags) {
__asm__ volatile ("pushfq; cli; popq %0" : "=rm"(*flags)::"memory");
}
void spin_lock_restore_flags (uint64_t flags) {
__asm__ volatile ("pushq %0; popfq" ::"rm"(flags) : "memory", "cc");
}