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);
159 * Subtract a relative interval from an absolute time.
161 static inline frsh_abs_time_t frsh_abs_time_decr(frsh_abs_time_t time, frsh_rel_time_t interval)
163 return fosa_abs_time_decr(time, interval);
167 * frsh_rel_time_decr()
169 * Subtract a relative interval from another one.
171 static inline frsh_rel_time_t frsh_rel_time_decr(frsh_rel_time_t total, frsh_rel_time_t part)
173 return fosa_rel_time_decr(total, part);
178 * frsh_abs_time_extract_interval()
180 * Subtract two absolute times to get a relative interval.
182 static inline frsh_rel_time_t frsh_abs_time_extract_interval(frsh_abs_time_t past, frsh_abs_time_t future)
184 return fosa_abs_time_extract_interval(past, future);
188 * frsh_rel_time_times_integer()
190 * Multiplies a relative time by an integer
192 static inline frsh_rel_time_t frsh_rel_time_times_integer(frsh_rel_time_t time, long multiplier)
194 return fosa_rel_time_times_integer(time, multiplier);
198 * frsh_rel_time_times_integer()
200 * Multiplies a relative time by an integer
202 static inline frsh_rel_time_t frsh_rel_time_divided_by_integer(frsh_rel_time_t time, long divider)
204 return fosa_rel_time_divided_by_integer(time, divider);
208 /************************************
209 * Conversion to-from natural formats
210 * Note: Overflows may occur
211 ************************************/
214 * frsh_msec_to_rel_time()
216 * Convert an integer value of milliseconds into a relative time interval.
218 static inline frsh_rel_time_t frsh_msec_to_rel_time(long msec)
220 return fosa_msec_to_rel_time(msec);
224 * frsh_rel_time_to_msec()
226 * Convert a relative interval into an integer number of milliseconds.
228 static inline long frsh_rel_time_to_msec(frsh_rel_time_t interval)
230 return fosa_rel_time_to_msec(interval);
234 * frsh_msec_to_abs_time()
236 * Convert an integer value of milliseconds into an absolute time instant
238 static inline frsh_abs_time_t frsh_msec_to_abs_time(long msec)
240 return fosa_msec_to_abs_time(msec);
244 * frsh_abs_time_to_msec()
246 * Convert an absolute instant into an integer number of milliseconds.
248 static inline long frsh_abs_time_to_msec(frsh_abs_time_t instant)
250 return fosa_abs_time_to_msec(instant);
254 * frsh_usec_to_rel_time()
256 * Convert an integer value of microseconds into an absolute instant.
258 static inline frsh_rel_time_t frsh_usec_to_rel_time(long usec)
260 return fosa_usec_to_rel_time(usec);
265 * frsh_rel_time_to_usec()
267 * Convert a relative interval into an integer number of microseconds.
269 static inline long frsh_rel_time_to_usec(frsh_rel_time_t interval)
271 return fosa_rel_time_to_usec(interval);
275 * frsh_usec_to_abs_time()
277 * Convert an integer value of microseconds into an absolute instant.
279 static inline frsh_abs_time_t frsh_usec_to_abs_time(long usec)
281 return fosa_usec_to_abs_time(usec);
286 * frsh_abs_time_to_usec()
288 * Convert a relative interval into an integer number of microseconds.
290 static inline long frsh_abs_time_to_usec(frsh_abs_time_t interval)
292 return fosa_abs_time_to_usec(interval);
296 * frsh_nsec_to_rel_time()
298 * Convert an integer value of microseconds into an absolute instant.
300 static inline frsh_rel_time_t frsh_nsec_to_rel_time(long nsec)
302 return fosa_nsec_to_rel_time(nsec);
307 * frsh_rel_time_to_nsec()
309 * Convert a relative interval into an integer number of microseconds.
311 static inline long frsh_rel_time_to_nsec(frsh_rel_time_t interval)
313 return fosa_rel_time_to_nsec(interval);
317 * frsh_nsec_to_abs_time()
319 * Convert an integer value of microseconds into an absolute instant.
321 static inline frsh_abs_time_t frsh_nsec_to_abs_time(long nsec)
323 return fosa_nsec_to_abs_time(nsec);
328 * frsh_abs_time_to_nsec()
330 * Convert a relative interval into an integer number of microseconds.
332 static inline long frsh_abs_time_to_nsec(frsh_abs_time_t interval)
334 return fosa_abs_time_to_nsec(interval);
337 /******************************************
338 * Conversion to-from POSIX timespec format
339 ******************************************/
342 * frsh_timespec_to_rel_time()
344 * Convert a POSIX timespec value into a relative time interval.
346 static inline frsh_rel_time_t frsh_timespec_to_rel_time(struct timespec interval)
348 return fosa_timespec_to_rel_time(interval);
352 * frsh_rel_time_to_timespec()
354 * Convert a relative interval into a POSIX timespec value.
356 static inline struct timespec frsh_rel_time_to_timespec(frsh_rel_time_t interval)
358 return fosa_rel_time_to_timespec(interval);
362 * frsh_timespec_to_abs_time()
364 * Convert a POSIX timespec value into an absolute time.
366 static inline frsh_abs_time_t frsh_timespec_to_abs_time(struct timespec time)
368 return fosa_timespec_to_abs_time(time);
372 * frsh_abs_time_to_timespec()
374 * Convert an absolute time into a POSIX timespec value.
376 static inline struct timespec frsh_abs_time_to_timespec(frsh_abs_time_t time)
378 return fosa_abs_time_to_timespec(time);
385 * Keep the thread busy executing for a given period of time.
387 static inline void frsh_eat(frsh_rel_time_t *cpu_time)
396 #endif /* !FOSA_TIME_H_ */