[Krafton Jungle] PintOS 2.0.0
크래프톤 정글 PintOS
 
Loading...
Searching...
No Matches
intq.h
Go to the documentation of this file.
1#ifndef DEVICES_INTQ_H
2#define DEVICES_INTQ_H
3
4#include "threads/interrupt.h"
5#include "threads/synch.h"
6
7/* An "interrupt queue", a circular buffer shared between
8 kernel threads and external interrupt handlers.
9
10 Interrupt queue functions can be called from kernel threads or
11 from external interrupt handlers. Except for intq_init(),
12 interrupts must be off in either case.
13
14 The interrupt queue has the structure of a "monitor". Locks
15 and condition variables from threads/synch.h cannot be used in
16 this case, as they normally would, because they can only
17 protect kernel threads from one another, not from interrupt
18 handlers. */
19
20/* Queue buffer size, in bytes. */
21#define INTQ_BUFSIZE 64
22
23/* A circular queue of bytes. */
24struct intq {
25 /* Waiting threads. */
26 struct lock lock; /* Only one thread may wait at once. */
27 struct thread *not_full; /* Thread waiting for not-full condition. */
28 struct thread *not_empty; /* Thread waiting for not-empty condition. */
29
30 /* Queue. */
31 uint8_t buf[INTQ_BUFSIZE]; /* Buffer. */
32 int head; /* New data is written here. */
33 int tail; /* Old data is read here. */
34};
35
36void intq_init (struct intq *);
37bool intq_empty (const struct intq *);
38bool intq_full (const struct intq *);
39uint8_t intq_getc (struct intq *);
40void intq_putc (struct intq *, uint8_t);
41
42#endif /* devices/intq.h */
void intq_init(struct intq *)
Definition: intq.c:11
bool intq_empty(const struct intq *)
Definition: intq.c:19
bool intq_full(const struct intq *)
Definition: intq.c:26
#define INTQ_BUFSIZE
Definition: intq.h:21
uint8_t intq_getc(struct intq *)
Definition: intq.c:36
void intq_putc(struct intq *, uint8_t)
Definition: intq.c:58
unsigned char uint8_t
Definition: stdint.h:20
Definition: intq.h:24
struct thread * not_empty
Definition: intq.h:28
int head
Definition: intq.h:32
int tail
Definition: intq.h:33
uint8_t buf[INTQ_BUFSIZE]
Definition: intq.h:31
struct thread * not_full
Definition: intq.h:27
Definition: synch.h:20
Definition: thread.h:100