diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-04-25 15:19:59 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-04-25 15:19:59 -0600 |
commit | 1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f (patch) | |
tree | 95050f5e635b87d26f4dd98612b05edf632b2a96 /nuttx/arch/z16/src/common/up_blocktask.c | |
parent | 5f6e91b0ed1b373d0b4f963b0e0f8f7fe05ec766 (diff) | |
download | px4-nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.tar.gz px4-nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.tar.bz2 px4-nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.zip |
Remove up_assert_code
Diffstat (limited to 'nuttx/arch/z16/src/common/up_blocktask.c')
-rw-r--r-- | nuttx/arch/z16/src/common/up_blocktask.c | 115 |
1 files changed, 55 insertions, 60 deletions
diff --git a/nuttx/arch/z16/src/common/up_blocktask.c b/nuttx/arch/z16/src/common/up_blocktask.c index 93efee96f..56618ab3d 100644 --- a/nuttx/arch/z16/src/common/up_blocktask.c +++ b/nuttx/arch/z16/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * common/up_blocktask.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -86,88 +86,83 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) { + FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; + bool switch_needed; + /* Verify that the context switch can be performed */ - if ((tcb->task_state < FIRST_READY_TO_RUN_STATE) || - (tcb->task_state > LAST_READY_TO_RUN_STATE)) - { - PANIC(OSERR_BADBLOCKSTATE); - } - else - { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; - bool switch_needed; + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - /* dbg("Blocking TCB=%p\n", tcb); */ + /* dbg("Blocking TCB=%p\n", tcb); */ - /* Remove the tcb task from the ready-to-run list. If we - * are blocking the task at the head of the task list (the - * most likely case), then a context switch to the next - * ready-to-run task is needed. In this case, it should - * also be true that rtcb == tcb. - */ + /* Remove the tcb task from the ready-to-run list. If we + * are blocking the task at the head of the task list (the + * most likely case), then a context switch to the next + * ready-to-run task is needed. In this case, it should + * also be true that rtcb == tcb. + */ - switch_needed = sched_removereadytorun(tcb); + switch_needed = sched_removereadytorun(tcb); - /* Add the task to the specified blocked task list */ + /* Add the task to the specified blocked task list */ - sched_addblocked(tcb, (tstate_t)task_state); + sched_addblocked(tcb, (tstate_t)task_state); - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - /* Now, perform the context switch if one is needed */ + /* Now, perform the context switch if one is needed */ - if (switch_needed) + if (switch_needed) + { + /* Are we in an interrupt handler? */ + + if (IN_INTERRUPT) { - /* Are we in an interrupt handler? */ + /* Yes, then we have to do things differently. + * Just copy the current registers into the OLD rtcb. + */ - if (IN_INTERRUPT) - { - /* Yes, then we have to do things differently. - * Just copy the current registers into the OLD rtcb. - */ + SAVE_IRQCONTEXT(rtcb); - SAVE_IRQCONTEXT(rtcb); + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + rtcb = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ - /* Then setup so that the context will be performed on exit - * from the interrupt. - */ + SET_IRQCONTEXT(rtcb); + } - SET_IRQCONTEXT(rtcb); - } + /* Copy the user C context into the TCB at the (old) head of the + * g_readytorun Task list. if SAVE_USERCONTEXT returns a non-zero + * value, then this is really the previously running task restarting! + */ - /* Copy the user C context into the TCB at the (old) head of the - * g_readytorun Task list. if SAVE_USERCONTEXT returns a non-zero - * value, then this is really the previously running task restarting! + else if (!SAVE_USERCONTEXT(rtcb)) + { + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. */ - else if (!SAVE_USERCONTEXT(rtcb)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + rtcb = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - /* Then switch contexts */ + /* Then switch contexts */ - RESTORE_USERCONTEXT(rtcb); - } + RESTORE_USERCONTEXT(rtcb); } } } |