This commit is contained in:
2026-03-15 09:53:29 +01:00
parent 5eaf193d42
commit 22fea378b4
2 changed files with 34 additions and 2 deletions

View File

@@ -9,6 +9,13 @@
#include "kernel.h"
#include "spinlock.h"
/*
* spinlock_acquire - Lock a lock
* @lock: pointer to desired spinlock
*
* Saves the RFLAGS register, then acquires a lock.
* Pause instruction is used to ease the CPU.
*/
void spinlock_acquire(struct spinlock_t* lock)
{
uint64_t rflags;
@@ -21,6 +28,14 @@ void spinlock_acquire(struct spinlock_t* lock)
lock->rflags = rflags;
}
/*
* spinlock_release - Unlock a lock
* @lock: pointer to desired spinlock
*
* Gets saved RFLAGS register from the lock and
* unlocks it (clears locked state).
* RFLAGS is then restored.
*/
void spinlock_release(struct spinlock_t* lock)
{
uint64_t rflags = lock->rflags;