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