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>
44 #include <cfg/compiler.h>
45 #include <cpu/types.h> /* for cpu_stack_t */
46 #include <mware/list.h>
47 #include <config_kern.h>
48 #include <appconfig.h>
50 typedef struct Process
52 Node link; /**< Link Process into scheduler lists */
53 cpustack_t *stack; /**< Per-process SP */
54 iptr_t user_data; /**< Custom data passed to the process */
56 #if CONFIG_KERN_SIGNALS
57 sigmask_t sig_wait; /**< Signals the process is waiting for */
58 sigmask_t sig_recv; /**< Received signals */
61 #if CONFIG_KERN_PREEMPTIVE
62 int forbid_cnt; /**< Nesting count for proc_forbid()/proc_permit(). */
66 uint16_t flags; /**< Flags */
67 cpustack_t *stack_base; /**< Base of process stack */
68 size_t stack_size; /**< Size of process stack */
71 #if CONFIG_KERN_MONITOR
76 cpustack_t *stack_base;
85 * \name Flags for Process.flags.
88 #define PF_FREESTACK BV(0) /**< Free the stack when process dies */
92 /** Track running processes. */
93 extern REGISTER Process *CurrentProcess;
95 /** Track ready processes. */
96 extern REGISTER List ProcReadyList;
99 /** Enqueue a task in the ready list. */
100 #define SCHED_ENQUEUE(proc) ADDTAIL(&ProcReadyList, &(proc)->link)
102 /** Schedule to another process *without* adding the current to the ready list. */
103 void proc_schedule(void);
105 #if CONFIG_KERN_MONITOR
106 /** Initialize the monitor */
107 void monitor_init(void);
109 /** Register a process into the monitor */
110 void monitor_add(Process *proc, const char *name, cpustack_t *stack, size_t stacksize);
112 /** Unregister a process from the monitor */
113 void monitor_remove(Process *proc);
115 /** Rename a process */
116 void monitor_rename(Process *proc, const char* name);
117 #endif /* CONFIG_KERN_MONITOR */
119 #endif /* KERN_PROC_P_H */