Add dual-license information.
[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.2  2004/06/03 11:27:09  bernie
19  * Add dual-license information.
20  *
21  * Revision 1.1  2004/05/23 17:27:00  bernie
22  * Import kern/ subdirectory.
23  *
24  * Revision 1.3  2004/05/14 12:52:13  rasky
25  * Importato supporto kernel per AVR da Stefano
26  *
27  * Revision 1.2  2004/04/28 16:13:49  rasky
28  * proc_schedule() is now semi-private (used only within the kernel)
29  *
30  * Revision 1.1  2004/04/26 18:02:40  rasky
31  * Importato microkernel
32  *
33  * Revision 1.1  2004/04/04 17:40:26  aleph
34  * Add multithreading kernel
35  *
36  */
37
38 #ifndef KERN_PROC_P_H
39 #define KERN_PROC_P_H
40
41 #include "compiler.h"
42 #include "config.h"
43 #include "config_kern.h"
44 #include <mware/list.h>
45 #include <drv/timer.h>
46
47
48 typedef struct Process
49 {
50         Node         link;        /*!< Link Process into scheduler lists */
51         cpustack_t  *stack;       /*!< Per-process SP */
52
53 #if CONFIG_KERN_SIGNALS
54         sigset_t     sig_wait;    /*!< Signals the process is waiting for */
55         sigset_t     sig_recv;    /*!< Received signals */
56 #endif
57
58 #if CONFIG_KERN_TIMER
59         struct Timer proc_timer;  /*!< Process own timer */
60 #endif
61
62 #if CONFIG_KERN_HEAP
63         uint16_t     flags;       /*!< Flags */
64         cpustack_t  *stack_base;  /*!< Base of process stack */
65         size_t       stack_size;  /*!< Size of process stack */
66 #endif
67 } Process;
68
69
70 /*!
71  * \name Flags for Process.flags
72  * \{
73  */
74 #define PF_FREESTACK  BV(0)  /*!< Free the stack when process dies */
75 /*\}*/
76
77
78 /*! Track running processes */
79 extern REGISTER Process *CurrentProcess;
80
81 /*! Track ready processes */
82 extern REGISTER List     ProcReadyList;
83
84
85 /*!
86  * Enqueue a task in the ready list
87  */
88 #define SCHED_ENQUEUE(proc)  ADDTAIL(&ProcReadyList, &(proc)->link)
89
90 /*! Schedule to another process *without* adding the current to the ready list */
91 void proc_schedule(void);
92
93 #endif /* KERN_PROC_P_H */
94