2008-01-29 08:50:16 +08:00
|
|
|
/****************************************************************************
|
2014-08-09 06:44:08 +08:00
|
|
|
* sched/task/task_activate.c
|
2007-03-12 06:19:01 +08:00
|
|
|
*
|
2020-05-26 05:30:40 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-03-12 06:19:01 +08:00
|
|
|
*
|
2020-05-26 05:30:40 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-12 06:19:01 +08:00
|
|
|
*
|
2020-05-26 05:30:40 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-03-12 06:19:01 +08:00
|
|
|
*
|
2008-01-29 08:50:16 +08:00
|
|
|
****************************************************************************/
|
2007-03-12 06:19:01 +08:00
|
|
|
|
2008-01-29 08:50:16 +08:00
|
|
|
/****************************************************************************
|
2007-03-12 06:19:01 +08:00
|
|
|
* Included Files
|
2008-01-29 08:50:16 +08:00
|
|
|
****************************************************************************/
|
2007-03-12 06:19:01 +08:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2009-12-15 02:39:29 +08:00
|
|
|
|
2007-03-12 06:19:01 +08:00
|
|
|
#include <sched.h>
|
|
|
|
#include <debug.h>
|
2012-07-15 03:30:31 +08:00
|
|
|
|
2016-02-14 22:17:46 +08:00
|
|
|
#include <nuttx/irq.h>
|
2020-05-26 05:30:40 +08:00
|
|
|
#include <nuttx/sched.h>
|
2007-03-12 06:19:01 +08:00
|
|
|
#include <nuttx/arch.h>
|
2016-03-17 23:49:43 +08:00
|
|
|
#include <nuttx/sched_note.h>
|
2007-03-12 06:19:01 +08:00
|
|
|
|
2022-11-01 09:52:11 +08:00
|
|
|
#include "sched/sched.h"
|
|
|
|
|
2008-01-29 08:50:16 +08:00
|
|
|
/****************************************************************************
|
2007-03-12 06:19:01 +08:00
|
|
|
* Public Functions
|
2008-01-29 08:50:16 +08:00
|
|
|
****************************************************************************/
|
2007-03-12 06:19:01 +08:00
|
|
|
|
2008-01-29 08:50:16 +08:00
|
|
|
/****************************************************************************
|
2020-05-26 05:30:40 +08:00
|
|
|
* Name: nxtask_activate
|
2007-03-12 06:19:01 +08:00
|
|
|
*
|
|
|
|
* Description:
|
2020-05-16 23:06:29 +08:00
|
|
|
* This function activates tasks initialized by nxtask_setup_scheduler().
|
2020-03-08 20:51:32 +08:00
|
|
|
* Without activation, a task is ineligible for execution by the
|
|
|
|
* scheduler.
|
2007-03-12 06:19:01 +08:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
2020-05-26 05:30:40 +08:00
|
|
|
* tcb - The TCB for the task for the task (same as the nxtask_init
|
2020-03-08 20:51:32 +08:00
|
|
|
* argument).
|
2007-03-12 06:19:01 +08:00
|
|
|
*
|
2018-02-02 00:00:02 +08:00
|
|
|
* Returned Value:
|
2020-06-04 20:19:40 +08:00
|
|
|
* None
|
2007-03-12 06:19:01 +08:00
|
|
|
*
|
2008-01-29 08:50:16 +08:00
|
|
|
****************************************************************************/
|
2007-03-12 06:19:01 +08:00
|
|
|
|
2020-06-04 20:19:40 +08:00
|
|
|
void nxtask_activate(FAR struct tcb_s *tcb)
|
2007-03-12 06:19:01 +08:00
|
|
|
{
|
2016-02-14 22:17:46 +08:00
|
|
|
irqstate_t flags = enter_critical_section();
|
2022-11-01 09:52:11 +08:00
|
|
|
FAR struct tcb_s *rtcb = this_task();
|
2007-03-12 06:19:01 +08:00
|
|
|
|
2007-03-19 22:22:43 +08:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
|
|
|
|
2007-03-12 06:19:01 +08:00
|
|
|
/* Check if this is really a re-start */
|
|
|
|
|
|
|
|
if (tcb->task_state != TSTATE_TASK_INACTIVE)
|
|
|
|
{
|
|
|
|
/* Inform the instrumentation layer that the task
|
|
|
|
* has stopped
|
|
|
|
*/
|
|
|
|
|
|
|
|
sched_note_stop(tcb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Inform the instrumentation layer that the task
|
|
|
|
* has started
|
|
|
|
*/
|
|
|
|
|
|
|
|
sched_note_start(tcb);
|
|
|
|
#endif
|
|
|
|
|
2022-11-01 09:52:11 +08:00
|
|
|
/* Remove the task from waitting list */
|
|
|
|
|
|
|
|
nxsched_remove_blocked(tcb);
|
|
|
|
|
|
|
|
/* Add the task to ready-to-run task list, and
|
|
|
|
* perform the context switch if one is needed
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (nxsched_add_readytorun(tcb))
|
|
|
|
{
|
2022-11-15 16:52:40 +08:00
|
|
|
up_switch_context(tcb, rtcb);
|
2022-11-01 09:52:11 +08:00
|
|
|
}
|
|
|
|
|
2016-02-14 22:17:46 +08:00
|
|
|
leave_critical_section(flags);
|
2007-03-12 06:19:01 +08:00
|
|
|
}
|