projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add the output selection page
[bertos.git]
/
bertos
/
kern
/
sem_test.c
diff --git
a/bertos/kern/sem_test.c
b/bertos/kern/sem_test.c
index 1638656705cc89084612b7b1ca248be3f5b0e376..feb0be72ba6424a23b1c1f592aaf7afafda611d9 100644
(file)
--- a/
bertos/kern/sem_test.c
+++ b/
bertos/kern/sem_test.c
@@
-32,12
+32,13
@@
* \brief Semaphore test.
*
* \version $Id$
* \brief Semaphore test.
*
* \version $Id$
- *
+ *
* \author Daniele Basile <asterix@develer.com>
* \author Daniele Basile <asterix@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- *
+ * \author Stefano Fedrigo <aleph@develer.com>
+ *
*/
*/
+#include <cfg/debug.h>
#include <cfg/test.h>
#include <kern/sem.h>
#include <cfg/test.h>
#include <kern/sem.h>
@@
-48,8
+49,8
@@
// Global settings for the test.
#define MAX_GLOBAL_COUNT 1024
// Global settings for the test.
#define MAX_GLOBAL_COUNT 1024
-#define TEST_TIME_OUT_MS
4
000
-#define DELAY
10
+#define TEST_TIME_OUT_MS
6
000
+#define DELAY
5
// Settings for the test process.
//Process 1
// Settings for the test process.
//Process 1
@@
-63,33
+64,26
@@
#define DELAY_PROC_T3 INC_PROC_T3*DELAY
//Process 4
#define INC_PROC_T4 7
#define DELAY_PROC_T3 INC_PROC_T3*DELAY
//Process 4
#define INC_PROC_T4 7
-#define DELAY_PROC_T4 INC_PROC_T
3
*DELAY
+#define DELAY_PROC_T4 INC_PROC_T
4
*DELAY
//Process 5
#define INC_PROC_T5 11
//Process 5
#define INC_PROC_T5 11
-#define DELAY_PROC_T5 INC_PROC_T
3
*DELAY
+#define DELAY_PROC_T5 INC_PROC_T
5
*DELAY
//Process 6
#define INC_PROC_T6 13
//Process 6
#define INC_PROC_T6 13
-#define DELAY_PROC_T6 INC_PROC_T
3
*DELAY
+#define DELAY_PROC_T6 INC_PROC_T
6
*DELAY
//Process 7
#define INC_PROC_T7 17
//Process 7
#define INC_PROC_T7 17
-#define DELAY_PROC_T7 INC_PROC_T
3
*DELAY
+#define DELAY_PROC_T7 INC_PROC_T
7
*DELAY
//Process 8
#define INC_PROC_T8 19
//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;
/*
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; \
#define PROC_TEST(num) static void proc_test##num(void) \
{ \
unsigned int local_count = 0; \
@@
-121,10
+115,7
@@
PROC_TEST(5)
PROC_TEST(6)
PROC_TEST(7)
PROC_TEST(8)
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)
// 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(6)
PROC_TEST_STACK(7)
PROC_TEST_STACK(8)
-/*
-PROC_TEST_STACK(9)
-PROC_TEST_STACK(10)
-*/
+
/**
* Run semaphore test
*/
/**
* Run semaphore test
*/
@@
-146,7
+134,7
@@
int sem_testRun(void)
ticks_t start_time = timer_clock();
kprintf("Run semaphore test..\n");
ticks_t start_time = timer_clock();
kprintf("Run semaphore test..\n");
-
+
//Init the process tests
PROC_TEST_INIT(1)
PROC_TEST_INIT(2)
//Init the process tests
PROC_TEST_INIT(1)
PROC_TEST_INIT(2)
@@
-156,21
+144,17
@@
int sem_testRun(void)
PROC_TEST_INIT(6)
PROC_TEST_INIT(7)
PROC_TEST_INIT(8)
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");
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 process
es exit, if something goes wrong we return an
+ * error after time
out_
ms.
+ */
while((timer_clock() - start_time) < ms_to_ticks(TEST_TIME_OUT_MS))
{
if (sem_attempt(&sem))
{
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");
if(global_count == MAX_GLOBAL_COUNT)
{
kputs("> Main: Test Finished..Ok!\n");
@@
-181,7
+165,7
@@
int sem_testRun(void)
}
proc_yield();
}
}
proc_yield();
}
-
+
kputs("Semaphore Test fail..\n");
return -1;
}
kputs("Semaphore Test fail..\n");
return -1;
}
@@
-193,7
+177,7
@@
int sem_testSetup(void)
kprintf("Init Semaphore..");
sem_init(&sem);
kprintf("Done.\n");
kprintf("Init Semaphore..");
sem_init(&sem);
kprintf("Done.\n");
-
+
#if CONFIG_KERN_PREEMPT
kprintf("Init Interrupt (preempt mode)..");
irq_init();
#if CONFIG_KERN_PREEMPT
kprintf("Init Interrupt (preempt mode)..");
irq_init();
@@
-203,11
+187,11
@@
int sem_testSetup(void)
kprintf("Init Timer..");
timer_init();
kprintf("Done.\n");
kprintf("Init Timer..");
timer_init();
kprintf("Done.\n");
-
+
kprintf("Init Process..");
proc_init();
kprintf("Done.\n");
kprintf("Init Process..");
proc_init();
kprintf("Done.\n");
-
+
return 0;
}
return 0;
}
@@
-217,4
+201,4
@@
int sem_testTearDown(void)
return 0;
}
return 0;
}
-TEST_MAIN(sem);
\ No newline at end of file
+TEST_MAIN(sem);