- /**
- * Enqueue a task in the ready list.
- *
- * Always use this macro to instert a process in the ready list, as its
- * might vary to implement a different scheduling algorithms.
- *
- * \note This macro is *NOT* protected against the scheduler. Access to
- * this list must be performed with interrupts disabled.
- */
- #define SCHED_ENQUEUE(proc) do { \
- LIST_ASSERT_VALID(&ProcReadyList); \
- LIST_ENQUEUE(&ProcReadyList, &(proc)->link); \
- } while (0)
+ #define prio_next() (LIST_EMPTY(&proc_ready_list) ? INT_MIN : \
+ ((PriNode *)LIST_HEAD(&proc_ready_list))->pri)
+ #define prio_proc(proc) (proc->link.pri)
+ #define prio_curr() prio_proc(current_process)
+
+ #define SCHED_ENQUEUE_INTERNAL(proc) \
+ LIST_ENQUEUE(&proc_ready_list, &(proc)->link)
+ #define SCHED_ENQUEUE_HEAD_INTERNAL(proc) \
+ LIST_ENQUEUE_HEAD(&proc_ready_list, &(proc)->link)
+#else
+ #define prio_next() 0
+ #define prio_proc(proc) 0
+ #define prio_curr() 0
+
+ #define SCHED_ENQUEUE_INTERNAL(proc) ADDTAIL(&proc_ready_list, &(proc)->link)
+ #define SCHED_ENQUEUE_HEAD_INTERNAL(proc) ADDHEAD(&proc_ready_list, &(proc)->link)
+#endif
+
+/**
+ * Enqueue a process in the ready list.
+ *
+ * Always use this macro to instert a process in the ready list, as its
+ * might vary to implement a different scheduling algorithms.
+ *
+ * \note Access to the scheduler ready list must be performed with
+ * interrupts disabled.
+ */
+#define SCHED_ENQUEUE(proc) do { \
+ IRQ_ASSERT_DISABLED(); \
+ LIST_ASSERT_VALID(&proc_ready_list); \
+ SCHED_ENQUEUE_INTERNAL(proc); \
+ } while (0)
+
+#define SCHED_ENQUEUE_HEAD(proc) do { \
+ IRQ_ASSERT_DISABLED(); \
+ LIST_ASSERT_VALID(&proc_ready_list); \
+ SCHED_ENQUEUE_HEAD_INTERNAL(proc); \
+ } while (0)