PMM and liballoc port

This commit is contained in:
2025-12-17 22:42:48 +01:00
parent 13fee12f59
commit f60d8d6861
32 changed files with 1202 additions and 12 deletions

1
kernel/sync/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.o

12
kernel/sync/spin_lock.c Normal file
View File

@@ -0,0 +1,12 @@
#include <libk/std.h>
#include <sys/spin_lock.h>
#include <sync/spin_lock.h>
void spin_lock(spin_lock_t *sl) {
while (atomic_flag_test_and_set_explicit(sl, memory_order_acquire))
spin_lock_relax();
}
void spin_unlock(spin_lock_t *sl) {
atomic_flag_clear_explicit(sl, memory_order_release);
}

13
kernel/sync/spin_lock.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef _KERNEL_SYNC_SPIN_LOCK_H
#define _KERNEL_SYNC_SPIN_LOCK_H
#include <libk/std.h>
#define SPIN_LOCK_INIT ATOMIC_FLAG_INIT
typedef atomic_flag spin_lock_t;
void spin_lock(spin_lock_t *sl);
void spin_unlock(spin_lock_t *sl);
#endif // _KERNEL_SYNC_SPIN_LOCK_H

3
kernel/sync/src.mk Normal file
View File

@@ -0,0 +1,3 @@
c += sync/spin_lock.c
o += sync/spin_lock.o