Subversion Repositories shark

Rev

Rev 79 | 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
 *   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
 ------------
79 pj 24
 CVS :        $Id: int_sem.h,v 1.3 2003-03-13 13:36:28 pj Exp $
2 pj 25
 
26
 File:        $File$
79 pj 27
 Revision:    $Revision: 1.3 $
28
 Last update: $Date: 2003-03-13 13:36:28 $
2 pj 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>
29 pj 66
#include <kernel/iqueue.h>
79 pj 67
#include "ll/sys/cdefs.h"
2 pj 68
 
79 pj 69
__BEGIN_DECLS
70
 
2 pj 71
/* this is the structure normally pointed by the opt field in the
72
   mutex_t structure */
73
typedef struct {
74
  int count;
29 pj 75
  IQUEUE blocked;
2 pj 76
} internal_sem_t;
77
 
78
 
79
/* this function initializes an internal semaphore */
80
void internal_sem_init(internal_sem_t *s, int value);
81
 
82
/* blocking wait (decrement by 1) */
83
void internal_sem_wait(internal_sem_t *s);
84
 
85
/* return 0 if the counter is decremented, -1 if not */
86
int internal_sem_trywait(internal_sem_t *s);
87
 
88
/* post (increment by 1) */
89
void internal_sem_post(internal_sem_t *s);
90
 
91
/* getvalue (>= 0 if there is noone blocked on it, -1 otherwise) */
92
int internal_sem_getvalue(internal_sem_t *s);
93
 
79 pj 94
__END_DECLS
2 pj 95
#endif