The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
poll.h File Reference
#include "common/stdint.h"

Go to the source code of this file.

Macros

#define POLLIN   0x001
 readiness of open files, for poll and select.
#define POLLPRI   0x002
#define POLLOUT   0x004
#define POLLERR   0x008
#define POLLHUP   0x010
#define POLLNVAL   0x020

Functions

void poll_init (void)
 set up the poll queue.
void poll_notify (void)
 wake every process in poll: some file's readiness may have changed.
uint32_t poll_snapshot (void)
 read the notify counter.
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 returned seen.

Macro Definition Documentation

◆ POLLIN

#define POLLIN   0x001

readiness of open files, for poll and select.

each kind of file reports its readiness through file_ops_t::poll. a process in poll sleeps on one shared queue; whatever can change some file's readiness (pipe reads, writes and closes, a key press) calls poll_notify, and every poller checks its files again.

◆ POLLPRI

#define POLLPRI   0x002

◆ POLLOUT

#define POLLOUT   0x004

◆ POLLERR

#define POLLERR   0x008

◆ POLLHUP

#define POLLHUP   0x010

◆ POLLNVAL

#define POLLNVAL   0x020

Function Documentation

◆ poll_init()

void poll_init ( void )

set up the poll queue.

call once at boot, before the first poll.

◆ poll_notify()

void poll_notify ( void )

wake every process in poll: some file's readiness may have changed.

safe to call from an interrupt handler.

◆ poll_snapshot()

uint32_t poll_snapshot ( void )

read the notify counter.

call it before the readiness check, and give the value to poll_wait: a notify between the check and the sleep then stops the sleep.

Returns
the counter.

◆ 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 returned seen.

Parameters
deadlinethe tick to wake at, or TIMER_NEVER.
seenthe value from poll_snapshot.