formatting

This commit is contained in:
jacob 2025-07-10 12:50:44 -05:00
parent 6838c7ac02
commit a1e062f362

View File

@ -231,38 +231,15 @@ enum job_queue_kind {
NUM_JOB_QUEUE_KINDS NUM_JOB_QUEUE_KINDS
}; };
/* ========================== * struct ticket_mutex {
* Ticket mutex
* ========================== */
struct tm {
struct atomic_i64_padded ticket; struct atomic_i64_padded ticket;
struct atomic_i64_padded serving; struct atomic_i64_padded serving;
}; };
INTERNAL void tm_lock(struct tm *tm)
{
i64 ticket = atomic_i64_fetch_add(&tm->ticket.v, 1);
while (atomic_i64_fetch(&tm->serving.v) != ticket) {
ix_pause();
}
}
INTERNAL void tm_unlock(struct tm *tm)
{
atomic_i64_fetch_add(&tm->serving.v, 1);
}
struct alignas(64) job_queue { struct alignas(64) job_queue {
enum job_queue_kind kind; enum job_queue_kind kind;
struct tm lock; struct ticket_mutex lock;
struct arena *arena; struct arena *arena;
struct job_info *first; struct job_info *first;
@ -319,7 +296,7 @@ GLOBAL struct {
/* Wait lists */ /* Wait lists */
struct atomic_u64_padded waiter_wake_gen; struct atomic_u64_padded waiter_wake_gen;
struct tm wait_lists_arena_lock; struct ticket_mutex wait_lists_arena_lock;
struct arena *wait_lists_arena; struct arena *wait_lists_arena;
/* Wait tables */ /* Wait tables */
@ -330,7 +307,7 @@ GLOBAL struct {
i16 num_fibers; i16 num_fibers;
i16 first_free_fiber_id; i16 first_free_fiber_id;
struct arena *fiber_names_arena; struct arena *fiber_names_arena;
struct tm fibers_lock; struct ticket_mutex fibers_lock;
struct fiber fibers[SYS_MAX_FIBERS]; struct fiber fibers[SYS_MAX_FIBERS];
/* Jobs */ /* Jobs */
@ -360,7 +337,22 @@ INTERNAL enum sys_priority job_priority_from_queue_kind(enum job_queue_kind queu
/* ========================== *
* Ticket mutex
* ========================== */
INTERNAL void tm_lock(struct ticket_mutex *tm)
{
i64 ticket = atomic_i64_fetch_add(&tm->ticket.v, 1);
while (atomic_i64_fetch(&tm->serving.v) != ticket) {
ix_pause();
}
}
INTERNAL void tm_unlock(struct ticket_mutex *tm)
{
atomic_i64_fetch_add(&tm->serving.v, 1);
}
/* ========================== * /* ========================== *
* Scheduler * Scheduler