The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
poll.h
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* readiness of open files, for poll and select.
5
*
6
* each kind of file reports its readiness through file_ops_t::poll. a
7
* process in poll sleeps on one shared queue; whatever can change some
8
* file's readiness (pipe reads, writes and closes, a key press) calls
9
* poll_notify, and every poller checks its files again.
10
*/
11
12
#include "
common/stdint.h
"
13
14
// poll events (ABI, as in libc poll.h)
15
#define POLLIN 0x001
// data to read (or EOF)
16
#define POLLPRI 0x002
// urgent data (never set)
17
#define POLLOUT 0x004
// room to write
18
#define POLLERR 0x008
// an error (a pipe with no reader left)
19
#define POLLHUP 0x010
// hung up (a pipe with no writer left)
20
#define POLLNVAL 0x020
// not an open descriptor
21
22
/**
23
* set up the poll queue. call once at boot, before the first poll.
24
*/
25
void
poll_init
(
void
);
26
27
/**
28
* wake every process in poll: some file's readiness may have changed.
29
* safe to call from an interrupt handler.
30
*/
31
void
poll_notify
(
void
);
32
33
/**
34
* read the notify counter. call it before the readiness check, and give
35
* the value to poll_wait: a notify between the check and the sleep then
36
* stops the sleep.
37
* @return the counter.
38
*/
39
uint32_t
poll_snapshot
(
void
);
40
41
/**
42
* sleep until poll_notify, a signal or the deadline tick, unless a notify
43
* came after poll_snapshot returned seen.
44
* @param deadline the tick to wake at, or TIMER_NEVER.
45
* @param seen the value from poll_snapshot.
46
*/
47
void
poll_wait
(
uint64_t
deadline,
uint32_t
seen);
stdint.h
uint32_t
unsigned int uint32_t
Definition
fb.h:17
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:17
poll_wait
void poll_wait(uint64_t deadline, uint32_t seen)
sleep until poll_notify, a signal or the deadline tick, unless a notify came after poll_snapshot retu...
Definition
poll.c:27
poll_notify
void poll_notify(void)
wake every process in poll: some file's readiness may have changed.
Definition
poll.c:16
poll_init
void poll_init(void)
set up the poll queue.
Definition
poll.c:11
poll_snapshot
uint32_t poll_snapshot(void)
read the notify counter.
Definition
poll.c:22
src
kernel
vfs
poll.h
Generated by
1.18.0