source: rtems/testsuites/support/src/spin.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <rtems.h>
15#include "test_support.h"
16
17/*
18 *  Burn CPU for specified number of ticks
19 */
20void rtems_test_spin_for_ticks(int ticks)
21{
22  rtems_interval        start;
23  rtems_interval        now;
24
25  start = rtems_clock_get_ticks_since_boot();
26  do {
27    now = rtems_clock_get_ticks_since_boot();
28    /*
29     *  Spin for <= ticks so we spin >= number of ticks.
30     *  The first tick we spin through is a partial one.
31     *  So you sping "ticks" number of ticks plus a partial
32     *  one.
33     */
34  } while ( (now-start) <= ticks );
35}
36
37/*
38 *  Spin until the next clock tick
39 */
40void rtems_test_spin_until_next_tick( void )
41{
42  rtems_interval        start;
43  rtems_interval        now;
44
45  start = rtems_clock_get_ticks_since_boot();
46  do {
47    now = rtems_clock_get_ticks_since_boot();
48  } while ( now != start );
49}
Note: See TracBrowser for help on using the repository browser.