diff options
Diffstat (limited to 'kernel/ringbuffer.c')
| -rw-r--r-- | kernel/ringbuffer.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/ringbuffer.c b/kernel/ringbuffer.c index a749b16..cba7eb4 100644 --- a/kernel/ringbuffer.c +++ b/kernel/ringbuffer.c @@ -1,10 +1,14 @@ #define FOOLOS_MODULE_NAME "ringbuffer" #include "lib/logger/log.h" -// TODO: why do we disable interrupts? (Eg. kb input) - #include "ringbuffer.h" + + +// TODO: this is disabled because a kb interrupt can occur anytime +// and the kernel will need to access the ringbuffer while we are accessing! +// DO WE need a spinlock in general? do not use a global one anyway!!!! + static int sl=9; ringbuffer ringbuffer_init(uint32_t size) @@ -38,15 +42,14 @@ volatile bool ringbuffer_put(ringbuffer* f,uint8_t c) lock_release(sl); x86_int_enable(); - return true; } volatile bool ringbuffer_has(ringbuffer* f) { + x86_int_disable(); bool res=true; - x86_int_disable(); lock_spin(sl); if(f->front==f->back) @@ -54,15 +57,14 @@ volatile bool ringbuffer_has(ringbuffer* f) lock_release(sl); x86_int_enable(); - return res; } volatile uint8_t ringbuffer_get(ringbuffer* f) // non blocking . please check first { + x86_int_disable(); char c; - x86_int_disable(); lock_spin(sl); if(f->front==f->back) @@ -80,6 +82,5 @@ volatile uint8_t ringbuffer_get(ringbuffer* f) // non blocking . please check fi lock_release(sl); x86_int_enable(); - return c; } |
