1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2008 FRESCOR consortium partners:
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
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org for a link to partners' websites
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
24 // based on previous work (FSF) done in the FIRST project
26 // Copyright (C) 2005 Mälardalen University, SWEDEN
27 // Scuola Superiore S.Anna, ITALY
28 // Universidad de Cantabria, SPAIN
29 // University of York, UK
31 // FSF API web pages: http://marte.unican.es/fsf/docs
32 // http://shark.sssup.it/contrib/first/docs/
34 // This file is part of FRSH (FRescor ScHeduler)
36 // FRSH is free software; you can redistribute it and/or modify it
37 // under terms of the GNU General Public License as published by the
38 // Free Software Foundation; either version 2, or (at your option) any
39 // later version. FRSH is distributed in the hope that it will be
40 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
41 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
42 // General Public License for more details. You should have received a
43 // copy of the GNU General Public License along with FRSH; see file
44 // COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
45 // Cambridge, MA 02139, USA.
47 // As a special exception, including FRSH header files in a file,
48 // instantiating FRSH generics or templates, or linking other files
49 // with FRSH objects to produce an executable application, does not
50 // by itself cause the resulting executable application to be covered
51 // by the GNU General Public License. This exception does not
52 // however invalidate any other reasons why the executable file might be
53 // covered by the GNU Public License.
54 // -----------------------------------------------------------------------
55 //frsh_spare_capacity_types.h
56 //==============================================
57 // ******** ******* ******** ** **
58 // **///// /**////** **////// /** /**
59 // ** /** /** /** /** /**
60 // ******* /******* /********* /**********
61 // **//// /**///** ////////** /**//////**
62 // ** /** //** /** /** /**
63 // ** /** //** ******** /** /**
64 // // // // //////// // //
66 // FRSH(FRescor ScHeduler), pronounced "fresh"
67 //==============================================
72 #include "frsh_core_types.h"
73 #include "frsh_core.h"
87 /***********************
88 * Relational operations
89 ***********************/
92 * frsh_abs_time_smaller()
94 * Check if an absolute time is smaller than another one.
96 static inline bool frsh_abs_time_smaller(frsh_abs_time_t t1, frsh_abs_time_t t2)
98 return fosa_abs_time_smaller(t1, t2);
102 * frsh_rel_time_smaller()
104 * Check if a relative interval is smaller than another one.
106 static inline bool frsh_rel_time_smaller(frsh_rel_time_t t1, frsh_rel_time_t t2)
108 return fosa_rel_time_smaller(t1, t2);
112 * frsh_abs_time_smaller_or_equal()
114 * Check if an absolute time is smaller than or equal to another one.
116 static inline bool frsh_abs_time_smaller_or_equal(frsh_abs_time_t t1, frsh_abs_time_t t2)
118 return fosa_abs_time_smaller_or_equal(t1, t2);
122 * frsh_rel_time_smaller_or_equal()
124 * Check if a relative interval is smaller than or equal to another one.
126 static inline bool frsh_rel_time_smaller_or_equal(frsh_rel_time_t t1, frsh_rel_time_t t2)
128 return fosa_rel_time_smaller_or_equal(t1, t2);
132 /***********************
133 * Arithmetic operations
134 ***********************/
137 * frsh_abs_time_incr()
139 * Add a relative interval to an absolute time.
141 static inline frsh_abs_time_t frsh_abs_time_incr(frsh_abs_time_t base, frsh_rel_time_t interval)
143 return fosa_abs_time_incr(base, interval);
147 * frsh_rel_time_add()
149 * Add a relative interval to another one.
151 static inline frsh_rel_time_t frsh_rel_time_add(frsh_rel_time_t t1, frsh_rel_time_t t2)
153 return fosa_rel_time_add(t1, t2);
156 static inline frsh_rel_time_t frsh_rel_time_incr(frsh_rel_time_t t1, frsh_rel_time_t t2)
158 return fosa_rel_time_add(t1, t2);
167 * Subtract a relative interval from an absolute time.
169 static inline frsh_abs_time_t frsh_abs_time_decr(frsh_abs_time_t time, frsh_rel_time_t interval)
171 return fosa_abs_time_decr(time, interval);
175 * frsh_rel_time_decr()
177 * Subtract a relative interval from another one.
179 static inline frsh_rel_time_t frsh_rel_time_decr(frsh_rel_time_t total, frsh_rel_time_t part)
181 return fosa_rel_time_decr(total, part);
186 * frsh_abs_time_extract_interval()
188 * Subtract two absolute times to get a relative interval.
190 static inline frsh_rel_time_t frsh_abs_time_extract_interval(frsh_abs_time_t past, frsh_abs_time_t future)
192 return fosa_abs_time_extract_interval(past, future);
196 static inline frsh_rel_time_t frsh_abs_time_subtract(frsh_abs_time_t past, frsh_abs_time_t future)
198 return fosa_abs_time_extract_interval(past, future);
205 * frsh_rel_time_times_integer()
207 * Multiplies a relative time by an integer
209 static inline frsh_rel_time_t frsh_rel_time_times_integer(frsh_rel_time_t time, long multiplier)
211 return fosa_rel_time_times_integer(time, multiplier);
215 * frsh_rel_time_times_integer()
217 * Multiplies a relative time by an integer
219 static inline frsh_rel_time_t frsh_rel_time_divided_by_integer(frsh_rel_time_t time, long divider)
221 return fosa_rel_time_divided_by_integer(time, divider);
225 /************************************
226 * Conversion to-from natural formats
227 * Note: Overflows may occur
228 ************************************/
231 * frsh_msec_to_rel_time()
233 * Convert an integer value of milliseconds into a relative time interval.
235 static inline frsh_rel_time_t frsh_msec_to_rel_time(long msec)
237 return fosa_msec_to_rel_time(msec);
241 * frsh_rel_time_to_msec()
243 * Convert a relative interval into an integer number of milliseconds.
245 static inline long frsh_rel_time_to_msec(frsh_rel_time_t interval)
247 return fosa_rel_time_to_msec(interval);
251 * frsh_msec_to_abs_time()
253 * Convert an integer value of milliseconds into an absolute time instant
255 static inline frsh_abs_time_t frsh_msec_to_abs_time(long msec)
257 return fosa_msec_to_abs_time(msec);
261 * frsh_abs_time_to_msec()
263 * Convert an absolute instant into an integer number of milliseconds.
265 static inline long frsh_abs_time_to_msec(frsh_abs_time_t instant)
267 return fosa_abs_time_to_msec(instant);
271 * frsh_usec_to_rel_time()
273 * Convert an integer value of microseconds into an absolute instant.
275 static inline frsh_rel_time_t frsh_usec_to_rel_time(long usec)
277 return fosa_usec_to_rel_time(usec);
282 * frsh_rel_time_to_usec()
284 * Convert a relative interval into an integer number of microseconds.
286 static inline long frsh_rel_time_to_usec(frsh_rel_time_t interval)
288 return fosa_rel_time_to_usec(interval);
292 * frsh_usec_to_abs_time()
294 * Convert an integer value of microseconds into an absolute instant.
296 static inline frsh_abs_time_t frsh_usec_to_abs_time(long usec)
298 return fosa_usec_to_abs_time(usec);
303 * frsh_abs_time_to_usec()
305 * Convert a relative interval into an integer number of microseconds.
307 static inline long frsh_abs_time_to_usec(frsh_abs_time_t interval)
309 return fosa_abs_time_to_usec(interval);
313 * frsh_nsec_to_rel_time()
315 * Convert an integer value of microseconds into an absolute instant.
317 static inline frsh_rel_time_t frsh_nsec_to_rel_time(long nsec)
319 return fosa_nsec_to_rel_time(nsec);
324 * frsh_rel_time_to_nsec()
326 * Convert a relative interval into an integer number of microseconds.
328 static inline long frsh_rel_time_to_nsec(frsh_rel_time_t interval)
330 return fosa_rel_time_to_nsec(interval);
334 * frsh_nsec_to_abs_time()
336 * Convert an integer value of microseconds into an absolute instant.
338 static inline frsh_abs_time_t frsh_nsec_to_abs_time(long nsec)
340 return fosa_nsec_to_abs_time(nsec);
345 * frsh_abs_time_to_nsec()
347 * Convert a relative interval into an integer number of microseconds.
349 static inline long frsh_abs_time_to_nsec(frsh_abs_time_t interval)
351 return fosa_abs_time_to_nsec(interval);
354 /******************************************
355 * Conversion to-from POSIX timespec format
356 ******************************************/
359 * frsh_timespec_to_rel_time()
361 * Convert a POSIX timespec value into a relative time interval.
363 static inline frsh_rel_time_t frsh_timespec_to_rel_time(struct timespec interval)
365 return fosa_timespec_to_rel_time(interval);
369 * frsh_rel_time_to_timespec()
371 * Convert a relative interval into a POSIX timespec value.
373 static inline struct timespec frsh_rel_time_to_timespec(frsh_rel_time_t interval)
375 return fosa_rel_time_to_timespec(interval);
379 * frsh_timespec_to_abs_time()
381 * Convert a POSIX timespec value into an absolute time.
383 static inline frsh_abs_time_t frsh_timespec_to_abs_time(struct timespec time)
385 return fosa_timespec_to_abs_time(time);
389 * frsh_abs_time_to_timespec()
391 * Convert an absolute time into a POSIX timespec value.
393 static inline struct timespec frsh_abs_time_to_timespec(frsh_abs_time_t time)
395 return fosa_abs_time_to_timespec(time);
402 * Keep the thread busy executing for a given period of time.
404 static inline void frsh_eat(frsh_rel_time_t *cpu_time)
413 #endif /* !FOSA_TIME_H_ */