2008-01-29 01:50:16 +01:00
|
|
|
/****************************************************************************
|
2014-08-09 00:44:08 +02:00
|
|
|
* sched/task/task_activate.c
|
2007-03-11 23:19:01 +01:00
|
|
|
*
|
2020-05-25 23:30:40 +02: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-11 23:19:01 +01:00
|
|
|
*
|
2020-05-25 23:30:40 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-11 23:19:01 +01:00
|
|
|
*
|
2020-05-25 23:30:40 +02: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-11 23:19:01 +01:00
|
|
|
*
|
2008-01-29 01:50:16 +01:00
|
|
|
****************************************************************************/
|
2007-03-11 23:19:01 +01:00
|
|
|
|
2008-01-29 01:50:16 +01:00
|
|
|
/****************************************************************************
|
2007-03-11 23:19:01 +01:00
|
|
|
* Included Files
|
2008-01-29 01:50:16 +01:00
|
|
|
****************************************************************************/
|
2007-03-11 23:19:01 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2009-12-14 19:39:29 +01:00
|
|
|
|
2007-03-11 23:19:01 +01:00
|
|
|
#include <sched.h>
|
|
|
|
#include <debug.h>
|
2012-07-14 21:30:31 +02:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
#include <nuttx/irq.h>
|
2020-05-25 23:30:40 +02:00
|
|
|
#include <nuttx/sched.h>
|
2007-03-11 23:19:01 +01:00
|
|
|
#include <nuttx/arch.h>
|
2016-03-17 16:49:43 +01:00
|
|
|
#include <nuttx/sched_note.h>
|
2007-03-11 23:19:01 +01:00
|
|
|
|
2008-01-29 01:50:16 +01:00
|
|
|
/****************************************************************************
|
2007-03-11 23:19:01 +01:00
|
|
|
* Public Functions
|
2008-01-29 01:50:16 +01:00
|
|
|
****************************************************************************/
|
2007-03-11 23:19:01 +01:00
|
|
|
|
2008-01-29 01:50:16 +01:00
|
|
|
/****************************************************************************
|
2020-05-25 23:30:40 +02:00
|
|
|
* Name: nxtask_activate
|
2007-03-11 23:19:01 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2020-05-16 17:06:29 +02:00
|
|
|
* This function activates tasks initialized by nxtask_setup_scheduler().
|
2020-03-08 13:51:32 +01:00
|
|
|
* Without activation, a task is ineligible for execution by the
|
|
|
|
* scheduler.
|
2007-03-11 23:19:01 +01:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
2020-05-25 23:30:40 +02:00
|
|
|
* tcb - The TCB for the task for the task (same as the nxtask_init
|
2020-03-08 13:51:32 +01:00
|
|
|
* argument).
|
2007-03-11 23:19:01 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2020-06-04 14:19:40 +02:00
|
|
|
* None
|
2007-03-11 23:19:01 +01:00
|
|
|
*
|
2008-01-29 01:50:16 +01:00
|
|
|
****************************************************************************/
|
2007-03-11 23:19:01 +01:00
|
|
|
|
2020-06-04 14:19:40 +02:00
|
|
|
void nxtask_activate(FAR struct tcb_s *tcb)
|
2007-03-11 23:19:01 +01:00
|
|
|
{
|
2016-02-14 15:17:46 +01:00
|
|
|
irqstate_t flags = enter_critical_section();
|
2007-03-11 23:19:01 +01:00
|
|
|
|
2007-03-19 15:22:43 +01:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
|
|
|
|
2007-03-11 23:19:01 +01: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
|
|
|
|
|
|
|
|
up_unblock_task(tcb);
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2007-03-11 23:19:01 +01:00
|
|
|
}
|