#ifndef _KERNEL_PROC_MUTEX_H
#define _KERNEL_PROC_MUTEX_H

#include <libk/list.h>
#include <libk/std.h>
#include <proc/suspension_q.h>

struct proc;
struct proc_resource;
struct cpu;
struct reschedule_ctx;

struct proc_mutex {
  struct proc_resource* resource;

  bool locked;
  struct proc_suspension_q suspension_q;
  struct proc* owner;
};

void proc_cleanup_resource_mutex (struct proc_resource* resource, struct reschedule_ctx* rctx);

void proc_mutex_lock (struct proc* proc, struct proc_mutex* mutex, struct reschedule_ctx* rctx);

void proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex, struct reschedule_ctx* rctx);

void proc_mutexes_cleanup (struct proc* proc, struct reschedule_ctx* rctx);

#endif // _KERNEL_PROC_MUTEX_H
