source: rtems/testsuites/psxtests/psx07/task.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.4 KB
Line 
1/*  Task_1
2 *
3 *  This routine serves as a test task.  It verifies the basic task
4 *  switching capabilities of the executive.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-1999.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include "system.h"
24#include <time.h>
25#include <sched.h>
26
27void *Task_1(
28  void *argument
29)
30{
31  puts( "Task_1 - exitting" );
32  pthread_exit( NULL );
33
34  return NULL; /* just so the compiler thinks we returned something */
35}
36
37void *Task_2(
38  void *argument
39)
40{
41  int i = 0;
42  time_t now, start;
43
44  /*
45   * sleep long enough to let the init thread join with us.
46   */
47  usleep(10000);
48
49  /*
50   *  Change our priority so we are running at a logically higher
51   *  priority than our "ss_high_priority".  This should result in
52   *  our replenishment period not touching our priority.
53   */
54
55  /*
56   *  Consume time so the cpu budget callout will run.
57   *
58   *  DO NOT BLOCK!!!
59   */
60  start = time(&start);
61  while( i <= 10 ) {
62    do {
63      now = time(&now);
64    } while (start == now);
65    start = time(&start);
66
67    printf( "Time elapsed Task_2: %2d (seconds)\n", i++ );
68  }
69
70  puts( "Task_2 - exitting" );
71  pthread_exit( NULL );
72  return NULL;
73}
Note: See TracBrowser for help on using the repository browser.