9 asm volatile (
"cpsid i");
15 asm volatile (
"cpsie i");
49 template <
class T>
class Fifo {
53 Fifo (
const unsigned depth) : max (depth) {
55 rdi = 0; wri = 0; len = 0;
61 if (len < max) { buf [wri++] = c;
saturate (wri);
safeInc();
return true; }
68 if (len > 0) { c = buf [rdi++];
saturate (rdi);
safeDec();
return true; }
76 if (index < max)
return; index = 0;
85 volatile int rdi, wri, len;
Fifo(const unsigned depth)
Parametr konstruktoru by měla být hloubka FIFO, ale pak by musela být dynamická alokace paměti...
Definition: fifo.h:53
void safeInc(void)
Atomická inkrementace délky dat.
Definition: fifo.h:79
volatile int gblMutex
Zamykání a odemykání vlákna.
Definition: main.cpp:4
void saturate(volatile int &index)
Definition: fifo.h:74
static void fifo_unlock(void)
V tomto konkrétním případě není lock / unlock potřeba.
Definition: fifo.h:13
static void fifo_lock(void)
V tomto konkrétním případě není lock / unlock potřeba.
Definition: fifo.h:8
void safeDec(void)
Atomická dekrementace délky dat.
Definition: fifo.h:81
bool Write(const T &c)
Definition: fifo.h:60
bool Read(T &c)
Definition: fifo.h:67
[Fifo class example]
Definition: fifo.h:50