#include "smp.h"
#include "error.h"
#include <mm/slab.h>
#include <lock.h>
#include <stdatomic.h>
#include <kprint.h>
#include <string.h>

struct ma_cache *mutex_cache;

void acquire_spinlock(atomic_flag *lock){

    while(atomic_flag_test_and_set_explicit(lock, memory_order_acquire)){
        asm volatile("pause");
    }

    atomic_thread_fence(memory_order_acquire);
}

void free_spinlock(atomic_flag *lock){
    atomic_flag_clear_explicit(lock, memory_order_release);
}