Add missing headers; Reformat.
[bertos.git] / kern / proc_p.h
1 /*!
2  * \file
3  * <!--
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 devlib/README for information.
7  * -->
8  *
9  * \brief Internal scheduler structures and definitions for processes.
10  *
11  * \version $Id$
12  *
13  * \author Bernardo Innocenti <bernie@develer.com>
14  */
15
16 /*
17  * $Log$
18  * Revision 1.6  2004/08/24 16:05:15  bernie
19  * Add missing headers; Reformat.
20  *
21  * Revision 1.5  2004/08/14 19:37:57  rasky
22  * Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc.
23  *
24  * Revision 1.4  2004/07/30 14:24:16  rasky
25  * Task switching con salvataggio perfetto stato di interrupt (SR)
26  * Kernel monitor per dump informazioni su stack dei processi
27  *
28  * Revision 1.3  2004/07/14 14:18:09  rasky
29  * Merge da SC: Rimosso timer dentro il task, che รจ uno spreco di memoria per troppi task
30  *
31  * Revision 1.2  2004/06/03 11:27:09  bernie
32  * Add dual-license information.
33  *
34  * Revision 1.1  2004/05/23 17:27:00  bernie
35  * Import kern/ subdirectory.
36  *
37  * Revision 1.3  2004/05/14 12:52:13  rasky
38  * Importato supporto kernel per AVR da Stefano
39  *
40  * Revision 1.2  2004/04/28 16:13:49  rasky
41  * proc_schedule() is now semi-private (used only within the kernel)
42  *
43  * Revision 1.1  2004/04/26 18:02:40  rasky
44  * Importato microkernel
45  *
46  * Revision 1.1  2004/04/04 17:40:26  aleph
47  * Add multithreading kernel
48  *
49  */
50 #ifndef KERN_PROC_P_H
51 #define KERN_PROC_P_H
52
53 #include "compiler.h"
54 #include "cpu.h"        /* for cpu_stack_t */
55 #include "config.h"
56 #include "config_kern.h"
57 #include <mware/list.h>
58
59 typedef struct Process
60 {
61         Node         link;        /*!< Link Process into scheduler lists */
62         cpustack_t  *stack;       /*!< Per-process SP */
63         IPTR         user_data;   /*!< Custom data passed to the process */
64
65 #if CONFIG_KERN_SIGNALS
66         sigset_t     sig_wait;    /*!< Signals the process is waiting for */
67         sigset_t     sig_recv;    /*!< Received signals */
68 #endif
69
70 #if CONFIG_KERN_HEAP
71         uint16_t     flags;       /*!< Flags */
72         cpustack_t  *stack_base;  /*!< Base of process stack */
73         size_t       stack_size;  /*!< Size of process stack */
74 #endif
75
76 #if CONFIG_KERN_MONITOR
77         struct ProcMonitor
78         {
79                 Node        link;
80                 const char *name;
81                 cpustack_t *stack_base;
82                 size_t      stack_size;
83         } monitor;
84 #endif
85
86 } Process;
87
88
89 /*!
90  * \name Flags for Process.flags
91  * \{
92  */
93 #define PF_FREESTACK  BV(0)  /*!< Free the stack when process dies */
94 /*\}*/
95
96
97 /*! Track running processes */
98 extern REGISTER Process *CurrentProcess;
99
100 /*! Track ready processes */
101 extern REGISTER List     ProcReadyList;
102
103
104 /*!
105  * Enqueue a task in the ready list
106  */
107 #define SCHED_ENQUEUE(proc)  ADDTAIL(&ProcReadyList, &(proc)->link)
108
109 /*! Schedule to another process *without* adding the current to the ready list */
110 void proc_schedule(void);
111
112 #endif /* KERN_PROC_P_H */
113