- * Proc scheduling test subthread 1
- */
-static void proc_test1(void)
-{
- unsigned int local_count = 0;
-
- for (int i = 0; i < INC_PROC_T1; ++i)
- {
- kputs("> test1\n");
- sem_obtain(&sem);
- kputs("> test1: Obtain semaphore.\n");
- local_count = global_count;
- kprintf("> test1: Read global count [%d]\n", local_count);
- timer_delay(DELAY_PROC_T1);
- local_count += INC_PROC_T1;
- global_count = local_count;
- kprintf("> test1: Update count g[%d] l[%d]\n", global_count, local_count);
- sem_release(&sem);
- kputs("> test1: Relase semaphore.\n");
- }
-}
-
+ * These macro generate the code that needed to create the
+ * test process function and all it needed.
+ */
+#define PROC_TEST(num) static void proc_test##num(void) \
+{ \
+ unsigned int local_count = 0; \
+ \
+ for (int i = 0; i < INC_PROC_T##num; ++i) \
+ { \
+ sem_obtain(&sem); \
+ kprintf("> test%d: Obtain semaphore.\n", num); \
+ local_count = global_count; \
+ kprintf("> test%d: Read global count [%d]\n", num, local_count); \
+ timer_delay(DELAY_PROC_T##num); \
+ local_count += INC_PROC_T##num; \
+ global_count = local_count; \
+ kprintf("> test%d: Update count g[%d] l[%d]\n", num, global_count, local_count); \
+ sem_release(&sem); \
+ kprintf("> test%d: Relase semaphore.\n", num); \
+ } \
+} \
+
+#define PROC_TEST_STACK(num) static cpu_stack_t proc_test##num##_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpu_stack_t)];
+#define PROC_TEST_INIT(num) proc_new(proc_test##num, NULL, sizeof(proc_test##num##_stack), proc_test##num##_stack);
+
+// Define process
+PROC_TEST(1)
+PROC_TEST(2)
+PROC_TEST(3)
+PROC_TEST(4)
+PROC_TEST(5)
+PROC_TEST(6)
+PROC_TEST(7)
+PROC_TEST(8)