]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blob - frsh_freelist.h
endpoint is passed by value now, created frsh_distributed_init
[frescor/frsh-include.git] / frsh_freelist.h
1 // -----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
3 //
4 //    Universidad de Cantabria,              SPAIN
5 //    University of York,                    UK
6 //    Scuola Superiore Sant'Anna,            ITALY
7 //    Kaiserslautern University,             GERMANY
8 //    Univ. Politécnica  Valencia,           SPAIN
9 //    Czech Technical University in Prague,  CZECH REPUBLIC
10 //    ENEA                                   SWEDEN
11 //    Thales Communication S.A.              FRANCE
12 //    Visual Tools S.A.                      SPAIN
13 //    Rapita Systems Ltd                     UK
14 //    Evidence                               ITALY
15 //
16 //    See http://www.frescor.org for a link to partners' websites
17 //
18 //           FRESCOR project (FP6/2005/IST/5-034026) is funded
19 //        in part by the European Union Sixth Framework Programme
20 //        The European Union is not liable of any use that may be
21 //        made of this code.
22 //
23 //
24 //  This file is part of FRSH Implementation
25 //
26 //  FRSH API is free software; you can  redistribute it and/or  modify
27 //  it under the terms of  the GNU General Public License as published by
28 //  the Free Software Foundation;  either  version 2, or (at  your option)
29 //  any later version.
30 //
31 //  FRSH API  is distributed  in  the hope  that  it  will  be useful,  but
32 //  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
33 //  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
34 //  General Public License for more details.
35 //
36 //  You should have  received a  copy of  the  GNU  General Public License
37 //  distributed  with  FRSH API;  see file COPYING.   If not,  write to the
38 //  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
39 //  02111-1307, USA.
40 //
41 //  As a special exception, if you include this header file into source
42 //  files to be compiled, this header file does not by itself cause
43 //  the resulting executable to be covered by the GNU General Public
44 //  License.  This exception does not however invalidate any other
45 //  reasons why the executable file might be covered by the GNU General
46 //  Public License.
47 // -----------------------------------------------------------------------
48 //==============================================
49 //  ******** *******    ********  **      **
50 //  **///// /**////**  **//////  /**     /**
51 //  **      /**   /** /**        /**     /**
52 //  ******* /*******  /********* /**********
53 //  **////  /**///**  ////////** /**//////**
54 //  **      /**  //**        /** /**     /**
55 //  **      /**   //** ********  /**     /**
56 //  //       //     // ////////   //      //
57 //
58 // FRSH(FRescor ScHeduler), pronounced "fresh"
59 //==============================================
60 //
61
62 // This header file defines the interface to a pair of functions used
63 // to manage a sinly linked list that is used to find free cells in
64 // some external table.
65 //
66 // Parallel to the external table, there is a table of indexes
67 // organized as a singly linked list; it is the free list. A separate
68 // index, free_cell, indicates which is the first element of the sibly
69 // linked list. The list is terminated with an index of -1.
70
71
72 #ifndef FRSH_FREELIST
73 #define FRSH_FREELIST
74
75 typedef struct {
76   int * freelist;
77   int first_free;
78 } frsh_freelist_t;
79
80 /**
81  *  Initialize a free list adding all the cells to the list of free cells
82  *  The size of the list is specified by size.
83  *  Returns: 0 if successful
84  *           FRSH_ERR_NO_SPACE if there is not enough memory available
85  */
86 int frsh_freelist_init(frsh_freelist_t *list, int size);
87
88 /**
89  *  Obtain the index of a free cell from the free list specified by list
90  *  the cell is removed from the list 
91  *  Returns the index to the requested cell, or -1 if there are no free cells
92  */
93 int frsh_freelist_alloc(frsh_freelist_t *list);
94
95
96 /**
97  * Deallocate the cell specified by index cell adding it to the list
98  * of free cells specified by list
99  * Returns 0 if successful, or -1 if the cell was already free
100  */
101 int frsh_freelist_free(frsh_freelist_t *list, int cell);
102
103 #endif // FRSH_FREELIST