source: rtems/testsuites/sptests/spnsext01/init.c @ 28779c7

4.11
Last change on this file since 28779c7 was 28779c7, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 7, 2014 at 11:53:41 AM

score: Add function to destroy SMP locks

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 * Copyright (c) 2011 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.com/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <tmacros.h>
20
21static rtems_task Init(rtems_task_argument argument)
22{
23  rtems_status_code sc = RTEMS_SUCCESSFUL;
24  rtems_interrupt_lock lock;
25  rtems_interrupt_lock_context lock_context;
26  rtems_interval t0 = 0;
27  rtems_interval t1 = 0;
28  int i = 0;
29  int n = 0;
30  struct timespec uptime;
31  struct timespec new_uptime;
32
33  puts("\n\n*** TEST NANO SECONDS EXTENSION 1 ***");
34
35  /* Align with clock tick */
36  t0 = rtems_clock_get_ticks_since_boot();
37  while ((t1 = rtems_clock_get_ticks_since_boot()) == t0) {
38    /* Do nothing */
39  }
40
41  t0 = t1;
42  sc = rtems_clock_get_uptime(&uptime);
43  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
44  while ((t1 = rtems_clock_get_ticks_since_boot()) == t0) {
45    ++n;
46    sc = rtems_clock_get_uptime(&new_uptime);
47    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
48    rtems_test_assert(!_Timespec_Less_than(&new_uptime, &uptime));
49    uptime = new_uptime;
50  }
51
52  n = (3 * n) / 2;
53
54  rtems_interrupt_lock_initialize(&lock);
55  rtems_interrupt_lock_acquire(&lock, &lock_context);
56  sc = rtems_clock_get_uptime(&uptime);
57  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
58  for (i = 0; i < n; ++i) {
59    /* Preserve execution time of previous loop */
60    rtems_clock_get_ticks_since_boot();
61
62    sc = rtems_clock_get_uptime(&new_uptime);
63    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
64    rtems_test_assert(!_Timespec_Less_than(&new_uptime, &uptime));
65    uptime = new_uptime;
66  }
67  rtems_interrupt_lock_release(&lock, &lock_context);
68  rtems_interrupt_lock_destroy(&lock);
69
70  puts("*** END OF TEST NANO SECONDS EXTENSION 1 ***");
71
72  rtems_test_exit(0);
73}
74
75#define CONFIGURE_INIT
76
77#define CONFIGURE_MICROSECONDS_PER_TICK 100000
78
79#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
80#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
81
82#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
83
84#define CONFIGURE_MAXIMUM_TASKS 1
85#define CONFIGURE_MAXIMUM_DRIVERS 2
86
87#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
88
89#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.