vfs: Polling

This commit is contained in:
2026-10-25 17:40:40 +01:00
parent d63724ea61
commit ef08e2e5d7
3 changed files with 166 additions and 4 deletions
+40 -4
View File
@@ -2,7 +2,11 @@
#pragma once
#include <zinnia/list.h>
#include <zinnia/atomic.h>
#include <zinnia/errno.h>
#include <zinnia/mutex.h>
#include <zinnia/spin.h>
#include <zinnia/tailq.h>
#include <stdint.h>
#include <uapi/poll.h>
@@ -20,7 +24,39 @@ enum poll_flags : uint16_t {
POLLWRBAND = __POLLWRBAND,
};
struct poll_event {
// TODO
list_link(struct poll_event*) next;
struct task;
struct poll_table;
struct poll_event;
struct poll_waiter {
struct poll_event* event;
struct poll_table* table;
tailq_link(struct poll_waiter) link;
struct poll_waiter* next;
};
struct poll_event {
struct spinlock lock;
tailq_head(struct poll_waiter) waiters;
};
struct poll_table {
struct task* task;
void (*notify)(struct poll_table* table);
atomic_bool triggered;
struct poll_waiter* waiters;
struct poll_waiter inline_waiter;
bool inline_used;
bool interruptible;
errno_t error;
};
void poll_event_init(struct poll_event* event);
void poll_event_notify(struct poll_event* event);
void poll_table_init(struct poll_table* table);
void poll_table_init_callback(struct poll_table* table, void (*notify)(struct poll_table* table));
void poll_table_fini(struct poll_table* table);
void poll_wait(struct poll_table* table, struct poll_event* event);
errno_t poll_table_wait(struct poll_table* table, const uint64_t* deadline_ns);
errno_t poll_table_sleep(struct poll_table* table, mutex_t* lock, const uint64_t* deadline_ns);