4 * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 1999, 2000, 2001 Bernardo Innocenti <bernie@develer.com>
6 * This file is part of DevLib - See README.devlib for information.
9 * \brief Internal scheduler structures and definitions for processes.
13 * \author Bernardo Innocenti <bernie@develer.com>
18 *#* Revision 1.15 2005/11/27 23:36:19 bernie
19 *#* Use appconfig.h instead of cfg/config.h.
21 *#* Revision 1.14 2005/11/04 16:20:02 bernie
22 *#* Fix reference to README.devlib in header.
24 *#* Revision 1.13 2005/04/11 19:10:28 bernie
25 *#* Include top-level headers from cfg/ subdir.
27 *#* Revision 1.12 2004/12/08 08:57:35 bernie
28 *#* Rename sigset_t to sigmask_t.
30 *#* Revision 1.11 2004/11/16 22:37:14 bernie
31 *#* Replace IPTR with iptr_t.
33 *#* Revision 1.10 2004/10/19 11:47:07 bernie
34 *#* Add missing #endif.
36 *#* Revision 1.9 2004/10/19 08:55:31 bernie
37 *#* Define forbid_cnt.
39 *#* Revision 1.8 2004/10/03 20:39:28 bernie
40 *#* Import changes from sc/firmware.
42 *#* Revision 1.7 2004/08/25 14:12:09 rasky
43 *#* Aggiornato il comment block dei log RCS
45 *#* Revision 1.6 2004/08/24 16:05:15 bernie
46 *#* Add missing headers; Reformat.
48 *#* Revision 1.5 2004/08/14 19:37:57 rasky
49 *#* Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc.
51 *#* Revision 1.4 2004/07/30 14:24:16 rasky
52 *#* Task switching con salvataggio perfetto stato di interrupt (SR)
53 *#* Kernel monitor per dump informazioni su stack dei processi
55 *#* Revision 1.3 2004/07/14 14:18:09 rasky
56 *#* Merge da SC: Rimosso timer dentro il task, che รจ uno spreco di memoria per troppi task
58 *#* Revision 1.2 2004/06/03 11:27:09 bernie
59 *#* Add dual-license information.
61 *#* Revision 1.1 2004/05/23 17:27:00 bernie
62 *#* Import kern/ subdirectory.
64 *#* Revision 1.3 2004/05/14 12:52:13 rasky
65 *#* Importato supporto kernel per AVR da Stefano
67 *#* Revision 1.2 2004/04/28 16:13:49 rasky
68 *#* proc_schedule() is now semi-private (used only within the kernel)
70 *#* Revision 1.1 2004/04/26 18:02:40 rasky
71 *#* Importato microkernel
73 *#* Revision 1.1 2004/04/04 17:40:26 aleph
74 *#* Add multithreading kernel
80 #include <cfg/compiler.h>
81 #include <cfg/cpu.h> /* for cpu_stack_t */
82 #include <mware/list.h>
83 #include <config_kern.h>
84 #include <appconfig.h>
86 typedef struct Process
88 Node link; /*!< Link Process into scheduler lists */
89 cpustack_t *stack; /*!< Per-process SP */
90 iptr_t user_data; /*!< Custom data passed to the process */
92 #if CONFIG_KERN_SIGNALS
93 sigmask_t sig_wait; /*!< Signals the process is waiting for */
94 sigmask_t sig_recv; /*!< Received signals */
97 #if CONFIG_KERN_PREEMPTIVE
98 int forbid_cnt; /*!< Nesting count for proc_forbid()/proc_permit(). */
102 uint16_t flags; /*!< Flags */
103 cpustack_t *stack_base; /*!< Base of process stack */
104 size_t stack_size; /*!< Size of process stack */
107 #if CONFIG_KERN_MONITOR
112 cpustack_t *stack_base;
121 * \name Flags for Process.flags.
124 #define PF_FREESTACK BV(0) /*!< Free the stack when process dies */
128 /*! Track running processes. */
129 extern REGISTER Process *CurrentProcess;
131 /*! Track ready processes. */
132 extern REGISTER List ProcReadyList;
135 /*! Enqueue a task in the ready list. */
136 #define SCHED_ENQUEUE(proc) ADDTAIL(&ProcReadyList, &(proc)->link)
138 /*! Schedule to another process *without* adding the current to the ready list. */
139 void proc_schedule(void);
141 #if CONFIG_KERN_MONITOR
142 /*! Initialize the monitor */
143 void monitor_init(void);
145 /*! Register a process into the monitor */
146 void monitor_add(Process *proc, const char *name, cpustack_t *stack, size_t stacksize);
148 /*! Unregister a process from the monitor */
149 void monitor_remove(Process *proc);
151 /*! Rename a process */
152 void monitor_rename(Process *proc, const char* name);
153 #endif /* CONFIG_KERN_MONITOR */
155 #endif /* KERN_PROC_P_H */