#include <cfg/module.h>
-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
* } 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)
// 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.
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); \
} \
}
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))
// 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;
// Send and wait the message
for (int i = 0; i < 23; ++i)
{
+ process_num = 0;
SEND_MSG(0);
SEND_MSG(1);
SEND_MSG(2);
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;
}
}
}
kprintf("Message test finished..ok!\n");
return 0;
}
-
+
+error:
kprintf("Message test finished..fail!\n");
return -1;
}
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)))
* 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
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
#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) \
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);
} \
} \
-#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
{ \
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 { \
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.
/* 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