Subversion Repositories shark

Rev

Details | 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
 ------------
24
 CVS :        $Id: int_sem.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $
25
 
26
 File:        $File$
27
 Revision:    $Revision: 1.1.1.1 $
28
 Last update: $Date: 2002-03-29 14:12:51 $
29
 ------------
30
 
31
 Internal semaphores.
32
 
33
 They are different from the Posix semaphores and the mutexes because:
34
 - internal_sem_wait is not a cancellation point
35
 - there are no limits on the semaphores that can be created
36
   (they works like a mutex_t...)
37
 - the queuing policy is FIFO
38
 - Be Careful!
39
   they are made to be fast... so not so many controls are done!!!
40
 
41
**/
42
 
43
/*
44
 * Copyright (C) 2000 Paolo Gai
45
 *
46
 * This program is free software; you can redistribute it and/or modify
47
 * it under the terms of the GNU General Public License as published by
48
 * the Free Software Foundation; either version 2 of the License, or
49
 * (at your option) any later version.
50
 *
51
 * This program is distributed in the hope that it will be useful,
52
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
53
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
54
 * GNU General Public License for more details.
55
 *
56
 * You should have received a copy of the GNU General Public License
57
 * along with this program; if not, write to the Free Software
58
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
59
 *
60
 */
61
 
62
#ifndef __INT_SEM_H__
63
#define __INT_SEM_H__
64
 
65
#include <kernel/types.h>
66
 
67
/* this is the structure normally pointed by the opt field in the
68
   mutex_t structure */
69
typedef struct {
70
  int count;
71
  QQUEUE blocked;
72
} internal_sem_t;
73
 
74
 
75
/* this function initializes an internal semaphore */
76
void internal_sem_init(internal_sem_t *s, int value);
77
 
78
/* blocking wait (decrement by 1) */
79
void internal_sem_wait(internal_sem_t *s);
80
 
81
/* return 0 if the counter is decremented, -1 if not */
82
int internal_sem_trywait(internal_sem_t *s);
83
 
84
/* post (increment by 1) */
85
void internal_sem_post(internal_sem_t *s);
86
 
87
/* getvalue (>= 0 if there is noone blocked on it, -1 otherwise) */
88
int internal_sem_getvalue(internal_sem_t *s);
89
 
90
#endif