From: lottaviano Date: Wed, 16 Sep 2009 08:04:45 +0000 (+0000) Subject: Use KERN_MINSTACKSIZE and PROC_DEFINE_STACK in all tests. X-Git-Tag: 2.2.0~19 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=47d5e292509c20d22adfc608f412bdbe7209decb;p=bertos.git Use KERN_MINSTACKSIZE and PROC_DEFINE_STACK in all tests. Various fixes to tests: - Fix proc_test stack and use correct flags when enabling priority test - Fix signal_test to use less stack (kputs instead of kprintf) - Fix idle_process stack - Fix msg_test - Fix buffer size in formatwr.c git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2949 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/kern/idle.c b/bertos/kern/idle.c index e5713e83..810560a1 100644 --- a/bertos/kern/idle.c +++ b/bertos/kern/idle.c @@ -41,7 +41,8 @@ #include -static cpu_stack_t idle_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpu_stack_t)]; +// below there's a TRACE so we need a big stack +PROC_DEFINE_STACK(idle_stack, KERN_MINSTACKSIZE * 2); /** * The idle process diff --git a/bertos/kern/msg.h b/bertos/kern/msg.h index 2d92f2e2..32232c56 100644 --- a/bertos/kern/msg.h +++ b/bertos/kern/msg.h @@ -106,7 +106,7 @@ * } TestMsg; * * - * static cpu_stack_t sender_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpu_stack_t)]; + * PROC_DEFINE_STACK(sender_stack, KERN_MINSTACKSIZE); * * // A process that sends two messages and waits for replies. * static void sender_proc(void) diff --git a/bertos/kern/msg_test.c b/bertos/kern/msg_test.c index 0deac2c8..1e4ed210 100644 --- a/bertos/kern/msg_test.c +++ b/bertos/kern/msg_test.c @@ -68,7 +68,7 @@ // Global settings for the test. #define MAX_GLOBAL_COUNT 11040 -#define TEST_TIME_OUT_MS 10 +#define TEST_TIME_OUT_MS 5000 #define DELAY 5 // Settings for the test message. @@ -107,6 +107,7 @@ static NORETURN void receiver_proc##num(void) \ rec_msg->result += rec_msg->val; \ kprintf("Proc[%d]..process message val[%d],delay[%d],res[%d]\n", num, rec_msg->val, rec_msg->delay, rec_msg->result); \ msg_reply(&rec_msg->msg); \ + process_num++; \ kprintf("Proc[%d] reply\n", num); \ } \ } @@ -118,7 +119,7 @@ static NORETURN void receiver_proc##num(void) \ msg_put(&test_port##num, &msg##num.msg); \ } while(0) -#define RECV_STACK(num) static cpu_stack_t receiver_stack##num[800 / sizeof(cpu_stack_t)] +#define RECV_STACK(num) PROC_DEFINE_STACK(receiver_stack##num, KERN_MINSTACKSIZE * 2) #define RECV_INIT_PROC(num) proc_new(receiver_proc##num, NULL, sizeof(receiver_stack##num), receiver_stack##num) #define RECV_INIT_MSG(num, proc, sig) msg_initPort(&test_port##num, event_createSignal(proc, sig)) @@ -134,6 +135,7 @@ typedef struct // Global count to check if the test is going ok. static int count = 0; +static int process_num; // Our message port. static MsgPort test_port0; @@ -223,6 +225,7 @@ int msg_testRun(void) // Send and wait the message for (int i = 0; i < 23; ++i) { + process_num = 0; SEND_MSG(0); SEND_MSG(1); SEND_MSG(2); @@ -231,14 +234,24 @@ int msg_testRun(void) SEND_MSG(5); while(1) { - if(sig_waitTimeout(SIG_SINGLE, TEST_TIME_OUT_MS) && SIG_SINGLE) + sigmask_t sigs = sig_waitTimeout(SIG_SINGLE, ms_to_ticks(TEST_TIME_OUT_MS)); + if (sigs & SIG_SINGLE) { // Wait for a reply... - reply = containerof(msg_get(&test_portMain), TestMsg, msg); - if(reply == NULL) - break; - count += reply->result; - kprintf("Main recv[%d] count[%d]\n", reply->result, count); + while ((reply = (TestMsg *)msg_get(&test_portMain))) + { + count += reply->result; + kprintf("Main recv[%d] count[%d]\n", reply->result, count); + } + } + + if (process_num == 6) + break; + + if (sigs & SIG_TIMEOUT) + { + kputs("Main: sig timeout\n"); + goto error; } } } @@ -248,7 +261,8 @@ int msg_testRun(void) kprintf("Message test finished..ok!\n"); return 0; } - + +error: kprintf("Message test finished..fail!\n"); return -1; } diff --git a/bertos/kern/proc.c b/bertos/kern/proc.c index 66caa2db..e8e23637 100644 --- a/bertos/kern/proc.c +++ b/bertos/kern/proc.c @@ -167,14 +167,14 @@ struct Process *proc_new_with_name(UNUSED_ARG(const char *, name), void (*entry) PROC_ATOMIC(stack_base = (cpu_stack_t *)list_remHead(&StackFreeList)); ASSERT(stack_base); - stack_size = CONFIG_KERN_MINSTACKSIZE; + stack_size = KERN_MINSTACKSIZE; #elif CONFIG_KERN_HEAP /* Did the caller provide a stack for us? */ if (!stack_base) { /* Did the caller specify the desired stack size? */ if (!stack_size) - stack_size = CONFIG_KERN_MINSTACKSIZE; + stack_size = KERN_MINSTACKSIZE; /* Allocate stack dinamically */ if (!(stack_base = heap_alloc(stack_size))) diff --git a/bertos/kern/proc.h b/bertos/kern/proc.h index 56b5f5aa..c28fd68f 100644 --- a/bertos/kern/proc.h +++ b/bertos/kern/proc.h @@ -119,7 +119,7 @@ void proc_init(void); * of the stack; * \li have some memory for temporary variables inside called functions. * - * The value given by CONFIG_KERN_MINSTACKSIZE is rather safe to use in the first place. + * The value given by KERN_MINSTACKSIZE is rather safe to use in the first place. * * \note The function * \code diff --git a/bertos/kern/proc_test.c b/bertos/kern/proc_test.c index 7573e802..ad30f711 100644 --- a/bertos/kern/proc_test.c +++ b/bertos/kern/proc_test.c @@ -103,12 +103,12 @@ unsigned int t8_count = 0; for (int i = 0; i < INC_PROC_T##num; ++i) \ { \ t##num##_count++; \ - kprintf("> Process[%d]: count[%d]\n", num, t##num##_count); \ + kputs("> Process[" #num "]\n"); \ timer_delay(DELAY_PROC_T##num); \ } \ -} \ +} -#define PROC_TEST_STACK(num) static cpu_stack_t proc_test##num##_stack[700 / sizeof(cpu_stack_t)]; +#define PROC_TEST_STACK(num) PROC_DEFINE_STACK(proc_test##num##_stack, KERN_MINSTACKSIZE); #define PROC_TEST_INIT(num) proc_new(proc_test##num, NULL, sizeof(proc_test##num##_stack), proc_test##num##_stack); // Define process @@ -135,8 +135,9 @@ PROC_TEST_STACK(8) #define PROC_PRI_TEST(num) static void proc_pri_test##num(void) \ { \ struct Process *main_proc = (struct Process *) proc_currentUserData(); \ + kputs("> Process: " #num "\n"); \ sig_signal(main_proc, SIG_USER##num); \ -} \ +} // Default priority is 0 #define PROC_PRI_TEST_INIT(num, proc) \ @@ -195,7 +196,7 @@ int proc_testRun(void) ret_value = -1; } -#if CONFIG_KERN_SIGNALS +#if CONFIG_KERN_SIGNALS & CONFIG_KERN_PRI // test process priority // main process must have the higher priority to check signals received proc_setPri(proc_current(), 10); diff --git a/bertos/kern/sem_test.c b/bertos/kern/sem_test.c index d042ab3b..cf927d0f 100644 --- a/bertos/kern/sem_test.c +++ b/bertos/kern/sem_test.c @@ -109,7 +109,7 @@ unsigned int global_count = 0; } \ } \ -#define PROC_TEST_STACK(num) static cpu_stack_t proc_sem_test##num##_stack[1024 / sizeof(cpu_stack_t)]; +#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 diff --git a/bertos/kern/signal_test.c b/bertos/kern/signal_test.c index ea8c76e2..d489f62c 100644 --- a/bertos/kern/signal_test.c +++ b/bertos/kern/signal_test.c @@ -80,12 +80,12 @@ static void NORETURN proc_signalTest##index(void) \ { \ for(;;) \ { \ - kprintf("> Slave [%d]: Wait signal [%d]\n", index, signal); \ + kputs("> Slave [" #index "]: Wait signal [" #signal "]\n"); \ sig_wait(signal); \ - kprintf("> Slave [%d]: send signal [%d]\n", index, signal); \ + kputs("> Slave [" #index "]: send signal [" #signal "]\n"); \ sig_signal(proc_currentUserData(), signal); \ } \ -} \ +} #define MAIN_CHECK_SIGNAL(index, slave) \ do { \ @@ -96,7 +96,7 @@ static void NORETURN proc_signalTest##index(void) \ count++; \ } while(0) \ -#define PROC_TEST_SLAVE_STACK(index) static cpu_stack_t proc_signal_test##index##_stack[700 / sizeof(cpu_stack_t)]; +#define PROC_TEST_SLAVE_STACK(index) PROC_DEFINE_STACK(proc_signal_test##index##_stack, KERN_MINSTACKSIZE); #define PROC_TEST_SLAVE_INIT(index, master_process) proc_new(proc_signalTest##index, master_process, sizeof(proc_signal_test##index##_stack), proc_signal_test##index##_stack) // Generate the code for signal test. diff --git a/bertos/mware/formatwr.c b/bertos/mware/formatwr.c index 3f11522e..7baea75a 100644 --- a/bertos/mware/formatwr.c +++ b/bertos/mware/formatwr.c @@ -106,9 +106,10 @@ /* Maximum precision for floating point values */ typedef long double max_float_t; - /*bernie: save some memory, who cares about floats with lots of decimals? */ - #define FRMWRI_BUFSIZE 134 - #warning FIXME:134 is too much, the code must be fixed to have a lower precision limit + /*luca: FIXME: this should be enough to print floating point values, must be investigated + * further. + */ + #define FRMWRI_BUFSIZE 20 #else /* * Conservative estimate. Should be (probably) 12 (which is the size necessary