#ifndef _KERNEL_PROC_RESCHEDULE_H
#define _KERNEL_PROC_RESCHEDULE_H

#include <libk/list.h>
#include <sync/spin_lock.h>
#include <sys/smp.h>

struct reschedule_ctx {
  struct cpu* cpus[CPUS_MAX];
};

#define rctx_insert_cpu(rctx, cpu)                                                                 \
  do {                                                                                             \
    bool __found = false;                                                                          \
    for (size_t __i = 0; __i < CPUS_MAX; __i++) {                                                  \
      if ((rctx)->cpus[__i] == (cpu))                                                              \
        __found = true;                                                                            \
    }                                                                                              \
    if (!__found) {                                                                                \
      for (size_t __i = 0; __i < CPUS_MAX; __i++) {                                                \
        if ((rctx)->cpus[__i] == NULL) {                                                           \
          (rctx)->cpus[__i] = (cpu);                                                               \
          break;                                                                                   \
        }                                                                                          \
      }                                                                                            \
    }                                                                                              \
  } while (0)

#endif // _KERNEL_PROC_RESCHEDULE_H
