diff options
-rw-r--r-- | core/nds32/switch.S | 5 | ||||
-rw-r--r-- | core/nds32/task.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/core/nds32/switch.S b/core/nds32/switch.S index 8696ef5f00..b891aeb2a5 100644 --- a/core/nds32/switch.S +++ b/core/nds32/switch.S @@ -81,6 +81,11 @@ __switch_task: */ .global __task_start __task_start: + /* + * Disable global interrupt here to ensure below sequence won't be + * broken. The "iret" instruction of ISR will enable GIE again. + */ + setgie.d /* area used as thread stack for the first switch */ la $r3, scratchpad diff --git a/core/nds32/task.c b/core/nds32/task.c index 6c0766635f..f4446bdacb 100644 --- a/core/nds32/task.c +++ b/core/nds32/task.c @@ -236,7 +236,8 @@ task_id_t task_get_current(void) /* If we haven't done a context switch then our task ID isn't valid */ ASSERT(current_task != (task_ *)scratchpad); #endif - return current_task - tasks; + /* return invalid task id if task scheduling is not yet start */ + return start_called ? (current_task - tasks) : TASK_ID_INVALID; } uint32_t *task_get_event_bitmap(task_id_t tskid) |