sched: split sched.h into separate header files

This commit is contained in:
2026-03-12 20:29:36 +00:00
parent de520cdd2d
commit 3f21e888d6
29 changed files with 268 additions and 201 deletions

37
include/kernel/work.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef KERNEL_WORK_H_
#define KERNEL_WORK_H_
#include <kernel/locks.h>
#include <kernel/queue.h>
#include <stddef.h>
struct work_item;
typedef void (*work_func_t)(struct work_item *);
struct work_item {
void *w_data;
work_func_t w_func;
struct queue_entry w_head;
};
struct worker_pool {
struct thread **wp_workers;
size_t wp_nworkers;
};
struct workqueue {
spin_lock_t wq_lock;
struct queue wq_queue; /* list of struct work_item */
};
extern void work_item_init(work_func_t func, void *data, struct work_item *out);
extern void workqueue_init(struct workqueue *wq);
extern struct worker_pool *worker_pool_create(size_t nworkers);
extern struct worker_pool *global_worker_pool(void);
extern bool schedule_work_on(struct workqueue *wq, struct work_item *work);
extern bool schedule_work(struct work_item *work);
extern void wake_workers(struct workqueue *wq, struct worker_pool *pool);
#endif