X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Fkern%2Fsem_test.c;h=feb0be72ba6424a23b1c1f592aaf7afafda611d9;hb=1e36feb3d267af4d363d5996a601ce1709d77f86;hp=b2031b3ba6a67719d9dcab50acb88b30824d0bd9;hpb=f0869aa03fa0df07d957981ec27f9fcd1282cd64;p=bertos.git diff --git a/bertos/kern/sem_test.c b/bertos/kern/sem_test.c index b2031b3b..feb0be72 100644 --- a/bertos/kern/sem_test.c +++ b/bertos/kern/sem_test.c @@ -32,10 +32,10 @@ * \brief Semaphore test. * * \version $Id$ - * + * * \author Daniele Basile - * \author Stefano Fedrigo - * + * \author Stefano Fedrigo + * */ #include @@ -49,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 @@ -64,27 +64,26 @@ #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 +#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) \ { \ unsigned int local_count = 0; \ @@ -135,7 +134,7 @@ int sem_testRun(void) ticks_t start_time = timer_clock(); kprintf("Run semaphore test..\n"); - + //Init the process tests PROC_TEST_INIT(1) PROC_TEST_INIT(2) @@ -146,16 +145,16 @@ int sem_testRun(void) PROC_TEST_INIT(7) PROC_TEST_INIT(8) 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"); @@ -166,7 +165,7 @@ int sem_testRun(void) } proc_yield(); } - + kputs("Semaphore Test fail..\n"); return -1; } @@ -178,7 +177,7 @@ int sem_testSetup(void) kprintf("Init Semaphore.."); sem_init(&sem); kprintf("Done.\n"); - + #if CONFIG_KERN_PREEMPT kprintf("Init Interrupt (preempt mode).."); irq_init(); @@ -188,11 +187,11 @@ int sem_testSetup(void) kprintf("Init Timer.."); timer_init(); kprintf("Done.\n"); - + kprintf("Init Process.."); proc_init(); kprintf("Done.\n"); - + return 0; } @@ -202,4 +201,4 @@ int sem_testTearDown(void) return 0; } -TEST_MAIN(sem); \ No newline at end of file +TEST_MAIN(sem);