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: delay.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
 task_delay
29
 
30
**/
31
 
32
/*
33
 * Copyright (C) 2000 Paolo Gai
34
 *
35
 * This program is free software; you can redistribute it and/or modify
36
 * it under the terms of the GNU General Public License as published by
37
 * the Free Software Foundation; either version 2 of the License, or
38
 * (at your option) any later version.
39
 *
40
 * This program is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43
 * GNU General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU General Public License
46
 * along with this program; if not, write to the Free Software
47
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
48
 *
49
 */
50
 
51
#include <stdarg.h>
52
#include <ll/ll.h>
53
#include <ll/stdlib.h>
54
#include <ll/stdio.h>
55
#include <ll/string.h>
56
#include <kernel/config.h>
57
#include <kernel/model.h>
58
#include <kernel/const.h>
59
#include <sys/types.h>
60
#include <kernel/types.h>
61
#include <kernel/descr.h>
62
#include <errno.h>
63
#include <kernel/var.h>
64
#include <kernel/func.h>
65
#include <kernel/trace.h>
66
 
67
/*+
68
  Suspend the task for s time unit
69
+*/
70
void task_delay(DWORD usdelay)
71
{
72
  LEVEL l;            /* for readableness only */
73
  TIME tx;            /* a dummy TIME for timespec operations */
74
  struct timespec ty; /* a dummy timespec for timespec operations */
75
 
76
  /* task_delay is a cancellation point */
77
  task_testcancel();
78
 
79
  proc_table[exec_shadow].context = kern_context_save();
80
 
81
  /* SAME AS SCHEDULER... manage the capacity event and the load_info */
82
  ll_gettime(TIME_EXACT, &schedule_time);
83
  SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty);
84
  tx = TIMESPEC2USEC(&ty);
85
  proc_table[exec_shadow].avail_time -= tx;
86
  jet_update_slice(tx);
87
  if (cap_timer != NIL) {
88
    event_delete(cap_timer);
89
    cap_timer = NIL;
90
  }
91
 
92
  l = proc_table[exec_shadow].task_level;
93
  level_table[l]->task_delay(l,exec_shadow, usdelay);
94
 
95
  /* tracer stuff */
96
  trc_logevent(TRC_DELAY,NULL);
97
 
98
  exec = exec_shadow = -1;
99
  scheduler();
100
  kern_context_load(proc_table[exec_shadow].context);
101
 
102
  /* task_delay is a cancellation point */
103
  task_testcancel();
104
}