Subversion Repositories shark

Rev

Details | 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: endcycle.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
 Kernel module registration and miscellaneous functions
29
 
30
 This file contains:
31
 
32
 task_endcycle
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
#include <kernel/trace.h>
70
 
71
 
72
/*+
73
  Suspend the executing periodic task till the next period
74
 
75
  The executing task will be now placed into the right queue...
76
  normally, it goes also in the idle state if it is periodic or
77
  in the sleep state if it is aperiodic.
78
 
79
  I.e., if the task is an hard-periodic task & we are calling the
80
  task_endcycle, then it cannot be over the deadline because the
81
  timer should detect this; anyway it could be finishing just on
82
  the deadline! In this case, we must place it into a ready queue
83
+*/
84
void task_endcycle(void)
85
{
86
  LEVEL l;            /* for readableness only */
87
  TIME tx;            /* a dummy TIME for timespec operations */
88
  struct timespec ty; /* a dummy timespec for timespec operations */
89
 
90
  proc_table[exec_shadow].context = kern_context_save();
91
 
92
  /* SAME AS SCHEDULER... manage the capacity event and the load_info */
93
  ll_gettime(TIME_EXACT, &schedule_time);
94
  SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty);
95
  tx = TIMESPEC2USEC(&ty);
96
  proc_table[exec_shadow].avail_time -= tx;
97
  jet_update_slice(tx);
98
  if (cap_timer != NIL) {
99
    event_delete(cap_timer);
100
    cap_timer = NIL;
101
  }
102
 
103
  l = proc_table[exec_shadow].task_level;
104
  level_table[l]->task_endcycle(l,exec_shadow);
105
 
106
  /* Update the Jet data... */
107
  jet_update_endcycle();
108
 
109
  /* tracer stuff */
110
  trc_logevent(TRC_ENDCYCLE,&exec_shadow);
111
 
112
  exec = exec_shadow = -1;
113
  scheduler();
114
  kern_context_load(proc_table[exec_shadow].context);
115
}