+unsigned int global_count = 0;
+
+/*
+ * These macros generate the code needed to create the test process functions.
+ */
+#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) static cpu_stack_t proc_sem_test##num##_stack[1024 / sizeof(cpu_stack_t)];
+#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)
+
+// Define process stacks for test.
+PROC_TEST_STACK(1)
+PROC_TEST_STACK(2)
+PROC_TEST_STACK(3)
+PROC_TEST_STACK(4)
+PROC_TEST_STACK(5)
+PROC_TEST_STACK(6)
+PROC_TEST_STACK(7)
+PROC_TEST_STACK(8)