|
ginnOS
The reference: libc, the libraries and the kernel
|
wait for a device: sleep until its interrupt, or poll. More...
Go to the source code of this file.
Data Structures | |
| struct | completion_t |
Typedefs | |
| typedef bool(*) | completion_ready_t(void *context) |
| a function that reads the device status. | |
Functions | |
| void | completion_init (completion_t *completion, const char *name, bool use_irq) |
| initialize a completion. | |
| void | completion_signal (completion_t *completion) |
| the device has something to report. | |
| bool | completion_wait_until (completion_t *completion, completion_ready_t ready, void *context, uint32_t timeout_ms) |
| wait until ready(context) returns true. | |
wait for a device: sleep until its interrupt, or poll.
a driver starts a command, then calls completion_wait_until with a function that reads the device status. its interrupt handler calls completion_signal. the waiting process sleeps between interrupts, so the CPU runs other processes while the device works.
the wait polls instead of sleeping when:
| typedef bool(*) completion_ready_t(void *context) |
a function that reads the device status.
| void completion_init | ( | completion_t * | completion, |
| const char * | name, | ||
| bool | use_irq ) |
initialize a completion.
call once (it registers a timed queue).
| use_irq | true if the driver has an interrupt handler. |
| void completion_signal | ( | completion_t * | completion | ) |
the device has something to report.
safe in an interrupt handler.
| bool completion_wait_until | ( | completion_t * | completion, |
| completion_ready_t | ready, | ||
| void * | context, | ||
| uint32_t | timeout_ms ) |
wait until ready(context) returns true.
| timeout_ms | how long the device may take. |