Rev 38 | Rev 353 | 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 | ------------ |
||
207 | giacomo | 21 | CVS : $Id: tskmsg.c,v 1.2 2003-07-22 11:56:06 giacomo Exp $ |
38 | pj | 22 | |
23 | File: $File$ |
||
207 | giacomo | 24 | Revision: $Revision: 1.2 $ |
25 | Last update: $Date: 2003-07-22 11:56:06 $ |
||
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 | #include <kernel/trace.h> |
||
64 | |||
65 | |||
66 | /* |
||
67 | The running task (pointed by exec_shadow) sent a message m to the |
||
68 | scheduling module that handle the task p. |
||
69 | |||
70 | If the message has value NULL the behavior should be the |
||
71 | task_endcycle primitive behavior, and an endcycle tracer event is |
||
72 | generated. |
||
73 | |||
74 | */ |
||
207 | giacomo | 75 | int task_message(void *m, PID p, int reschedule) |
38 | pj | 76 | { |
77 | LEVEL l; /* for readableness only */ |
||
78 | |||
79 | int retvalue; |
||
207 | giacomo | 80 | |
81 | if (p == NIL) p = exec_shadow; |
||
38 | pj | 82 | |
83 | if (reschedule) { |
||
84 | proc_table[exec_shadow].context = kern_context_save(); |
||
85 | |||
86 | kern_epilogue_macro(); |
||
87 | |||
207 | giacomo | 88 | l = proc_table[p].task_level; |
89 | retvalue = level_table[l]->public_message(l,p,m); |
||
38 | pj | 90 | |
91 | exec = exec_shadow = -1; |
||
92 | scheduler(); |
||
93 | |||
94 | kern_context_load(proc_table[exec_shadow].context); |
||
95 | |||
96 | } else { |
||
97 | SYS_FLAGS f; |
||
98 | |||
99 | f = kern_fsave(); |
||
207 | giacomo | 100 | l = proc_table[p].task_level; |
101 | retvalue = level_table[l]->public_message(l,p,m); |
||
38 | pj | 102 | kern_frestore(f); |
103 | } |
||
104 | |||
105 | return retvalue; |
||
106 | } |