PKUOS - Pintos
Pintos source browser for PKU Operating System course
Functions
intq.c File Reference
#include "devices/intq.h"
#include <debug.h>
#include "threads/thread.h"
Include dependency graph for intq.c:

Go to the source code of this file.

Functions

static int next (int pos)
 Returns the position after POS within an intq. More...
 
static void wait (struct intq *q, struct thread **waiter)
 
static void signal (struct intq *q, struct thread **waiter)
 
void intq_init (struct intq *q)
 Initializes interrupt queue Q. More...
 
bool intq_empty (const struct intq *q)
 Returns true if Q is empty, false otherwise. More...
 
bool intq_full (const struct intq *q)
 Returns true if Q is full, false otherwise. More...
 
uint8_t intq_getc (struct intq *q)
 Removes a byte from Q and returns it. More...
 
void intq_putc (struct intq *q, uint8_t byte)
 Adds BYTE to the end of Q. More...
 
static void wait (struct intq *q UNUSED, struct thread **waiter)
 WAITER must be the address of Q's not_empty or not_full member. More...
 
static void signal (struct intq *q UNUSED, struct thread **waiter)
 WAITER must be the address of Q's not_empty or not_full member, and the associated condition must be true. More...
 

Function Documentation

◆ intq_empty()

bool intq_empty ( const struct intq q)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intq_full()

bool intq_full ( const struct intq q)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intq_getc()

uint8_t intq_getc ( struct intq q)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intq_init()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intq_putc()

void intq_putc ( struct intq q,
uint8_t  byte 
)

Adds BYTE to the end of Q.

devices/intq.h

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ next()

static int next ( int  pos)
static

Returns the position after POS within an intq.

Definition at line 79 of file intq.c.

References INTQ_BUFSIZE.

Referenced by hash_apply(), intq_full(), intq_getc(), intq_putc(), list_unique(), rehash(), and schedule().

Here is the caller graph for this function:

◆ signal() [1/2]

static void signal ( struct intq *q  UNUSED,
struct thread **  waiter 
)
static

WAITER must be the address of Q's not_empty or not_full member, and the associated condition must be true.

If a thread is waiting for the condition, wakes it up and resets the waiting thread.

Definition at line 103 of file intq.c.

References ASSERT, intq_empty(), intq_full(), intr_get_level(), INTR_OFF, NULL, and thread_unblock().

Here is the call graph for this function:

◆ signal() [2/2]

static void signal ( struct intq q,
struct thread **  waiter 
)
static

Referenced by intq_getc(), intq_putc(), and main().

Here is the caller graph for this function:

◆ wait() [1/2]

static void wait ( struct intq *q  UNUSED,
struct thread **  waiter 
)
static

WAITER must be the address of Q's not_empty or not_full member.

Waits until the given condition is true.

Definition at line 87 of file intq.c.

References ASSERT, intq_empty(), intq_full(), intr_context(), intr_get_level(), INTR_OFF, thread_block(), and thread_current().

Here is the call graph for this function:

◆ wait() [2/2]

static void wait ( struct intq q,
struct thread **  waiter 
)
static

Referenced by intq_getc(), intq_putc(), main(), sort_chunks(), test_main(), and wait_children().

Here is the caller graph for this function: