+ kputs("> Main: Processes created\n");
+ /* Synchronize on start */
+ while (1)
+ {
+ for (i = 0; i < TASKS; i++)
+ if (!barrier[i])
+ break;
+ if (i == TASKS)
+ break;
+ proc_yield();
+ }
+ /* Now all threads have been created, start them all */
+ main_barrier = 1;
+ MEMORY_BARRIER;
+ kputs("> Main: Processes started\n");
+ while (1)
+ {
+ for (i = 0; i < TASKS; i++)
+ {
+ if (!preempt_done[i])
+ break;
+ else if (preempt_done[i] == TEST_FAIL)
+ {
+ kputs("> Main: process test finished..fail!\n");
+ return -1;
+ }
+ }
+ if (i == TASKS)
+ break;
+ monitor_report();
+ timer_delay(1000);
+ }
+ for (i = 0; i < TASKS; i++)
+ score += preempt_counter[i];
+ kputs("> Main: process test finished..ok!\n");
+ kprintf("> Score: %lu\n", score);
+ return 0;
+}
+#endif /* CONFIG_KERN_PREEMPT */
+
+#if CONFIG_KERN_SIGNALS & CONFIG_KERN_PRI
+
+#define PROC_PRI_TEST_STACK(num) PROC_DEFINE_STACK(proc_test##num##_stack, KERN_MINSTACKSIZE);
+
+// Define params to test priority
+#define PROC_PRI_TEST(num) static void proc_pri_test##num(void) \
+{ \
+ struct Process *main_proc = (struct Process *) proc_currentUserData(); \
+ kputs("> Process: " #num "\n"); \
+ sig_signal(main_proc, SIG_USER##num); \
+}
+
+// Default priority is 0
+#define PROC_PRI_TEST_INIT(num, proc) \
+do { \
+ struct Process *p = proc_new(proc_pri_test##num, (proc), \
+ sizeof(proc_test##num##_stack), \
+ proc_test##num##_stack); \
+ proc_setPri(p, num + 1); \
+} while (0)
+
+PROC_PRI_TEST_STACK(0)
+PROC_PRI_TEST_STACK(1)
+PROC_PRI_TEST_STACK(2)
+
+PROC_PRI_TEST(0)
+PROC_PRI_TEST(1)
+PROC_PRI_TEST(2)
+
+static int prio_worker_test(void)
+{
+ struct Process *curr = proc_current();
+ int orig_pri = curr->link.pri;
+ int ret = 0;