[Krafton Jungle] PintOS 2.0.0
크래프톤 정글 PintOS
 
Loading...
Searching...
No Matches
intq.c File Reference
#include "devices/intq.h"
#include <debug.h>
#include "threads/thread.h"
Include dependency graph for intq.c:

Functions

static int next (int pos)
 
static void wait (struct intq *q, struct thread **waiter)
 
static void signal (struct intq *q, struct thread **waiter)
 
void intq_init (struct intq *q)
 
bool intq_empty (const struct intq *q)
 
bool intq_full (const struct intq *q)
 
uint8_t intq_getc (struct intq *q)
 
void intq_putc (struct intq *q, uint8_t byte)
 
static void wait (struct intq *q UNUSED, struct thread **waiter)
 
static void signal (struct intq *q UNUSED, struct thread **waiter)
 

Function Documentation

◆ intq_empty()

bool intq_empty ( const struct intq q)
19 {
21 return q->head == q->tail;
22}
#define ASSERT(CONDITION)
Definition: debug.h:30
@ INTR_OFF
Definition: interrupt.h:9
enum intr_level intr_get_level(void)
Definition: interrupt.c:115
int head
Definition: intq.h:32
int tail
Definition: intq.h:33
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)
26 {
28 return next (q->head) == q->tail;
29}
static int next(int pos)
Definition: intq.c:74
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)
36 {
37 uint8_t byte;
38
40 while (intq_empty (q)) {
41 ASSERT (!intr_context ());
42 lock_acquire (&q->lock);
43 wait (q, &q->not_empty);
44 lock_release (&q->lock);
45 }
46
47 byte = q->buf[q->tail];
48 q->tail = next (q->tail);
49 signal (q, &q->not_full);
50 return byte;
51}
bool intr_context(void)
Definition: interrupt.c:258
static void wait(struct intq *q, struct thread **waiter)
bool intq_empty(const struct intq *q)
Definition: intq.c:19
static void signal(struct intq *q, struct thread **waiter)
unsigned char uint8_t
Definition: stdint.h:20
struct lock lock
Definition: intq.h:26
struct thread * not_empty
Definition: intq.h:28
uint8_t buf[INTQ_BUFSIZE]
Definition: intq.h:31
struct thread * not_full
Definition: intq.h:27
void lock_release(struct lock *)
Definition: synch.c:243
void lock_acquire(struct lock *)
Definition: synch.c:202
Here is the call graph for this function:
Here is the caller graph for this function:

◆ intq_init()

void intq_init ( struct intq q)
11 {
12 lock_init (&q->lock);
13 q->not_full = q->not_empty = NULL;
14 q->head = q->tail = 0;
15}
#define NULL
Definition: stddef.h:4
void lock_init(struct lock *)
Definition: synch.c:186
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 
)
58 {
60 while (intq_full (q)) {
61 ASSERT (!intr_context ());
62 lock_acquire (&q->lock);
63 wait (q, &q->not_full);
64 lock_release (&q->lock);
65 }
66
67 q->buf[q->head] = byte;
68 q->head = next (q->head);
69 signal (q, &q->not_empty);
70}
bool intq_full(const struct intq *q)
Definition: intq.c:26
Here is the call graph for this function:
Here is the caller graph for this function:

◆ next()

static int next ( int  pos)
static
74 {
75 return (pos + 1) % INTQ_BUFSIZE;
76}
#define INTQ_BUFSIZE
Definition: intq.h:21
Here is the caller graph for this function:

◆ signal() [1/2]

static void signal ( struct intq *q  UNUSED,
struct thread **  waiter 
)
static
96 {
98 ASSERT ((waiter == &q->not_empty && !intq_empty (q))
99 || (waiter == &q->not_full && !intq_full (q)));
100
101 if (*waiter != NULL) {
102 thread_unblock (*waiter);
103 *waiter = NULL;
104 }
105}
void thread_unblock(struct thread *)
Definition: thread.c:275
Here is the call graph for this function:

◆ signal() [2/2]

static void signal ( struct intq q,
struct thread **  waiter 
)
static
Here is the caller graph for this function:

◆ wait() [1/2]

static void wait ( struct intq *q  UNUSED,
struct thread **  waiter 
)
static
81 {
82 ASSERT (!intr_context ());
84 ASSERT ((waiter == &q->not_empty && intq_empty (q))
85 || (waiter == &q->not_full && intq_full (q)));
86
87 *waiter = thread_current ();
88 thread_block ();
89}
struct thread * thread_current(void)
Definition: thread.c:301
void thread_block(void)
Definition: thread.c:258
Here is the call graph for this function:

◆ wait() [2/2]

static void wait ( struct intq q,
struct thread **  waiter 
)
static
Here is the caller graph for this function: