Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions arch/arm/src/common/arm_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/arm64/src/common/arm64_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ void up_exit(int status)
struct tcb_s *tcb = this_task();
UNUSED(status);

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/avr/src/common/avr_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/hc/src/common/hc_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/mips/src/common/mips_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/misoc/src/lm32/lm32_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/misoc/src/minerva/minerva_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts. The
* IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/or1k/src/common/or1k_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/renesas/src/common/renesas_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/risc-v/src/common/riscv_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
2 changes: 2 additions & 0 deletions arch/sim/src/nuttx-names.in
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ NXSYMBOLS(pthread_cond_init)
NXSYMBOLS(pthread_cond_signal)
NXSYMBOLS(pthread_cond_wait)
NXSYMBOLS(pthread_create)
NXSYMBOLS(pthread_gettid_np)
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
NXSYMBOLS(pthread_getspecific)
NXSYMBOLS(pthread_key_create)
Expand All @@ -111,6 +112,7 @@ NXSYMBOLS(pthread_mutex_unlock)
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
NXSYMBOLS(pthread_setspecific)
#endif
NXSYMBOLS(pthread_self)
NXSYMBOLS(pthread_sigmask)
NXSYMBOLS(puts)
NXSYMBOLS(read)
Expand Down
6 changes: 0 additions & 6 deletions arch/sim/src/sim/sim_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ void up_exit(int status)
{
struct tcb_s *tcb;

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
8 changes: 3 additions & 5 deletions arch/sim/src/sim/sim_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,13 @@ void up_idle(void)
#ifdef CONFIG_PM
static enum pm_state_e state = PM_NORMAL;
enum pm_state_e newstate;
#endif
irqstate_t flags;

/* Fake some power management stuff for testing purposes */

flags = enter_critical_section();
sched_lock();

#ifdef CONFIG_PM
/* Fake some power management stuff for testing purposes */

newstate = pm_checkstate(PM_IDLE_DOMAIN);
if (newstate != state)
{
Expand All @@ -85,8 +83,8 @@ void up_idle(void)

#ifdef CONFIG_PM
pm_changestate(PM_IDLE_DOMAIN, PM_RESTORE);
#endif

sched_unlock();
leave_critical_section(flags);
#endif
}
6 changes: 0 additions & 6 deletions arch/sparc/src/common/sparc_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

(void)enter_critical_section();

/* Update scheduler parameters */

nxsched_suspend_scheduler(tcb);
Expand Down
6 changes: 0 additions & 6 deletions arch/tricore/src/common/tricore_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/x86/src/common/x86_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/x86_64/src/common/x86_64_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ void up_exit(int status)
{
struct tcb_s *tcb;

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/xtensa/src/common/xtensa_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/z16/src/common/z16_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ void up_exit(int status)
{
FAR struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
6 changes: 0 additions & 6 deletions arch/z80/src/common/z80_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void up_exit(int status)
{
FAR struct tcb_s *tcb = this_task();

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Destroy the task at the head of the ready to run list. */

nxtask_exit();
Expand Down
8 changes: 8 additions & 0 deletions sched/pthread/pthread_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ void nx_pthread_exit(FAR void *exit_value)
_exit(EXIT_FAILURE);
}

/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/

enter_critical_section();

/* Perform common task termination logic. This will get called again later
* through logic kicked off by up_exit().
*
Expand All @@ -103,6 +109,8 @@ void nx_pthread_exit(FAR void *exit_value)
* once, or does something very naughty.
*/

tcb->flags |= TCB_FLAG_EXIT_PROCESSING;

nxtask_exithook(tcb, status);

up_exit(EXIT_SUCCESS);
Expand Down
76 changes: 76 additions & 0 deletions sched/sched/sched_setpriority.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,58 @@
#include "irq/irq.h"
#include "sched/sched.h"

/****************************************************************************
* Private Type Declarations
****************************************************************************/

#ifdef CONFIG_SMP
struct reprioritize_arg_s
{
pid_t pid;
cpu_set_t saved_affinity;
uint16_t saved_flags;
int sched_priority;
bool need_restore;
};

/****************************************************************************
* Private Functions
****************************************************************************/

static int reprioritize_handler(FAR void *cookie)
{
FAR struct reprioritize_arg_s *arg = cookie;
FAR struct tcb_s *rtcb = this_task();
FAR struct tcb_s *tcb;
irqstate_t flags;

flags = enter_critical_section();

tcb = nxsched_get_tcb(arg->pid);

if (!tcb || tcb->task_state == TSTATE_TASK_INVALID ||
(tcb->flags & TCB_FLAG_EXIT_PROCESSING) != 0)
{
leave_critical_section(flags);
return OK;
}

if (arg->need_restore)
{
tcb->affinity = arg->saved_affinity;
tcb->flags = arg->saved_flags;
}

if (nxsched_reprioritize_rtr(tcb, arg->sched_priority))
{
up_switch_context(this_task(), rtcb);
}

leave_critical_section(flags);
return OK;
}
#endif

/****************************************************************************
* Name: nxsched_nexttcb
*
Expand Down Expand Up @@ -175,6 +223,34 @@ static inline void nxsched_running_setpriority(FAR struct tcb_s *tcb,
{
/* A context switch will occur. */

#ifdef CONFIG_SMP
if (tcb->cpu != this_cpu() &&
tcb->task_state == TSTATE_TASK_RUNNING)
{
struct reprioritize_arg_s arg;

if ((tcb->flags & TCB_FLAG_CPU_LOCKED) != 0)
{
arg.pid = tcb->pid;
arg.need_restore = false;
}
else
{
arg.pid = tcb->pid;
arg.saved_flags = tcb->flags;
arg.saved_affinity = tcb->affinity;
arg.need_restore = true;

tcb->flags |= TCB_FLAG_CPU_LOCKED;
CPU_SET(tcb->cpu, &tcb->affinity);
}

arg.sched_priority = sched_priority;
nxsched_smp_call_single(tcb->cpu, reprioritize_handler,
&arg, true);
}
else
#endif
if (nxsched_reprioritize_rtr(tcb, sched_priority))
{
up_switch_context(this_task(), rtcb);
Expand Down
Loading