Subversion Repositories shark

Rev

Rev 3 | 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
 ------------
38 pj 21
 CVS :        $Id: tpreempt.c,v 1.2 2003-01-07 17:07:49 pj Exp $
2 pj 22
 
23
 File:        $File$
38 pj 24
 Revision:    $Revision: 1.2 $
25
 Last update: $Date: 2003-01-07 17:07:49 $
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
{
71
    if ((~proc_table[exec_shadow].control) & NO_PREEMPT) {
72
      kern_cli();
73
      proc_table[exec_shadow].control |= NO_PREEMPT;
74
      if (cap_timer != NIL) {
38 pj 75
        kern_event_delete(cap_timer);
2 pj 76
        cap_timer = NIL;
77
      }
78
      kern_sti();
79
    }
80
}
81
 
82
/*+ This primitive reset the non-preemption flag in the task
83
    descriptor control field and check if there is a preemption
84
    to make...
85
+*/
86
void task_preempt(void)
87
{
88
    if (proc_table[exec_shadow].control & NO_PREEMPT)
89
    {
90
      proc_table[exec_shadow].context = kern_context_save();
91
 
92
      proc_table[exec_shadow].control &= ~NO_PREEMPT;
93
      scheduler();
94
      kern_context_load(proc_table[exec_shadow].context);
95
    }
96
}