Subversion Repositories shark

Rev

Rev 916 | 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
 ------------
916 pj 21
 CVS :        $Id: event.c,v 1.3 2005-01-08 14:45:23 pj Exp $
2 pj 22
 
23
 File:        $File$
916 pj 24
 Revision:    $Revision: 1.3 $
25
 Last update: $Date: 2005-01-08 14:45:23 $
2 pj 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>
1689 fabio 57
#include <arch/stdlib.h>
58
#include <arch/stdio.h>
59
#include <arch/string.h>
2 pj 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
 
916 pj 91
int event_noreschedule = 0;
92
 
2 pj 93
/*+ used to call the scheduler at the end of an event list +*/
94
static void reschedule(void)
95
{
916 pj 96
  if (!event_noreschedule) {
2 pj 97
    scheduler();
98
    ll_context_to(proc_table[exec_shadow].context);
99
  }
100
}
101
 
102
 
103
/*+ called in the events to force the event handler to reset the event
104
    epilogue; called in __kernel_init__ +*/
105
void event_resetepilogue()
106
{
107
  #ifdef __PERF_TEST2__
108
  extern TIME perftime_prol[10001];
109
  extern int perftime_count;
110
  extern void perftest_epilogue(void);
111
 
112
  if (perftime_count < 10000) {
38 pj 113
    perftime_prol[perftime_count] = kern_gettime(NULL);
2 pj 114
  }
115
  event_setepilogue(perftest_epilogue);
116
  #else
117
  event_setepilogue(NULL);
118
  #endif
119
 
120
}
121
 
122
#ifdef __PERF_TEST2__
123
static void perftest_reschedule(void)
124
{
125
  extern TIME perftime_epil[10001];
126
  extern int perftime_count;
127
  reschedule();
128
 
129
  if (perftime_count < 10000){
38 pj 130
    perftime_epil[perftime_count] = kern_gettime(NULL);
2 pj 131
    perftime_count++;
132
  }
133
}
134
 
135
static void perftest_epilogue(void)
136
{
137
  extern TIME perftime_epil[10001];
138
  extern int perftime_count;
139
 
140
 
141
  if (perftime_count < 10000) {
38 pj 142
    perftime_epil[perftime_count] = kern_gettime(NULL);
2 pj 143
    perftime_count++;
144
  }
145
}
146
#endif
147