PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
Go to the source code of this file.
Data Structures | |
struct | intq |
A circular queue of bytes. More... | |
Macros | |
#define | INTQ_BUFSIZE 64 |
An "interrupt queue", a circular buffer shared between kernel threads and external interrupt handlers. More... | |
Functions | |
void | intq_init (struct intq *) |
Initializes interrupt queue Q. More... | |
bool | intq_empty (const struct intq *) |
Returns true if Q is empty, false otherwise. More... | |
bool | intq_full (const struct intq *) |
Returns true if Q is full, false otherwise. More... | |
uint8_t | intq_getc (struct intq *) |
Removes a byte from Q and returns it. More... | |
void | intq_putc (struct intq *, uint8_t) |
devices/intq.h More... | |
#define INTQ_BUFSIZE 64 |
An "interrupt queue", a circular buffer shared between kernel threads and external interrupt handlers.
Interrupt queue functions can be called from kernel threads or from external interrupt handlers. Except for intq_init(), interrupts must be off in either case.
The interrupt queue has the structure of a "monitor". Locks and condition variables from threads/synch.h cannot be used in this case, as they normally would, because they can only protect kernel threads from one another, not from interrupt handlers. Queue buffer size, in bytes.
Returns true if Q is empty, false otherwise.
Definition at line 20 of file intq.c.
References ASSERT, intq::head, intr_get_level(), INTR_OFF, and intq::tail.
Referenced by intq_getc(), serial_flush(), serial_interrupt(), signal(), wait(), and write_ier().
Returns true if Q is full, false otherwise.
Definition at line 28 of file intq.c.
References ASSERT, intq::head, intr_get_level(), INTR_OFF, next(), and intq::tail.
Referenced by input_full(), input_putc(), intq_putc(), serial_putc(), signal(), and wait().
Removes a byte from Q and returns it.
If Q is empty, sleeps until a byte is added. When called from an interrupt handler, Q must not be empty.
Definition at line 38 of file intq.c.
References ASSERT, intq::buf, intq_empty(), intr_context(), intr_get_level(), INTR_OFF, intq::lock, lock_acquire(), lock_release(), next(), intq::not_empty, intq::not_full, signal(), intq::tail, and wait().
Referenced by input_getc(), serial_flush(), serial_interrupt(), and serial_putc().
void intq_init | ( | struct intq * | q | ) |
Initializes interrupt queue Q.
Definition at line 11 of file intq.c.
References intq::head, intq::lock, lock_init(), intq::not_empty, intq::not_full, NULL, and intq::tail.
Referenced by init_poll(), and input_init().
If Q is full, sleeps until a byte is removed. When called from an interrupt handler, Q must not be full.
Definition at line 61 of file intq.c.
References ASSERT, intq::buf, intq::head, intq_full(), intr_context(), intr_get_level(), INTR_OFF, intq::lock, lock_acquire(), lock_release(), next(), intq::not_empty, intq::not_full, signal(), and wait().
Referenced by input_putc(), and serial_putc().