From 76e88c896315b71ec761f01bc03557ff05ca72d5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 11 Feb 2016 17:24:19 -0600 Subject: [PATCH] SMP: Removed unused macros, update comments, update sched_removereadytorun for SMP --- arch | 2 +- sched/sched/sched.h | 2 -- sched/sched/sched_addreadytorun.c | 45 ++++++++------------------- sched/sched/sched_removereadytorun.c | 46 +++++++++++----------------- 4 files changed, 31 insertions(+), 64 deletions(-) diff --git a/arch b/arch index df987248a7..717113268b 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit df987248a73f078f04d532f2b6d2b9ace867926d +Subproject commit 717113268b97f16d755a11609a63526dfe71e4cf diff --git a/sched/sched/sched.h b/sched/sched/sched.h index 1838a559e6..2abdb59dfa 100644 --- a/sched/sched/sched.h +++ b/sched/sched/sched.h @@ -93,11 +93,9 @@ #ifdef CONFIG_SMP # define TLIST_HEAD(s,c) \ ((TLIST_ISINDEXED(s)) ? __TLIST_HEADINDEXED(s,c) : __TLIST_HEAD(s)) -# define TLIST_READYTORUN(s,c) __TLIST_HEADINDEXED(s,c) # define TLIST_BLOCKED(s) __TLIST_HEAD(s) #else # define TLIST_HEAD(s) __TLIST_HEAD(s) -# define TLIST_READYTORUN(s) __TLIST_HEAD(s) # define TLIST_BLOCKED(s) __TLIST_HEAD(s) #endif diff --git a/sched/sched/sched_addreadytorun.c b/sched/sched/sched_addreadytorun.c index 25f9e00e6c..23a0a2da91 100644 --- a/sched/sched/sched_addreadytorun.c +++ b/sched/sched/sched_addreadytorun.c @@ -45,26 +45,6 @@ #include "sched/sched.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -73,12 +53,11 @@ * Name: sched_addreadytorun * * Description: - * This function adds a TCB to the ready to run - * list. If the currently active task has preemption disabled - * and the new TCB would cause this task to be pre-empted, the - * new task is added to the g_pendingtasks list instead. The - * pending tasks will be made ready-to-run when preemption - * is unlocked. + * This function adds a TCB to the ready to run list. If the currently + * active task has preemption disabled and the new TCB would cause this + * task to be pre-empted, the new task is added to the g_pendingtasks list + * instead. Thepending tasks will be made ready-to-run when preemption is + * unlocked. * * Inputs: * btcb - Points to the blocked TCB that is ready-to-run @@ -88,13 +67,13 @@ * has changed. * * Assumptions: - * - The caller has established a critical section before - * calling this function (calling sched_lock() first is NOT - * a good idea -- use irqsave()). - * - The caller has already removed the input rtcb from - * whatever list it was in. - * - The caller handles the condition that occurs if the - * the head of the ready-to-run list is changed. + * - The caller has established a critical section before calling this + * function (calling sched_lock() first is NOT a good idea -- use + * irqsave()). + * - The caller has already removed the input rtcb from whatever list it + * was in. + * - The caller handles the condition that occurs if the head of the + * ready-to-run list is changed. * ****************************************************************************/ diff --git a/sched/sched/sched_removereadytorun.c b/sched/sched/sched_removereadytorun.c index 9cad532f8c..eb71e63892 100644 --- a/sched/sched/sched_removereadytorun.c +++ b/sched/sched/sched_removereadytorun.c @@ -1,7 +1,7 @@ /**************************************************************************** * shced/sched_removereadytorun.c * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,26 +45,6 @@ #include "sched/sched.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -79,24 +59,25 @@ * rtcb - Points to the TCB that is ready-to-run * * Return Value: - * true if the currently active task (the head of the - * g_readytorun list) has changed. + * true if the currently active task (the head of the ready-to-run list) + * has changed. * * Assumptions: * - The caller has established a critical section before calling this * function (calling sched_lock() first is NOT a good idea -- use irqsave()). - * - The caller handles the condition that occurs if the - * the head of the g_readytorun list is changed. + * - The caller handles the condition that occurs if the head of the + * ready-to-run list is changed. * ****************************************************************************/ bool sched_removereadytorun(FAR struct tcb_s *rtcb) { FAR struct tcb_s *ntcb = NULL; + FAR dq_queue_t *tasklist; bool ret = false; /* Check if the TCB to be removed is at the head of the ready to run list. - * In this case, we are removing the currently active task. + * In this case, we are removing the currently active task on this CPU. */ if (!rtcb->blink) @@ -113,9 +94,18 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb) ret = true; } - /* Remove the TCB from the ready-to-run list */ + /* Remove the TCB from the ready-to-run list. In the non-SMP case, this + * is always the g_readytorun list; In the SMP case, however, this may be + * either the g_readytorun() or the g_assignedtasks[cpu] list. + */ - dq_rem((FAR dq_entry_t *)rtcb, (FAR dq_queue_t *)&g_readytorun); +#ifdef CONFIG_SMP + tasklist = TLIST_HEAD(rtcb->task_state, rtcb->cpu); +#else + tasklist = (FAR dq_queue_t *)&g_readytorun; +#endif + + dq_rem((FAR dq_entry_t *)rtcb, tasklist); /* Since the TCB is not in any list, it is now invalid */