Subversion Repositories shark

Rev

Rev 14 | 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
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
 
22
/**
23
 ------------
14 pj 24
 CVS :        $Id: blkact.c,v 1.2 2002-10-28 07:58:19 pj Exp $
2 pj 25
 
26
 File:        $File$
14 pj 27
 Revision:    $Revision: 1.2 $
28
 Last update: $Date: 2002-10-28 07:58:19 $
2 pj 29
 ------------
30
 
31
 block_activations & co.
32
 
33
**/
34
 
35
/*
36
 * Copyright (C) 2000 Paolo Gai
37
 *
38
 * This program is free software; you can redistribute it and/or modify
39
 * it under the terms of the GNU General Public License as published by
40
 * the Free Software Foundation; either version 2 of the License, or
41
 * (at your option) any later version.
42
 *
43
 * This program is distributed in the hope that it will be useful,
44
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
46
 * GNU General Public License for more details.
47
 *
48
 * You should have received a copy of the GNU General Public License
49
 * along with this program; if not, write to the Free Software
50
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
51
 *
52
 */
53
 
54
#include <stdarg.h>
55
#include <ll/ll.h>
1689 fabio 56
#include <arch/stdlib.h>
57
#include <arch/stdio.h>
58
#include <arch/string.h>
2 pj 59
#include <kernel/config.h>
60
#include <kernel/model.h>
61
#include <kernel/const.h>
62
#include <sys/types.h>
63
#include <kernel/types.h>
64
#include <kernel/descr.h>
65
#include <errno.h>
66
#include <kernel/var.h>
67
#include <kernel/func.h>
68
 
69
/*+
70
  It blocks all explicit activation of a task made with task_activate and
71
  group_activate. These activations are registered in an internal counter,
72
  returned by task_unblock_activation.
73
  it returns 0 if all ok, or -1 otherwise. errno is set accordingly.
74
+*/
75
int task_block_activation(PID p)
76
{
77
    SYS_FLAGS f;
78
 
79
    /* some controls on the task p */
80
    if (p<0 || p>=MAX_PROC) {
14 pj 81
        errno = EINVALID_TASK_ID;
2 pj 82
        return -1;
83
    }
84
    if (proc_table[p].status == FREE) {
14 pj 85
        errno = EINVALID_TASK_ID;
2 pj 86
        return -1;
87
    }
88
 
89
    f = kern_fsave();
90
    if (!(proc_table[p].control & FREEZE_ACTIVATION)) {
91
      proc_table[p].control |= FREEZE_ACTIVATION;
92
      proc_table[p].frozen_activations = 0;
93
    }
94
    kern_frestore(f);
95
    return 0;
96
}
97
 
98
/*+
99
  It unblocks all explicit activations of a task, and returns the number of
100
  "frozen" activations. It not call the task_activate!!!!
101
  it returns -1 if an error occurs. errno is set accordingly.
102
+*/
103
int task_unblock_activation(PID p)
104
{
105
    int result;
106
    SYS_FLAGS f;
107
 
108
    /* some controls on the task p */
109
    if (p<0 || p>=MAX_PROC) {
14 pj 110
        errno = EINVALID_TASK_ID;
2 pj 111
        return -1;
112
    }
113
    if (proc_table[p].status == FREE) {
14 pj 114
        errno = EINVALID_TASK_ID;
2 pj 115
        return -1;
116
    }
117
 
118
    f = kern_fsave();
119
 
120
    result = 0;
121
 
122
    if (proc_table[p].control & FREEZE_ACTIVATION) {
123
      proc_table[p].control &= ~FREEZE_ACTIVATION;
124
      result = proc_table[p].frozen_activations;
125
      proc_table[p].frozen_activations = 0;
126
    }
127
    kern_frestore(f);
128
 
129
    return result;
130
}