4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
30 * Copyright 1999, 2000, 2001 Bernardo Innocenti <bernie@develer.com>
34 * \brief Internal scheduler structures and definitions for processes.
38 * \author Bernardo Innocenti <bernie@develer.com>
43 *#* Revision 1.16 2006/07/19 12:56:27 bernie
44 *#* Convert to new Doxygen style.
46 *#* Revision 1.15 2005/11/27 23:36:19 bernie
47 *#* Use appconfig.h instead of cfg/config.h.
49 *#* Revision 1.14 2005/11/04 16:20:02 bernie
50 *#* Fix reference to README.devlib in header.
52 *#* Revision 1.13 2005/04/11 19:10:28 bernie
53 *#* Include top-level headers from cfg/ subdir.
55 *#* Revision 1.12 2004/12/08 08:57:35 bernie
56 *#* Rename sigset_t to sigmask_t.
58 *#* Revision 1.11 2004/11/16 22:37:14 bernie
59 *#* Replace IPTR with iptr_t.
61 *#* Revision 1.10 2004/10/19 11:47:07 bernie
62 *#* Add missing #endif.
64 *#* Revision 1.9 2004/10/19 08:55:31 bernie
65 *#* Define forbid_cnt.
67 *#* Revision 1.8 2004/10/03 20:39:28 bernie
68 *#* Import changes from sc/firmware.
70 *#* Revision 1.7 2004/08/25 14:12:09 rasky
71 *#* Aggiornato il comment block dei log RCS
73 *#* Revision 1.6 2004/08/24 16:05:15 bernie
74 *#* Add missing headers; Reformat.
76 *#* Revision 1.5 2004/08/14 19:37:57 rasky
77 *#* Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc.
79 *#* Revision 1.4 2004/07/30 14:24:16 rasky
80 *#* Task switching con salvataggio perfetto stato di interrupt (SR)
81 *#* Kernel monitor per dump informazioni su stack dei processi
83 *#* Revision 1.3 2004/07/14 14:18:09 rasky
84 *#* Merge da SC: Rimosso timer dentro il task, che รจ uno spreco di memoria per troppi task
86 *#* Revision 1.2 2004/06/03 11:27:09 bernie
87 *#* Add dual-license information.
89 *#* Revision 1.1 2004/05/23 17:27:00 bernie
90 *#* Import kern/ subdirectory.
92 *#* Revision 1.3 2004/05/14 12:52:13 rasky
93 *#* Importato supporto kernel per AVR da Stefano
95 *#* Revision 1.2 2004/04/28 16:13:49 rasky
96 *#* proc_schedule() is now semi-private (used only within the kernel)
98 *#* Revision 1.1 2004/04/26 18:02:40 rasky
99 *#* Importato microkernel
101 *#* Revision 1.1 2004/04/04 17:40:26 aleph
102 *#* Add multithreading kernel
105 #ifndef KERN_PROC_P_H
106 #define KERN_PROC_P_H
108 #include <cfg/compiler.h>
109 #include <cfg/cpu.h> /* for cpu_stack_t */
110 #include <mware/list.h>
111 #include <config_kern.h>
112 #include <appconfig.h>
114 typedef struct Process
116 Node link; /**< Link Process into scheduler lists */
117 cpustack_t *stack; /**< Per-process SP */
118 iptr_t user_data; /**< Custom data passed to the process */
120 #if CONFIG_KERN_SIGNALS
121 sigmask_t sig_wait; /**< Signals the process is waiting for */
122 sigmask_t sig_recv; /**< Received signals */
125 #if CONFIG_KERN_PREEMPTIVE
126 int forbid_cnt; /**< Nesting count for proc_forbid()/proc_permit(). */
130 uint16_t flags; /**< Flags */
131 cpustack_t *stack_base; /**< Base of process stack */
132 size_t stack_size; /**< Size of process stack */
135 #if CONFIG_KERN_MONITOR
140 cpustack_t *stack_base;
149 * \name Flags for Process.flags.
152 #define PF_FREESTACK BV(0) /**< Free the stack when process dies */
156 /** Track running processes. */
157 extern REGISTER Process *CurrentProcess;
159 /** Track ready processes. */
160 extern REGISTER List ProcReadyList;
163 /** Enqueue a task in the ready list. */
164 #define SCHED_ENQUEUE(proc) ADDTAIL(&ProcReadyList, &(proc)->link)
166 /** Schedule to another process *without* adding the current to the ready list. */
167 void proc_schedule(void);
169 #if CONFIG_KERN_MONITOR
170 /** Initialize the monitor */
171 void monitor_init(void);
173 /** Register a process into the monitor */
174 void monitor_add(Process *proc, const char *name, cpustack_t *stack, size_t stacksize);
176 /** Unregister a process from the monitor */
177 void monitor_remove(Process *proc);
179 /** Rename a process */
180 void monitor_rename(Process *proc, const char* name);
181 #endif /* CONFIG_KERN_MONITOR */
183 #endif /* KERN_PROC_P_H */