Skip to content

Commit 35fcd93

Browse files
Fix-Pointxiaoxiang781216
authored andcommitted
sched/sched: Remove g_sched_time and fix CONFIG_SCHED_SPORADIC compilation error
This patch removes unused variable g_sched_time while fixes compilation error if CONFIG_SCHED_SPORADIC enabled. Signed-off-by: ouyangxiangzhen <[email protected]> Signed-off-by: ligd <[email protected]>
1 parent 66871ce commit 35fcd93

File tree

1 file changed

+15
-48
lines changed

1 file changed

+15
-48
lines changed

sched/sched/sched_timerexpiration.c

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ uint32_t g_oneshot_maxticks = UINT32_MAX;
7171
****************************************************************************/
7272

7373
#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC)
74-
static clock_t nxsched_cpu_scheduler(int cpu, clock_t elapsed,
75-
bool noswitches);
74+
static clock_t nxsched_cpu_scheduler(int cpu, clock_t ticks,
75+
clock_t elapsed, bool noswitches);
7676
#endif
7777
#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC)
78-
static clock_t nxsched_process_scheduler(clock_t elapsed, bool noswitches);
78+
static clock_t nxsched_process_scheduler(clock_t ticks, clock_t elapsed,
79+
bool noswitches);
7980
#endif
8081
static clock_t nxsched_timer_process(clock_t ticks, clock_t elapsed,
8182
bool noswitches);
@@ -101,12 +102,6 @@ static clock_t g_timer_tick;
101102
static unsigned int g_timer_interval;
102103
#endif
103104

104-
#ifdef CONFIG_SCHED_SPORADIC
105-
/* This is the time of the last scheduler assessment */
106-
107-
static clock_t g_sched_time;
108-
#endif
109-
110105
/****************************************************************************
111106
* Private Functions
112107
****************************************************************************/
@@ -184,8 +179,8 @@ int up_timer_tick_cancel(FAR clock_t *ticks)
184179
****************************************************************************/
185180

