diff --git a/sched/sched/CMakeLists.txt b/sched/sched/CMakeLists.txt index 998c82f0c3..4f5b4c624f 100644 --- a/sched/sched/CMakeLists.txt +++ b/sched/sched/CMakeLists.txt @@ -108,10 +108,6 @@ else() list(APPEND SRCS sched_processtimer.c) endif() -if(CONFIG_SMP) - list(APPEND SRCS sched_thistask.c) -endif() - if(CONFIG_SCHED_CRITMONITOR) list(APPEND SRCS sched_critmonitor.c) endif() diff --git a/sched/sched/Make.defs b/sched/sched/Make.defs index 2ff311780e..8c94be1778 100644 --- a/sched/sched/Make.defs +++ b/sched/sched/Make.defs @@ -84,10 +84,6 @@ else CSRCS += sched_processtimer.c endif -ifeq ($(CONFIG_SMP),y) -CSRCS += sched_thistask.c -endif - ifeq ($(CONFIG_SCHED_CRITMONITOR),y) CSRCS += sched_critmonitor.c endif diff --git a/sched/sched/sched.h b/sched/sched/sched.h index bdf3a60097..be950451b9 100644 --- a/sched/sched/sched.h +++ b/sched/sched/sched.h @@ -353,7 +353,28 @@ void nxsched_suspend(FAR struct tcb_s *tcb); #endif #ifdef CONFIG_SMP -FAR struct tcb_s *this_task(void) noinstrument_function; +noinstrument_function +static inline_function 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; +} int nxsched_select_cpu(cpu_set_t affinity); int nxsched_pause_cpu(FAR struct tcb_s *tcb); diff --git a/sched/sched/sched_thistask.c b/sched/sched/sched_thistask.c deleted file mode 100644 index 57a146757c..0000000000 --- a/sched/sched/sched_thistask.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** - * 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 - -#include -#include - -#include -#include - -#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 */