ptest.c 2.4 KB
Newer Older
yoogx's avatar
yoogx committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119

#include <stdio.h>
#include <po_hi_time.h>
#include <unistd.h>

#include "whetstone.c"

#define loop 167

void task_1 (void)
{
  // Time variable, C = WCET/100
  int32_t C1 = 2 ;
  int i = 0;

  //Temporal Variable
  __po_hi_time_t  tstart;
  __po_hi_time_t  tfin;

  printf("Starting FIRST TASK...\n");
  fflush (stdout);

  //Starting Time
  int test1 = __po_hi_get_time(&tstart);
  if (test1 < 0)
    {
      printf("ERROR TIME 1");
      fflush (stdout);
    }

  //Executute Task with a certain duration

  for (i=0 ; i < C1 ; i++){burnproc(loop);}

  //Ending Time
  int test2 = __po_hi_get_time(&tfin);
  if (test2 < 0)
    { printf("ERROR TIME 2");
      fflush (stdout);}

  //Compute Time Duration
  float duration = 1000.0*((float)(tfin.sec - tstart.sec)+((float)((tfin.nsec-tstart.nsec))/1000000000.0));
  printf ("[%f msec] Completed FIRST TASK.\n",duration);
  fflush (stdout);

}

void task_2 (void)
{
  // Time variable, C = WCET/100
  int32_t C2 = 1;
  int i = 0;

  //Temporal Variable
  __po_hi_time_t  tstart;
  __po_hi_time_t  tfin;

  printf("Starting SECOND TASK...\n");
  fflush (stdout);

  //Starting Time
  int test1 = __po_hi_get_time(&tstart);
  if (test1 < 0)
    { printf("ERROR TIME 1");
      fflush (stdout);}

  //Executute Task with a certain duration

  for (i=0 ; i < C2 ; i++){burnproc(loop);}

  //Ending Time
  int test2 = __po_hi_get_time(&tfin);
  if (test2 < 0)
    { printf("ERROR TIME 2");
     fflush (stdout);}

  //Compute Time Duration
  float duration = 1000.0*((float)(tfin.sec - tstart.sec)+((float)((tfin.nsec-tstart.nsec))/1000000000.0));
  printf ("[%f msec] Completed SECOND TASK.\n",duration);
  fflush (stdout);

}

void task_3 (void)
{

  //Temporal Variable
  __po_hi_time_t  tstart;
  __po_hi_time_t  tfin;

  // Time variable, C = WCET/100
  int32_t C3 = 2 ;
  int i = 0;

  printf("Starting THIRD TASK...\n");
  fflush (stdout);

  //Starting Time
  int test1 = __po_hi_get_time(&tstart);
  if (test1 < 0)
    { printf("ERROR TIME 1");
      fflush (stdout);}

  //Executute Task with a certain duration

  for (i=0 ; i < C3 ; i++){burnproc(loop);}

  //Ending Time
  int test2 = __po_hi_get_time(&tfin);
  if (test2 < 0)
    { printf("ERROR TIME 2");
     fflush (stdout);}

  //Compute Time Duration
  float duration = 1000.0*((float)(tfin.sec - tstart.sec)+((float)((tfin.nsec-tstart.nsec))/1000000000.0));
  printf ("[%f msec] Completed THIRD TASK.\n",duration);
  fflush (stdout);

}