From 711ce0e4695fbc35c242e0819e184334f37ae59a Mon Sep 17 00:00:00 2001 From: Himanshu Chauhan Date: Thu, 2 Jun 2011 20:15:11 +0530 Subject: [PATCH] Changed the default stack size for threads. Fixed the critical section problems. Signed-off-by: Himanshu Chauhan --- ports/mips/atomport-asm.s | 10 ++++++++++ ports/mips/atomport-tests.h | 2 +- ports/mips/atomport.h | 3 --- ports/mips/tests-main.c | 6 +++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ports/mips/atomport-asm.s b/ports/mips/atomport-asm.s index 53cff5b..2b64746 100644 --- a/ports/mips/atomport-asm.s +++ b/ports/mips/atomport-asm.s @@ -32,6 +32,8 @@ .section .text .extern atomCurrentContext +.extern at_preempt_count + /** * Function that performs the contextSwitch. Whether its a voluntary release * of CPU by thread or a pre-emption, under both conditions this function is @@ -145,7 +147,15 @@ __unwind_int_context: RESTORE_INT_CONTEXT __ret_from_switch: + la k0, at_preempt_count + lw k1, (k0) + addi k1, k1, -1 + sw k1, (k0) + bnez k1, __return_from_int + nop enable_global_interrupts + ehb +__return_from_int: eret /** diff --git a/ports/mips/atomport-tests.h b/ports/mips/atomport-tests.h index 66b58eb..b6b6c46 100644 --- a/ports/mips/atomport-tests.h +++ b/ports/mips/atomport-tests.h @@ -39,7 +39,7 @@ #define _STR /* Default thread stack size (in bytes) */ -#define TEST_THREAD_STACK_SIZE 128 +#define TEST_THREAD_STACK_SIZE 8192 /* Uncomment to enable logging of stack usage to UART */ /* #define TESTS_LOG_STACK_USAGE */ diff --git a/ports/mips/atomport.h b/ports/mips/atomport.h index 64ba0bc..a6ed705 100644 --- a/ports/mips/atomport.h +++ b/ports/mips/atomport.h @@ -78,12 +78,9 @@ extern uint32_t at_preempt_count; \ if (at_preempt_count == 0) { \ if (atomCurrentContext()) { \ - printk("+"); \ __asm__ __volatile__("ei %0\t\n" \ "ehb\t\n" \ ::"r"(status_reg));\ - } else { \ - printk("."); \ } \ } \ \ diff --git a/ports/mips/tests-main.c b/ports/mips/tests-main.c index 57347aa..27aee97 100644 --- a/ports/mips/tests-main.c +++ b/ports/mips/tests-main.c @@ -48,7 +48,7 @@ * In this case, the idle stack is allocated on the BSS via the * idle_thread_stack[] byte array. */ -#define IDLE_STACK_SIZE_BYTES 4096 +#define IDLE_STACK_SIZE_BYTES 8192 /* @@ -122,10 +122,10 @@ static ATOM_TCB main_tcb; /* Main thread's stack area */ -static uint8_t main_thread_stack[MAIN_STACK_SIZE_BYTES] __attribute__((aligned (4))); +static uint8_t main_thread_stack[MAIN_STACK_SIZE_BYTES]; /* Idle thread's stack area */ -static uint8_t idle_thread_stack[IDLE_STACK_SIZE_BYTES] __attribute__((aligned (4))); +static uint8_t idle_thread_stack[IDLE_STACK_SIZE_BYTES]; /* Forward declarations */ static void main_thread_func (uint32_t data);