Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
/*
2
 * Project: HARTIK (HA-rd R-eal TI-me K-ernel)
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *               Gerardo Lamastra <gerardo@sssup.it>
6
 *
7
 * Authors     : Paolo Gai <pj@hartik.sssup.it>
8
 * (see authors.txt for full list of hartik's authors)
9
 *
10
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
11
 *
12
 * http://www.sssup.it
13
 * http://retis.sssup.it
14
 * http://hartik.sssup.it
15
 */
16
 
17
/**
18
 ------------
19
 CVS :        $Id: sysend.c,v 1.1.1.1 2002-09-02 09:37:48 pj Exp $
20
 
21
 File:        $File$
22
 Revision:    $Revision: 1.1.1.1 $
23
 Last update: $Date: 2002-09-02 09:37:48 $
24
 ------------
25
 
26
 System termination:
27
 
28
   the main task create J1, J2 and wait until 1 sec., then it calls sys_end
29
     and cycles around a task_testcancel
30
 
31
   J1 is a system task that ends at t=1.5 sec.
32
 
33
   J2 is another user task that dies at t= 1.8 sec (it will not die!!!)
34
 
35
 
36
**/
37
 
38
/*
39
 * Copyright (C) 2000 Paolo Gai
40
 *
41
 * This program is free software; you can redistribute it and/or modify
42
 * it under the terms of the GNU General Public License as published by
43
 * the Free Software Foundation; either version 2 of the License, or
44
 * (at your option) any later version.
45
 *
46
 * This program is distributed in the hope that it will be useful,
47
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
49
 * GNU General Public License for more details.
50
 *
51
 * You should have received a copy of the GNU General Public License
52
 * along with this program; if not, write to the Free Software
53
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
54
 *
55
 */
56
 
57
#include <sys/types.h>
58
#include <pthread.h>
59
#include <signal.h>
60
 
61
#include <kernel/kern.h>
62
#include <drivers/keyb.h>
63
 
64
void *J1(void *arg)
65
{
66
  while (sys_gettime(NULL) < 1500000);
67
  kern_printf("J1: t = 1.5 sec, ending...");
68
  return 0;
69
}
70
 
71
void uscitaJ2(void *arg)
72
{
73
  kern_printf("J2: AAAARRRRGGGHHH!!! killed by someone, time = %ld\n",sys_gettime(NULL));
74
}
75
 
76
void *J2(void *arg)
77
{
78
  task_cleanup_push(uscitaJ2,NULL);
79
 
80
  while (sys_gettime(NULL) < 1800000);
81
  kern_printf("J1: t = 1.8 sec, ending...");
82
 
83
  task_cleanup_pop(0);
84
  return 0;
85
}
86
 
87
void fine(KEY_EVT *e)
88
{
89
  sys_end();
90
}
91
 
92
void uscitamain(void *arg)
93
{
94
  kern_printf("main: AAAARRRRGGGHHH!!! killed by someone, time = %ld\n",sys_gettime(NULL));
95
}
96
 
97
 
98
int main(int argc, char **argv)
99
{
100
  PID err;
101
 
102
  NRT_TASK_MODEL m1, m2;
103
 
104
    KEY_EVT emerg;
105
    //keyb_set_map(itaMap);
106
    emerg.ascii = 'x';
107
    emerg.scan = KEY_X;
108
    emerg.flag = ALTL_BIT;
109
    keyb_hook(emerg,fine);
110
 
111
 
112
  nrt_task_default_model(m1);
113
  nrt_task_def_system(m1);
114
  nrt_task_def_level(m1,1);
115
  nrt_task_default_model(m2);
116
  nrt_task_def_level(m2,1);
117
 
118
  kern_printf("main: creating J1\n");
119
  err = task_create("J1", J1, (TASK_MODEL *)&m1, NULL);
120
  if (err == -1) kern_printf("Error creating J1\n");
121
  task_activate(err);
122
 
123
  kern_printf("main: creating J2\n");
124
  err = task_create("J2", J2, (TASK_MODEL *)&m2, NULL);
125
  if (err == -1) kern_printf("Error creating J2\n");
126
  task_activate(err);
127
 
128
  kern_printf("main: waiting 1 sec\n");
129
  while (sys_gettime(NULL) < 1000000);
130
 
131
  kern_printf("main: sys_end()\n");
132
 
133
  sys_end();
134
 
135
  task_cleanup_push(uscitamain,NULL);
136
 
137
  while (1)
138
    task_testcancel();
139
 
140
  task_cleanup_pop(0);
141
 
142
  return 0;
143
}