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