diff --git a/examples/main.c (barrier) b/examples/main.c (barrier) index 3e2a144a..2660f4c9 100644 --- a/examples/main.c (barrier) +++ b/examples/main.c (barrier) @@ -6,14 +6,12 @@ bar_t bar = BAR_INIT(2); void slave() { bar_wait(&bar); - LED_Tick(); } void master() { tsk_delay(SEC); - bar_wait(&bar); } diff --git a/examples/main.c (demo) b/examples/main.c (demo 1) similarity index 74% rename from examples/main.c (demo) rename to examples/main.c (demo 1) index 5a149e0b..9e31b643 100644 --- a/examples/main.c (demo) +++ b/examples/main.c (demo 1) @@ -28,10 +28,10 @@ int main() LED_Config(); GRN_Config(); - tsk_start(TSK_CREATE(proc)); - tsk_start(TSK_CREATE(proc)); - tsk_start(TSK_CREATE(proc)); - tsk_start(TSK_CREATE(proc)); - tsk_start(TSK_CREATE(proc)); + tsk_start((tsk_id)TSK_CREATE(proc)); + tsk_start((tsk_id)TSK_CREATE(proc)); + tsk_start((tsk_id)TSK_CREATE(proc)); + tsk_start((tsk_id)TSK_CREATE(proc)); + tsk_start((tsk_id)TSK_CREATE(proc)); tsk_stop(); } diff --git a/examples/main.c (demo 2) b/examples/main.c (demo 2) new file mode 100644 index 00000000..0fb073c3 --- /dev/null +++ b/examples/main.c (demo 2) @@ -0,0 +1,30 @@ +#include +#include + +void proc(volatile unsigned *led, unsigned timePoint) +{ + for (;;) + { + tsk_sleepUntil(timePoint += SEC/2); + (*led)++; + } +} + +OS_DEF(t1) { proc(&LED[0], SEC/8*0); } +OS_DEF(t2) { proc(&LED[1], SEC/8*1); } +OS_DEF(t3) { proc(&LED[2], SEC/8*2); } +OS_DEF(t4) { proc(&LED[3], SEC/8*3); } +OS_DEF(t5) { proc(&GRN, SEC/8*4); } + +int main() +{ + LED_Config(); + GRN_Config(); + + tsk_start(t1); + tsk_start(t2); + tsk_start(t3); + tsk_start(t4); + tsk_start(t5); + tsk_stop(); +} diff --git a/examples/main.c (flag) b/examples/main.c (flag) index f3ae0c14..82fc8e4b 100644 --- a/examples/main.c (flag) +++ b/examples/main.c (flag) @@ -6,18 +6,14 @@ flg_t flg = FLG_INIT(); void slave() { flg_wait(&flg, 3, flgAll); - LED_Tick(); } void master() { tsk_delay(SEC/2); - flg_give(&flg, 1); - tsk_delay(SEC/2); - flg_give(&flg, 2); } diff --git a/examples/main.c (infinite loop) b/examples/main.c (infinite loop) index f65f96e1..339ba699 100644 --- a/examples/main.c (infinite loop) +++ b/examples/main.c (infinite loop) @@ -8,7 +8,6 @@ int main() for (;;) { tsk_delay(SEC); - LED_Tick(); } } diff --git a/examples/main.c (mailbox queue) b/examples/main.c (mailbox queue) index abe1824d..c7a11710 100644 --- a/examples/main.c (mailbox queue) +++ b/examples/main.c (mailbox queue) @@ -10,7 +10,6 @@ void slave() for (;;) { box_wait(&box, &x); - LEDs = x; } } @@ -22,9 +21,7 @@ void master() for (;;) { tsk_delay(SEC); - x++; - box_give(&box, &x); } } diff --git a/examples/main.c (message queue) b/examples/main.c (message queue) index 9eed5ffe..9ac22077 100644 --- a/examples/main.c (message queue) +++ b/examples/main.c (message queue) @@ -10,7 +10,6 @@ void slave() for (;;) { msg_wait(&msg, &x); - LEDs = x; } } @@ -22,7 +21,6 @@ void master() for (;;) { tsk_delay(SEC); - msg_give(&msg, ++x); } } diff --git a/examples/main.c (mutex) b/examples/main.c (mutex) index 32f2d90b..5acd4203 100644 --- a/examples/main.c (mutex) +++ b/examples/main.c (mutex) @@ -6,18 +6,14 @@ mtx_t mtx = MTX_INIT(); void slave() { mtx_wait(&mtx); - LED_Tick(); - mtx_give(&mtx); } void master() { mtx_wait(&mtx); - tsk_delay(SEC); - mtx_give(&mtx); } diff --git a/examples/main.c (semaphore) b/examples/main.c (semaphore) index 234d98df..9aba1881 100644 --- a/examples/main.c (semaphore) +++ b/examples/main.c (semaphore) @@ -6,14 +6,12 @@ sem_t sem = SEM_INIT(0); void slave() { sem_wait(&sem); - LED_Tick(); } void master() { tsk_delay(SEC); - sem_give(&sem); } diff --git a/examples/main.c (signal 1) b/examples/main.c (signal 1) index a02db027..0311098a 100644 --- a/examples/main.c (signal 1) +++ b/examples/main.c (signal 1) @@ -6,14 +6,12 @@ sig_t sig = SIG_INIT(sigClear); void slave() { sig_wait(&sig); - LED_Tick(); } void master() { tsk_delay(SEC); - sig_give(&sig); } diff --git a/examples/main.c (signal 2) b/examples/main.c (signal 2) index fc6c1c45..450af22f 100644 --- a/examples/main.c (signal 2) +++ b/examples/main.c (signal 2) @@ -6,14 +6,12 @@ sig_id sig = SIG_CREATE(sigClear); void slave() { sig_wait(sig); - LED_Tick(); } void master() { tsk_delay(SEC); - sig_give(sig); } @@ -21,7 +19,7 @@ int main() { LED_Config(); - tsk_start(TSK_CREATE(slave)); - tsk_start(TSK_CREATE(master)); + tsk_start((tsk_id)TSK_CREATE(slave)); + tsk_start((tsk_id)TSK_CREATE(master)); tsk_sleep(); } diff --git a/examples/main.c (timer 1) b/examples/main.c (timer 1) index b1f08206..49144cbf 100644 --- a/examples/main.c (timer 1) +++ b/examples/main.c (timer 1) @@ -7,7 +7,6 @@ tmr_t tmr = TMR_INIT(); void slave() { sem_wait(&sem); - LED_Tick(); } diff --git a/examples/main.c (tsk_flip) b/examples/main.c (tsk_flip) index a0506ab3..6ead33ce 100644 --- a/examples/main.c (tsk_flip) +++ b/examples/main.c (tsk_flip) @@ -7,7 +7,6 @@ void master(void); void slave() { LED_Tick(); - tsk_flip(master); } @@ -16,7 +15,6 @@ void master() static unsigned time = 0; tsk_sleepUntil(time += SEC); - tsk_flip(slave); } diff --git a/examples/main.c (tsk_startFrom) b/examples/main.c (tsk_startFrom) index df3f64af..9c0c7d00 100644 --- a/examples/main.c (tsk_startFrom) +++ b/examples/main.c (tsk_startFrom) @@ -6,7 +6,6 @@ tsk_t tsk = TSK_INIT(0); void slave() { LED_Tick(); - tsk_stop(); } @@ -17,7 +16,6 @@ void master() for (;;) { tsk_sleepUntil(time += SEC); - tsk_startFrom(&tsk, slave); } }