186181
#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC)
187-
static clock_t nxsched_cpu_scheduler(int cpu, clock_t elapsed,
188-
bool noswitches)
182+
static clock_t nxsched_cpu_scheduler(int cpu, clock_t ticks,
183+
clock_t elapsed, bool noswitches)
189184
{
190185
FAR struct tcb_s *rtcb = current_task(cpu);
191186
FAR struct tcb_s *ntcb = current_task(cpu);
@@ -220,7 +215,7 @@ static clock_t nxsched_cpu_scheduler(int cpu, clock_t elapsed,
220215
* committed to updating the scheduler for this TCB.
221216
*/
222217

223-
sporadic->eventtime = g_sched_time;
218+
sporadic->eventtime = ticks;
224219

225220
/* Yes, check if the currently executing task has exceeded its
226221
* budget.
@@ -242,7 +237,7 @@ static clock_t nxsched_cpu_scheduler(int cpu, clock_t elapsed,
242237
{
243238
/* Recurse just to get the correct return value */
244239

245-
return nxsched_process_scheduler(0, true);
240+
return nxsched_process_scheduler(ticks, 0, true);
246241
}
247242

248243
/* Returning zero means that there is no interesting event to be timed */
@@ -259,6 +254,7 @@ static clock_t nxsched_cpu_scheduler(int cpu, clock_t elapsed,
259254
* active task on a single CPU.
260255
*
261256
* Input Parameters:
257+
* ticks - The number of ticks that represent current time.
262258
* elapsed - The number of ticks that have elapsed on the interval timer.
263259
* noswitches - True: Can't do context switches now.
264260
*
@@ -276,7 +272,8 @@ static clock_t nxsched_cpu_scheduler(int cpu, clock_t elapsed,
276272
****************************************************************************/
277273

278274
#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC)
279-
static clock_t nxsched_process_scheduler(clock_t elapsed, bool noswitches)
275+
static clock_t nxsched_process_scheduler(clock_t ticks, clock_t elapsed,
276+
bool noswitches)
280277
{
281278
#ifdef CONFIG_SMP
282279
clock_t minslice = CLOCK_MAX;
@@ -298,7 +295,7 @@ static clock_t nxsched_process_scheduler(clock_t elapsed, bool noswitches)
298295

299296
for (i = 0; i < CONFIG_SMP_NCPUS; i++)
300297
{
301-
timeslice = nxsched_cpu_scheduler(i, elapsed, noswitches);
298+
timeslice = nxsched_cpu_scheduler(i, ticks, elapsed, noswitches);
302299
if (timeslice > 0 && timeslice < minslice)
303300
{
304301
minslice = timeslice;
@@ -311,11 +308,11 @@ static clock_t nxsched_process_scheduler(clock_t elapsed, bool noswitches)
311308
#else
312309
/* Perform scheduler operations on the single CPUs */
313310

314-
return nxsched_cpu_scheduler(0, elapsed, noswitches);
311+
return nxsched_cpu_scheduler(0, ticks, elapsed, noswitches);
315312
#endif
316313
}
317314
#else
318-
# define nxsched_process_scheduler(t,n) (0)
315+
# define nxsched_process_scheduler(t, e, n) (0)
319316
#endif
320317

321318
/****************************************************************************
@@ -407,7 +404,7 @@ static clock_t nxsched_timer_process(clock_t ticks, clock_t elapsed,
407404
* active task.
408405
*/
409406

410-
tmp = nxsched_process_scheduler(elapsed, noswitches);
407+
tmp = nxsched_process_scheduler(ticks, elapsed, noswitches);
411408

412409
#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC)
413410
if (tmp > 0 && tmp < rettime)
@@ -520,12 +517,6 @@ void nxsched_alarm_tick_expiration(clock_t ticks)
520517

521518
g_timer_tick = ticks;
522519

523-
#ifdef CONFIG_SCHED_SPORADIC
524-
/* Save the last time that the scheduler ran */
525-
526-
g_sched_time = ticks;
527-
#endif
528-
529520
/* Process the timer ticks and set up the next interval (or not) */
530521

531522
nexttime = nxsched_timer_process(ticks, elapsed, false);
@@ -586,12 +577,6 @@ void nxsched_timer_expiration(void)
586577
elapsed = g_timer_interval;
587578
g_timer_interval = 0;
588579

589-
#ifdef CONFIG_SCHED_SPORADIC
590-
/* Save the last time that the scheduler ran */
591-
592-
up_timer_gettick(&g_sched_time);
593-
#endif
594-
595580
/* Process the timer ticks and set up the next interval (or not) */
596581

597582
nexttime = nxsched_timer_process(g_timer_tick, elapsed, false);
@@ -639,12 +624,6 @@ clock_t nxsched_cancel_timer(void)
639624

640625
up_alarm_tick_cancel(&g_timer_tick);
641626

642-
#ifdef CONFIG_SCHED_SPORADIC
643-
/* Save the last time that the scheduler ran */
644-
645-
g_sched_time = g_timer_tick;
646-
#endif
647-
648627
/* Convert this to the elapsed time and update clock tickbase */
649628

650629
elapsed = g_timer_tick - ticks;
@@ -675,12 +654,6 @@ clock_t nxsched_cancel_timer(void)
675654
g_timer_interval = 0;
676655
g_timer_tick += elapsed;
677656

678-
#ifdef CONFIG_SCHED_SPORADIC
679-
/* Save the last time that the scheduler ran */
680-
681-
g_sched_time = g_timer_tick;
682-
#endif
683-
684657
/* Process the timer ticks and return the next interval */
685658

686659
return nxsched_timer_process(g_timer_tick, elapsed, true);
@@ -712,12 +685,6 @@ void nxsched_resume_timer(void)
712685
{
713686
clock_t nexttime;
714687

715-
#ifdef CONFIG_SCHED_SPORADIC
716-
/* Save the last time that the scheduler ran */
717-
718-
up_timer_gettick(&g_sched_time);
719-
#endif
720-
721688
/* Reassess the next deadline (by simply processing a zero ticks expired)
722689
* and set up the next interval (or not).
723690
*/

0 commit comments

Comments
 (0)