Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
865 | trimarchi | 1 | //fsf_shared_objects.h |
2 | //================================================== |
||
3 | // FFFFFFIII RRRRR SSTTTTTTT |
||
4 | // FF IIR RR SS |
||
5 | // FF IR SS |
||
6 | // FFFFFF RRRR SSSSST |
||
7 | // FF FI RRR SS |
||
8 | // FF II RRR SS |
||
9 | // FF IIIIIR RS |
||
10 | // |
||
11 | // FSF(FIRST Scheduling Framework) |
||
12 | // shared objects functionality |
||
13 | //==================================================== |
||
14 | |||
15 | #include <pthread.h> |
||
16 | #include "fsf_basic_types.h" |
||
17 | #include "fsf_core.h" |
||
18 | |||
19 | #ifndef _FSF_SHARED_OBJECTS_H_ |
||
20 | #define _FSF_SHARED_OBJECTS_H_ |
||
21 | |||
22 | #define FSF_SHARED_OBJECTS_MODULE_SUPPORTED 1 |
||
23 | |||
24 | |||
25 | // These constants are defined in the fsf_configuration_parameters.h |
||
26 | // file: |
||
27 | |||
28 | //#define FSF_MAX_N_SHARED_OBJECTS 100 |
||
29 | //#define FSF_MAX_N_CRITICAL_SECTIONS 20 |
||
30 | |||
31 | |||
32 | //// The definition of this types is in fsf_basic_types.h |
||
33 | // |
||
34 | //// Shared object identifier (null character terminated string) |
||
35 | //typedef char * fsf_shared_obj_id_t; |
||
36 | // |
||
37 | //// Shared object handle (opaque type) |
||
38 | //typedef FSF_SHARED_OBJ_HANDLE_T_OPAQUE fsf_shared_obj_handle_t; |
||
39 | // |
||
40 | //// Critical section data |
||
41 | //typedef struct { |
||
42 | // fsf_shared_obj_handle_t obj_handle; |
||
43 | // struct timespec wcet; //Execution time |
||
44 | //} fsf_critical_section_data_t; |
||
45 | // |
||
46 | //// List of critical sections |
||
47 | //typedef struct { |
||
48 | // int size; // = 0 |
||
49 | // fsf_critical_section_data_t |
||
50 | // section[FSF_MAX_N_CRITICAL_SECTIONS]; |
||
51 | //} fsf_critical_sections_t; |
||
52 | // |
||
53 | |||
54 | ///////////////////////////////////////////////////// |
||
55 | // SHARED OBJECTS & OPERATIONS MANAGEMENT |
||
56 | ///////////////////////////////////////////////////// |
||
57 | |||
58 | // fsf_init_shared_object: Initialization of shared objects. If the |
||
59 | // object identified by obj_id does not yet exist it is created, a |
||
60 | // handle to the object is returned in the variable pointed to by |
||
61 | // obj_handle, and the specified mutex is initialized with the |
||
62 | // appropriate attributes necessary for the current implementation. |
||
63 | // If the object already exists, the function fails. |
||
64 | |||
65 | int fsf_init_shared_object |
||
66 | (fsf_shared_obj_id_t obj_id, |
||
67 | fsf_shared_obj_handle_t *obj_handle, |
||
68 | pthread_mutex_t *mutex); |
||
69 | |||
70 | |||
71 | // fsf_get_shared_object_handle: getting the handle of shared |
||
72 | // objects. If the object already exists a handle to the object is |
||
73 | // returned in the variable pointed to by obj_handle. Otherwise, an |
||
74 | // error code is returned by the function. |
||
75 | |||
76 | int fsf_get_shared_object_handle |
||
77 | (fsf_shared_obj_id_t obj_id, |
||
78 | fsf_shared_obj_handle_t *obj_handle); |
||
79 | |||
80 | // fsf_get_shared_object_mutex: getting the mutex of shared |
||
81 | // objects. If the object exists, a pointer to its associated mutex is |
||
82 | // returned in the variable pointed to by mutex. Otherwise, an error |
||
83 | // code is returned by the function. |
||
84 | |||
85 | int fsf_get_shared_object_mutex |
||
86 | (fsf_shared_obj_handle_t obj_handle, |
||
87 | pthread_mutex_t **mutex); |
||
88 | |||
89 | |||
90 | ///////////////////////////////////////////////////// |
||
91 | // CONTRACT PARAMETERS |
||
92 | ///////////////////////////////////////////////////// |
||
93 | |||
94 | //fsf_set_contract_synchronization_parameters: The operation updates |
||
95 | //the specified contract parameters object by setting its critical |
||
96 | //sections to the specified input parameter. |
||
97 | |||
98 | int |
||
99 | fsf_set_contract_synchronization_parameters |
||
100 | (fsf_contract_parameters_t *contract, |
||
101 | const fsf_critical_sections_t *critical_sections); |
||
102 | |||
103 | |||
104 | //fsf_get_contract_synchronization_parameters: The operation obtains |
||
105 | //from the specified contract parameters object its critical sections, |
||
106 | //and copies them to the places pointed to by the specified input |
||
107 | //parameter. Only those critical_section_data records that are in use |
||
108 | //in the critical_sections structure are copied (according to its size |
||
109 | //field). |
||
110 | |||
111 | int |
||
112 | fsf_get_contract_synchronization_parameters |
||
113 | (const fsf_contract_parameters_t *contract, |
||
114 | fsf_critical_sections_t *critical_sections); |
||
115 | |||
116 | |||
117 | #endif // _FSF_SHARED_OBJECTS_H_ |