4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
33 * \brief Test kernel process.
36 * \author Daniele Basile <asterix@develer.com>
39 #include <kern/proc.h>
41 #include <kern/monitor.h>
43 #include <drv/timer.h>
47 // Global settings for the test.
50 // Settings for the test process.
53 #define DELAY_PROC_T1 INC_PROC_T1*DELAY
56 #define DELAY_PROC_T2 INC_PROC_T2*DELAY
59 #define DELAY_PROC_T3 INC_PROC_T3*DELAY
62 #define DELAY_PROC_T4 INC_PROC_T4*DELAY
64 #define INC_PROC_T5 11
65 #define DELAY_PROC_T5 INC_PROC_T5*DELAY
67 #define INC_PROC_T6 13
68 #define DELAY_PROC_T6 INC_PROC_T6*DELAY
70 #define INC_PROC_T7 17
71 #define DELAY_PROC_T7 INC_PROC_T7*DELAY
73 #define INC_PROC_T8 19
74 #define DELAY_PROC_T8 INC_PROC_T8*DELAY
76 //Global count for each process.
77 unsigned int t1_count = 0;
78 unsigned int t2_count = 0;
79 unsigned int t3_count = 0;
80 unsigned int t4_count = 0;
81 unsigned int t5_count = 0;
82 unsigned int t6_count = 0;
83 unsigned int t7_count = 0;
84 unsigned int t8_count = 0;
87 * These macros generate the code needed to create the test process functions.
89 #define PROC_TEST(num) static void proc_test##num(void) \
91 for (int i = 0; i < INC_PROC_T##num; ++i) \
94 kprintf("> Process[%d]: count[%d]\n", num, t##num##_count); \
95 timer_delay(DELAY_PROC_T##num); \
99 #define PROC_TEST_STACK(num) static cpu_stack_t proc_test##num##_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpu_stack_t)];
100 #define PROC_TEST_INIT(num) proc_new(proc_test##num, NULL, sizeof(proc_test##num##_stack), proc_test##num##_stack);
112 // Define process stacks for test.
124 * Process scheduling test
126 int proc_testRun(void)
128 kprintf("Run Process test..\n");
130 //Init the process tests
139 kputs("> Main: Processes created\n");
141 for (int i = 0; i < 30; ++i)
148 if( t1_count == INC_PROC_T1 &&
149 t2_count == INC_PROC_T2 &&
150 t3_count == INC_PROC_T3 &&
151 t4_count == INC_PROC_T4 &&
152 t5_count == INC_PROC_T5 &&
153 t6_count == INC_PROC_T6 &&
154 t7_count == INC_PROC_T7 &&
155 t8_count == INC_PROC_T8)
157 kputs("> Main: process test finished..ok!\n");
161 kputs("> Main: process test..fail!\n");
166 int proc_testSetup(void)
170 #if CONFIG_KERN_PREEMPT
171 kprintf("Init Interrupt (preempt mode)..");
176 kprintf("Init Timer..");
180 kprintf("Init Process..");
187 int proc_testTearDown(void)
189 kputs("TearDown Process test.\n");