08c4376606
Summary: - ARCH_GLOBAL_IRQDISABLE was initially introduced for LC823450 SMP - At that time, i.MX6 (quad Cortex-A9) did not use this config - However, this option is now used for all CPUs which support SMP - So it's good timing for refactoring the code Impact: - Should have no impact because the logic is the same for SMP Testing: - Tested with board: spresense:smp, spresense:wifi_smp - Tested with qemu: esp32-core:smp, maix-bit:smp, sabre-6quad:smp - Build only: lc823450-xgevk:rndis, sam4cmp-db:nsh Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
77 lines
2.4 KiB
C
77 lines
2.4 KiB
C
/****************************************************************************
|
|
* sched/sched/sched_thistask.c
|
|
*
|
|
* 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
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* 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.
|
|
*
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Included Files
|
|
****************************************************************************/
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <sys/types.h>
|
|
#include <arch/irq.h>
|
|
|
|
#include <nuttx/irq.h>
|
|
#include <nuttx/spinlock.h>
|
|
|
|
#include "sched/sched.h"
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: this_task
|
|
*
|
|
* Description:
|
|
* The functions will safely obtain the TCB that is currently running
|
|
* on the current CPU. In SMP, this must be done by disabling local
|
|
* interrupts to avoid CPU switching during access to current_task()
|
|
*
|
|
* Returned Value:
|
|
* the TCB that is currently running on the current CPU.
|
|
*
|
|
****************************************************************************/
|
|
|
|
FAR struct tcb_s *this_task(void)
|
|
{
|
|
FAR struct tcb_s *tcb;
|
|
irqstate_t flags;
|
|
|
|
/* If the CPU supports suppression of interprocessor interrupts, then
|
|
* simple disabling interrupts will provide sufficient protection for
|
|
* the following operations.
|
|
*/
|
|
|
|
flags = up_irq_save();
|
|
|
|
/* Obtain the TCB which is currently running on this CPU */
|
|
|
|
tcb = current_task(this_cpu());
|
|
|
|
/* Enable local interrupts */
|
|
|
|
up_irq_restore(flags);
|
|
return tcb;
|
|
}
|
|
|
|
#endif /* CONFIG_SMP */
|