Add integrity checks.
[bertos.git] / kern / proc.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 Process scheduler (public interface).
10  *
11  * \version $Id$
12  *
13  * \author Bernardo Innocenti <bernie@develer.com>
14  */
15
16 /*#*
17  *#* $Log$
18  *#* Revision 1.8  2004/11/16 22:37:14  bernie
19  *#* Replace IPTR with iptr_t.
20  *#*
21  *#* Revision 1.7  2004/10/19 08:54:55  bernie
22  *#* Define forbid_cnt.
23  *#*
24  *#* Revision 1.6  2004/10/03 20:44:18  bernie
25  *#* Remove stale declarations (moved to monitor.h).
26  *#*
27  *#* Revision 1.2  2004/06/03 11:27:09  bernie
28  *#* Add dual-license information.
29  *#*
30  *#* Revision 1.1  2004/05/23 17:27:00  bernie
31  *#* Import kern/ subdirectory.
32  *#*
33  *#*/
34
35 #ifndef KERN_PROC_H
36 #define KERN_PROC_H
37
38 #include "compiler.h"
39 #include "cpu.h"
40 #include "config_kern.h"
41
42 /* Fwd decl */
43 struct Process;
44
45 /* Task scheduling services */
46 void proc_init(void);
47 struct Process *proc_new_with_name(const char* name, void (*entry)(void), iptr_t data, size_t stacksize, cpustack_t *stack);
48
49 #if !CONFIG_KERN_MONITOR
50         #define proc_new(entry,data,size,stack) proc_new_with_name(NULL,(entry),(data),(size),(stack))
51 #else
52         #define proc_new(entry,data,size,stack) proc_new_with_name(#entry,(entry),(data),(size),(stack))
53 #endif
54
55 void proc_exit(void);
56 void proc_switch(void);
57 void proc_test(void);
58 struct Process* proc_current(void);
59 iptr_t proc_current_user_data(void);
60 void proc_rename(struct Process* proc, const char* name);
61
62 #if CONFIG_KERN_PREEMPTIVE
63         void proc_forbid(void);
64         void proc_permit(void);
65 #else
66         INLINE void proc_forbid(void) { /* nop */ }
67         INLINE void proc_permit(void) { /* nop */ }
68 #endif
69
70 /*!
71  * Execute a block of \a CODE atomically with respect to task scheduling.
72  */
73 #define PROC_ATOMIC(CODE) \
74         do { \
75                 proc_forbid(); \
76                 CODE; \
77                 proc_permit(); \
78         } while(0)
79
80 #endif /* KERN_PROC_H */
81