X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fsem_test.c;h=b6428c1be5f73314743c8ec4442b702096dfb895;hb=2b542ab21bf9f3df4e564e38e0c9db2c180449bd;hp=1638656705cc89084612b7b1ca248be3f5b0e376;hpb=855e0cde9353e94cf1b6ad6c511d4ad499ed91c2;p=bertos.git diff --git a/bertos/kern/sem_test.c b/bertos/kern/sem_test.c index 16386567..b6428c1b 100644 --- a/bertos/kern/sem_test.c +++ b/bertos/kern/sem_test.c @@ -38,6 +38,7 @@ * */ +#include #include #include @@ -48,8 +49,8 @@ // Global settings for the test. #define MAX_GLOBAL_COUNT 1024 -#define TEST_TIME_OUT_MS 4000 -#define DELAY 10 +#define TEST_TIME_OUT_MS 6000 +#define DELAY 5 // Settings for the test process. //Process 1 @@ -63,32 +64,25 @@ #define DELAY_PROC_T3 INC_PROC_T3*DELAY //Process 4 #define INC_PROC_T4 7 -#define DELAY_PROC_T4 INC_PROC_T3*DELAY +#define DELAY_PROC_T4 INC_PROC_T4*DELAY //Process 5 #define INC_PROC_T5 11 -#define DELAY_PROC_T5 INC_PROC_T3*DELAY +#define DELAY_PROC_T5 INC_PROC_T5*DELAY //Process 6 #define INC_PROC_T6 13 -#define DELAY_PROC_T6 INC_PROC_T3*DELAY +#define DELAY_PROC_T6 INC_PROC_T6*DELAY //Process 7 #define INC_PROC_T7 17 -#define DELAY_PROC_T7 INC_PROC_T3*DELAY +#define DELAY_PROC_T7 INC_PROC_T7*DELAY //Process 8 #define INC_PROC_T8 19 -#define DELAY_PROC_T8 INC_PROC_T3*DELAY -//Process 9 -#define INC_PROC_T9 23 -#define DELAY_PROC_T9 INC_PROC_T3*DELAY -//Process 10 -#define INC_PROC_T10 29 -#define DELAY_PROC_T10 INC_PROC_T3*DELAY +#define DELAY_PROC_T8 INC_PROC_T8*DELAY Semaphore sem; unsigned int global_count = 0; /* - * These macro generate the code that needed to create the - * test process function and all it needed. + * These macros generate the code needed to create the test process functions. */ #define PROC_TEST(num) static void proc_test##num(void) \ { \ @@ -121,10 +115,7 @@ PROC_TEST(5) PROC_TEST(6) PROC_TEST(7) PROC_TEST(8) -/* -PROC_TEST(9) -PROC_TEST(10) -*/ + // Define process stacks for test. PROC_TEST_STACK(1) PROC_TEST_STACK(2) @@ -134,10 +125,7 @@ PROC_TEST_STACK(5) PROC_TEST_STACK(6) PROC_TEST_STACK(7) PROC_TEST_STACK(8) -/* -PROC_TEST_STACK(9) -PROC_TEST_STACK(10) -*/ + /** * Run semaphore test */ @@ -156,21 +144,17 @@ int sem_testRun(void) PROC_TEST_INIT(6) PROC_TEST_INIT(7) PROC_TEST_INIT(8) - /* - PROC_TEST_INIT(9) - PROC_TEST_INIT(10) - */ kputs("> Main: Processes created\n"); /* - * Wait until all process finishing, if some going wrong we return - * error after time_out_ms ms. + * Wait until all processes exit, if something goes wrong we return an + * error after timeout_ms. */ while((timer_clock() - start_time) < ms_to_ticks(TEST_TIME_OUT_MS)) { if (sem_attempt(&sem)) { - kputs("> Main: Check if test is finish..\n"); + kputs("> Main: Check if test has finished..\n"); if(global_count == MAX_GLOBAL_COUNT) { kputs("> Main: Test Finished..Ok!\n");