Subversion Repositories shark

Rev

Rev 318 | Go to most recent revision | 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
 ------------
318 giacomo 21
 CVS :        $Id: tpreempt.c,v 1.3 2003-11-05 15:05:12 giacomo Exp $
2 pj 22
 
23
 File:        $File$
318 giacomo 24
 Revision:    $Revision: 1.3 $
25
 Last update: $Date: 2003-11-05 15:05:12 $
2 pj 26
 ------------
27
 
28
 task_preempt and task_nopreempt
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
 
66
 
67
/*+ This primitive set the non-preemption flag in the task
68
    descriptor control field                               +*/
69
void task_nopreempt(void)
70
{
318 giacomo 71
   SYS_FLAGS f;
72
 
2 pj 73
    if ((~proc_table[exec_shadow].control) & NO_PREEMPT) {
318 giacomo 74
      f = kern_fsave();
2 pj 75
      proc_table[exec_shadow].control |= NO_PREEMPT;
76
      if (cap_timer != NIL) {
38 pj 77
        kern_event_delete(cap_timer);
2 pj 78
        cap_timer = NIL;
79
      }
318 giacomo 80
      kern_frestore(f);
2 pj 81
    }
82
}
83
 
84
/*+ This primitive reset the non-preemption flag in the task
85
    descriptor control field and check if there is a preemption
86
    to make...
87
+*/
88
void task_preempt(void)
89
{
90
    if (proc_table[exec_shadow].control & NO_PREEMPT)
91
    {
92
      proc_table[exec_shadow].context = kern_context_save();
93
 
94
      proc_table[exec_shadow].control &= ~NO_PREEMPT;
95
      scheduler();
96
      kern_context_load(proc_table[exec_shadow].context);
97
    }
98
}