CM3: kernel preemption.
[bertos.git] / bertos / kern / proc_p.h
index 85cb758f9ecfd7472ea540a3547bb2261fa5717b..56c810819b56964d2d16c83fe29075fbde8f3e5b 100644 (file)
 
 #include <kern/proc.h>   // struct Process
 
+/*
+ * Check if the process context switch can be performed directly by the
+ * architecture-dependent asm_switch_context() or if it must be delayed
+ * because we're in the middle of an ISR.
+ *
+ * Return true if asm_switch_context() can be executed, false
+ * otherwise.
+ *
+ * NOTE: if an architecture does not implement IRQ_RUNNING() this function
+ * always returns true.
+ */
+#define CONTEXT_SWITCH_FROM_ISR()      (!IRQ_RUNNING())
+
+#ifndef asm_switch_context
 /**
  * CPU dependent context switching routines.
  *
@@ -57,6 +71,7 @@
  * support routine which usually needs to be written in assembly.
  */
 EXTERN_C void asm_switch_context(cpu_stack_t **new_sp, cpu_stack_t **save_sp);
+#endif
 
 /*
  * Save context of old process and switch to new process.