sched/sched: Clean up some logic that I committed yesterday. Add more comments and conditional logic to clarify the issues.
This commit is contained in:
parent
8a48031615
commit
f51693e36a
@ -100,8 +100,10 @@ endif
|
|||||||
|
|
||||||
ifeq ($(CONFIG_SMP),y)
|
ifeq ($(CONFIG_SMP),y)
|
||||||
CSRCS += sched_tasklistlock.c
|
CSRCS += sched_tasklistlock.c
|
||||||
|
ifeq ($(CONFIG_ARCH_GLOBAL_IRQDISABLE),y)
|
||||||
CSRCS += sched_thistask.c
|
CSRCS += sched_thistask.c
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# Include sched build support
|
# Include sched build support
|
||||||
|
|
||||||
|
@ -72,12 +72,19 @@
|
|||||||
|
|
||||||
/* These are macros to access the current CPU and the current task on a CPU.
|
/* These are macros to access the current CPU and the current task on a CPU.
|
||||||
* These macros are intended to support a future SMP implementation.
|
* These macros are intended to support a future SMP implementation.
|
||||||
* NOTE: this_task() for SMP is implemented in sched_thistask.c
|
* NOTE: this_task() for SMP is implemented in sched_thistask.c if the CPU
|
||||||
|
* supports disabling of inter-processor interrupts.
|
||||||
|
*
|
||||||
|
* REVISIT: A mechanism to provide an atomic this_task() is still required
|
||||||
|
* for the case where where inter-processor interrupts cannot be disabled!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
# define current_task(cpu) ((FAR struct tcb_s *)g_assignedtasks[cpu].head)
|
# define current_task(cpu) ((FAR struct tcb_s *)g_assignedtasks[cpu].head)
|
||||||
# define this_cpu() up_cpu_index()
|
# define this_cpu() up_cpu_index()
|
||||||
|
# ifndef CONFIG_ARCH_GLOBAL_IRQDISABLE
|
||||||
|
# define this_task() (current_task(this_cpu()))
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
# define current_task(cpu) ((FAR struct tcb_s *)g_readytorun.head)
|
# define current_task(cpu) ((FAR struct tcb_s *)g_readytorun.head)
|
||||||
# define this_cpu() (0)
|
# define this_cpu() (0)
|
||||||
@ -428,7 +435,9 @@ void sched_sporadic_lowpriority(FAR struct tcb_s *tcb);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
#ifdef CONFIG_ARCH_GLOBAL_IRQDISABLE
|
||||||
FAR struct tcb_s *this_task(void);
|
FAR struct tcb_s *this_task(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
int sched_cpu_select(cpu_set_t affinity);
|
int sched_cpu_select(cpu_set_t affinity);
|
||||||
int sched_cpu_pause(FAR struct tcb_s *tcb);
|
int sched_cpu_pause(FAR struct tcb_s *tcb);
|
||||||
|
@ -69,17 +69,22 @@
|
|||||||
|
|
||||||
FAR struct tcb_s *this_task(void)
|
FAR struct tcb_s *this_task(void)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
|
||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_GLOBAL_IRQDISABLE
|
#ifdef CONFIG_ARCH_GLOBAL_IRQDISABLE
|
||||||
/* Disable local interrupts to avoid CPU switching */
|
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();
|
flags = up_irq_save();
|
||||||
#else
|
#else
|
||||||
/* Enter a critical section */
|
/* REVISIT: Otherwise, there is no protection available. sched_lock() and
|
||||||
|
* enter_critical section are not viable options here (because both depend
|
||||||
//flags = enter_critical_section();
|
* on this_task()).
|
||||||
|
*/
|
||||||
|
# warning "Missing critical section"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Obtain the TCB which is currently running on this CPU */
|
/* Obtain the TCB which is currently running on this CPU */
|
||||||
@ -90,8 +95,6 @@ FAR struct tcb_s *this_task(void)
|
|||||||
|
|
||||||
#ifdef CONFIG_ARCH_GLOBAL_IRQDISABLE
|
#ifdef CONFIG_ARCH_GLOBAL_IRQDISABLE
|
||||||
up_irq_restore(flags);
|
up_irq_restore(flags);
|
||||||
#else
|
|
||||||
//leave_critical_section(flags);
|
|
||||||
#endif
|
#endif
|
||||||
return tcb;
|
return tcb;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user