Subversion Repositories shark

Rev

Rev 2 | Rev 38 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/**
20
 ------------
21
 CVS :        $Id: event.c,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $
22
 
23
 File:        $File$
24
 Revision:    $Revision: 1.1.1.1 $
25
 Last update: $Date: 2002-03-29 14:12:51 $
26
 ------------
27
 
28
 This file contains the functions to be used into events:
29
 
30
 event_need_reschedule
31
 event_resetepilogue
32
 reschedule
33
 
34
**/
35
 
36
/*
37
 * Copyright (C) 2000 Paolo Gai
38
 *
39
 * This program is free software; you can redistribute it and/or modify
40
 * it under the terms of the GNU General Public License as published by
41
 * the Free Software Foundation; either version 2 of the License, or
42
 * (at your option) any later version.
43
 *
44
 * This program is distributed in the hope that it will be useful,
45
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47
 * GNU General Public License for more details.
48
 *
49
 * You should have received a copy of the GNU General Public License
50
 * along with this program; if not, write to the Free Software
51
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
52
 *
53
 */
54
 
55
#include <stdarg.h>
56
#include <ll/ll.h>
57
#include <ll/stdlib.h>
58
#include <ll/stdio.h>
59
#include <ll/string.h>
60
#include <kernel/config.h>
61
#include <kernel/model.h>
62
#include <kernel/const.h>
63
#include <sys/types.h>
64
#include <kernel/types.h>
65
#include <kernel/descr.h>
66
#include <errno.h>
67
#include <kernel/var.h>
68
#include <kernel/func.h>
69
 
70
static void reschedule(void);
71
 
72
#ifdef __PERF_TEST2__
73
static void perftest_reschedule(void);
74
#endif
75
 
76
/*+ called in an event to force the system to execute the scheduler at
77
    the end of an event list. An event shall NEVER call directly
78
    the sequence {scheduler(); kern_context_load(...);} !!! +*/
79
void event_need_reschedule()
80
{
81
  #ifdef __PERF_TEST2__
82
  event_setepilogue(perftest_reschedule);
83
  #else
84
  event_setepilogue(reschedule);
85
  #endif
86
}
87
 
88
 
89
/* some static functions ...*/
90
 
91
/*+ used to call the scheduler at the end of an event list +*/
92
static void reschedule(void)
93
{
94
  /* we have to change context ONLY IF the sys_end primitive was not called
95
     before (e.g., in a exception raise called by a task_epilogue called by
96
     the scheduler. */
97
  if (mustexit == 0) {
98
    scheduler();
99
    ll_context_to(proc_table[exec_shadow].context);
100
  }
101
}
102
 
103
 
104
/*+ called in the events to force the event handler to reset the event
105
    epilogue; called in __kernel_init__ +*/
106
void event_resetepilogue()
107
{
108
  #ifdef __PERF_TEST2__
109
  extern TIME perftime_prol[10001];
110
  extern int perftime_count;
111
  extern void perftest_epilogue(void);
112
 
113
  if (perftime_count < 10000) {
114
    perftime_prol[perftime_count] = ll_gettime(TIME_EXACT, NULL);
115
  }
116
  event_setepilogue(perftest_epilogue);
117
  #else
118
  event_setepilogue(NULL);
119
  #endif
120
 
121
}
122
 
123
#ifdef __PERF_TEST2__
124
static void perftest_reschedule(void)
125
{
126
  extern TIME perftime_epil[10001];
127
  extern int perftime_count;
128
  reschedule();
129
 
130
  if (perftime_count < 10000){
131
    perftime_epil[perftime_count] = ll_gettime(TIME_EXACT, NULL);
132
    perftime_count++;
133
  }
134
}
135
 
136
static void perftest_epilogue(void)
137
{
138
  extern TIME perftime_epil[10001];
139
  extern int perftime_count;
140
 
141
 
142
  if (perftime_count < 10000) {
143
    perftime_epil[perftime_count] = ll_gettime(TIME_EXACT, NULL);
144
    perftime_count++;
145
  }
146
}
147
#endif
148