doc: Added group definitions for most common modules.
[bertos.git] / bertos / kern / proc.h
index c78735e89d2e54aa0c8e5c47fe4bfb33de28240d..13bd7bf018f934334e6bd1e8fc01b0a2e098fd84 100644 (file)
  * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
  * -->
  *
+ * \defgroup kern Kernel facilities
+ * \{
+ *
+ * \defgroup kern_proc Process (Threads) management
+ * \{
+ *
  * \brief BeRTOS Kernel core (Process scheduler).
  *
- * \version $Id$
  * \author Bernie Innocenti <bernie@codewiz.org>
  *
  * $WIZ$ module_name = "kernel"
  * $WIZ$ module_configuration = "bertos/cfg/cfg_proc.h"
- * $WIZ$ module_depends = "switch_ctx", "mtask"
+ * $WIZ$ module_depends = "switch_ctx"
  * $WIZ$ module_supports = "not atmega103"
  */
 
 #include <struct/list.h> // Node, PriNode
 
 #include <cfg/compiler.h>
-
-#if CONFIG_KERN_PREEMPT
-       #include <cfg/debug.h> // ASSERT()
-#endif
+#include <cfg/debug.h> // ASSERT()
 
 #include <cpu/types.h> // cpu_stack_t
 #include <cpu/frame.h> // CPU_SAVED_REGS_CNT
@@ -142,16 +144,24 @@ struct Process *proc_new_with_name(const char *name, void (*entry)(void), iptr_t
 void proc_exit(void);
 
 /**
- * Co-operative context switch.
- *
- * The process that calls this function will release the CPU before its cpu quantum
- * expires, the scheduler will run to select the next process that will take control
- * of the processor.
- * \note This function is available only if CONFIG_KERN is enabled
- * \sa cpu_relax(), which is the recommended method to release the cpu.
+ * Public scheduling class methods.
  */
 void proc_yield(void);
 
+#if CONFIG_KERN_PREEMPT
+bool proc_needPreempt(void);
+void proc_preempt(void);
+#else
+INLINE bool proc_needPreempt(void)
+{
+       return false;
+}
+
+INLINE void proc_preempt(void)
+{
+}
+#endif
+
 void proc_rename(struct Process *proc, const char *name);
 const char *proc_name(struct Process *proc);
 const char *proc_currentName(void);
@@ -163,7 +173,11 @@ const char *proc_currentName(void);
  * the returned pointer to the correct type.
  * \return Pointer to the user data of the current process.
  */
-iptr_t proc_currentUserData(void);
+INLINE iptr_t proc_currentUserData(void)
+{
+       extern struct Process *current_process;
+       return current_process->user_data;
+}
 
 int proc_testSetup(void);
 int proc_testRun(void);
@@ -388,5 +402,7 @@ INLINE struct Process *proc_current(void)
                #error No cpu_stack_t size supported!
        #endif
 #endif
+/** \} */ //defgroup kern_proc
+/** \} */ //defgroup kern
 
 #endif /* KERN_PROC_H */