Subversion Repositories shark

Rev

Rev 2 | 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: sleep.c,v 1.1.1.1 2002-03-29 14:12:52 pj Exp $
22
 
23
 File:        $File$
24
 Revision:    $Revision: 1.1.1.1 $
25
 Last update: $Date: 2002-03-29 14:12:52 $
26
 ------------
27
 
28
 task_sleep
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
  Puts the actual executing task in the sleep state
69
  The change of state is made by the task call task_sleep
70
+*/
71
void task_sleep(void)
72
{
73
  LEVEL l;            /* for readableness only */
74
  TIME tx;            /* a dummy TIME for timespec operations */
75
  struct timespec ty; /* a dummy timespec for timespec operations */
76
 
77
  proc_table[exec_shadow].context = kern_context_save();
78
 
79
  /* SAME AS SCHEDULER... manage the capacity event and the load_info */
80
  ll_gettime(TIME_EXACT, &schedule_time);
81
  SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty);
82
  tx = TIMESPEC2USEC(&ty);
83
  proc_table[exec_shadow].avail_time -= tx;
84
  jet_update_slice(tx);
85
  if (cap_timer != NIL) {
86
    event_delete(cap_timer);
87
    cap_timer = NIL;
88
  }
89
 
90
  l = proc_table[exec_shadow].task_level;
91
  level_table[l]->task_sleep(l,exec_shadow);
92
 
93
  /* SAME AS TASK_ENDCYCLE!!! */
94
  jet_update_endcycle();
95
 
96
  trc_logevent(TRC_SLEEP, &exec_shadow);
97
 
98
  exec = exec_shadow = -1;
99
  scheduler();
100
  kern_context_load(proc_table[exec_shadow].context);
101
}