Subversion Repositories shark

Rev

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

Rev Author Line No. Line
38 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
 ------------
353 giacomo 21
 CVS :        $Id: tskmsg.c,v 1.3 2003-12-10 16:54:59 giacomo Exp $
38 pj 22
 
23
 File:        $File$
353 giacomo 24
 Revision:    $Revision: 1.3 $
25
 Last update: $Date: 2003-12-10 16:54:59 $
38 pj 26
 ------------
27
 
28
**/
29
 
30
/*
31
 * Copyright (C) 2002 Paolo Gai
32
 *
33
 * This program is free software; you can redistribute it and/or modify
34
 * it under the terms of the GNU General Public License as published by
35
 * the Free Software Foundation; either version 2 of the License, or
36
 * (at your option) any later version.
37
 *
38
 * This program is distributed in the hope that it will be useful,
39
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
41
 * GNU General Public License for more details.
42
 *
43
 * You should have received a copy of the GNU General Public License
44
 * along with this program; if not, write to the Free Software
45
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
46
 *
47
 */
48
 
49
#include <stdarg.h>
50
#include <ll/ll.h>
51
#include <ll/stdlib.h>
52
#include <ll/stdio.h>
53
#include <ll/string.h>
54
#include <kernel/config.h>
55
#include <kernel/model.h>
56
#include <kernel/const.h>
57
#include <sys/types.h>
58
#include <kernel/types.h>
59
#include <kernel/descr.h>
60
#include <errno.h>
61
#include <kernel/var.h>
62
#include <kernel/func.h>
63
 
353 giacomo 64
#include <tracer.h>
38 pj 65
 
353 giacomo 66
 
38 pj 67
/*
68
  The running task (pointed by exec_shadow) sent a message m to the
69
  scheduling module that handle the task p.
70
 
71
  If the message has value NULL the behavior should be the
72
  task_endcycle primitive behavior, and an endcycle tracer event is
73
  generated.
74
 
75
*/
207 giacomo 76
int task_message(void *m, PID p, int reschedule)
38 pj 77
{
78
  LEVEL l;            /* for readableness only */
79
 
80
  int retvalue;
207 giacomo 81
 
82
  if (p == NIL) p = exec_shadow;
38 pj 83
 
84
  if (reschedule) {
85
    proc_table[exec_shadow].context = kern_context_save();
86
 
87
    kern_epilogue_macro();
88
 
207 giacomo 89
    l = proc_table[p].task_level;
90
    retvalue = level_table[l]->public_message(l,p,m);
38 pj 91
 
92
    exec = exec_shadow = -1;
93
    scheduler();
94
 
95
    kern_context_load(proc_table[exec_shadow].context);
96
 
97
  } else {
98
    SYS_FLAGS f;
99
 
100
    f = kern_fsave();
207 giacomo 101
    l = proc_table[p].task_level;
102
    retvalue = level_table[l]->public_message(l,p,m);
38 pj 103
    kern_frestore(f);
104
  }
105
 
106
  return retvalue;
107
}