-static void proc_test2(void)
-{
- unsigned int local_count = 0;
-
- for (int i = 0; i < INC_PROC_T2; ++i)
- {
- kputs("> test2\n");
- sem_obtain(&sem);
- kputs("> test2: Obtain semaphore.\n");
- local_count = global_count;
- kprintf("> test2: Read global count [%d]\n", local_count);
- timer_delay(DELAY_PROC_T2);
- local_count += INC_PROC_T2;
- global_count = local_count;
- kprintf("> test2: Update count g[%d] l[%d]\n", global_count, local_count);
- sem_release(&sem);
- kputs("> test2: Relase semaphore.\n");
- }
-}
+#define PROC_TEST(num) static void proc_semTest##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) PROC_DEFINE_STACK(proc_sem_test##num##_stack, KERN_MINSTACKSIZE * 2)
+#define PROC_TEST_INIT(num) proc_new(proc_semTest##num, NULL, sizeof(proc_sem_test##num##_stack), proc_sem_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)