aboutsummaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
Diffstat (limited to 'usr')
-rw-r--r--usr/main.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/usr/main.c b/usr/main.c
index 835cedf..0cc25d8 100644
--- a/usr/main.c
+++ b/usr/main.c
@@ -1,4 +1,6 @@
+#include <cpu.h>
#include <globals.h>
+#include <graphics/lfb.h>
#include <symbols.h>
#include <sys/schedule.h>
#include <usr/string.h>
@@ -33,6 +35,25 @@ static struct UartInfo UART_INFO = {
.priority = 2,
};
+static unsigned long simulated = 0;
+
+void producer(void)
+{
+ draw_string(0, 15, "Producing...");
+ sys1(SYS_SEMAPHORE_V, &simulated);
+ draw_string(0, 15, "Produced! ");
+}
+
+void consumer(void)
+{
+ add_thread(producer, 0, 4);
+ while (1) {
+ draw_string(0, 16, "Consuming...");
+ sys1(SYS_SEMAPHORE_P, &simulated);
+ draw_string(0, 16, "Consumed! ");
+ }
+}
+
void main(void)
{
subscribe_irq(UART_IRQ, handle_data, &UART_INFO);
@@ -40,5 +61,6 @@ void main(void)
subscribe_irq(SYS_TIMER_1_IRQ, loopt, &stime_1);
subscribe_irq(SYS_TIMER_2_IRQ, loopt, &stime_2);
subscribe_irq(SYS_TIMER_3_IRQ, loopt, &stime_3);
- add_thread(loop, 0, 0);
+ add_thread(loop, 0, 8);
+ add_thread(consumer, 0, 3);
}