Commit f96d9223 authored by yoogx's avatar yoogx

* Add test for scheduling

        Committed on behalf of R. Defoin
parent 258d72f9
......@@ -220,6 +220,7 @@ AC_OUTPUT([
examples/aadlv2/packet-store/Makefile
examples/aadlv2/file-store/Makefile
examples/aadlv2/latency/Makefile
examples/aadlv2/priority_test/Makefile
examples/aadlv2/rma/Makefile
examples/aadlv2/rpc/Makefile
examples/aadlv2/some-types/Makefile
......
SUBDIRS = d3.1.3-1 ping rma sunseeker producer-consumer some-types \
some-types-stdint flight-mgmt import monitor lua cpp \
packet-store file-store latency code_coverage torture_gqueue \
rpc
rpc priority_test
SAMPLE_DIR = ${shell $(CYGPATH_U) '$(OCARINA_PREFIX)/examples/ocarina/polyorb-hi-c/aadlv2'}
......
C_FILES = $(srcdir)/ptest.c $(srcdir)/whetstone.c
AADL_FILES = $(srcdir)/ptest.aadl
SCENARIO_FILES = $(srcdir)/scenario.aadl \
$(srcdir)/scenario_rtems.aadl
include $(srcdir)/../../Makefile.common
EXTRA_DIST = $(AADL_FILES) $(SCENARIO_FILES) $(C_FILES)
CLEANDIRS = ptest_impl ptest_rtems_impl
-- This AADL model illustrates how to conduct schedulability analysis
-- using Cheddar, and then code generation of periodic tasks.
--
-- Three periodic tasks run in parrallel, without interaction, in order
-- to analyse Periodic Priority behavior.
--
-- Study Case Cottet, F., & Grolleau, E. (2005). Systèmes temps réel de contrôle-commande:
-- conception et implémentation. Dunod. Page 501. Using RTEMS.
package PTEST
public
with Deployment;
-----------------
-- Subprograms --
-----------------
subprogram Ptest_Spg_1
properties
source_language => (C);
source_name => "task_1";
source_text => ("ptest.c");
end Ptest_Spg_1;
subprogram Ptest_Spg_2
properties
source_language => (C);
source_name => "task_2";
source_text => ("ptest.c");
end Ptest_Spg_2;
subprogram Ptest_Spg_3
properties
source_language => (C);
source_name => "task_3";
source_text => ("ptest.c");
end Ptest_Spg_3;
-------------
-- Threads --
-------------
thread Task
end Task;
thread implementation Task.impl_1
calls
Mycalls: {
P_Spg : subprogram Ptest_Spg_1;
};
properties
Dispatch_Protocol => periodic;
Period => 600ms;
Priority => 30;
end Task.impl_1;
thread implementation Task.impl_2
calls
Mycalls: {
P_Spg : subprogram Ptest_Spg_2;
};
properties
Dispatch_Protocol => periodic;
Period => 800ms;
Priority => 20;
Dispatch_offset => 200ms;
end Task.impl_2;
thread implementation Task.impl_3
calls
Mycalls: {
P_Spg : subprogram Ptest_Spg_3;
};
properties
Dispatch_Protocol => periodic;
Period => 1200ms;
Priority => 10;
end Task.impl_3;
---------------
-- Processor --
---------------
processor cpurm
properties
Deployment::Execution_Platform => native;
end cpurm;
processor implementation cpurm.impl
properties
Scheduling_Protocol => (Posix_1003_Highest_Priority_First_Protocol);
Priority_Range => 0 .. 255;
end cpurm.impl;
---------------
-- Processes --
---------------
process node_a
end node_a;
process implementation node_a.impl
subcomponents
Task1 : thread Task.impl_1;
Task2 : thread Task.impl_2;
Task3 : thread Task.impl_3;
end node_a.impl;
------------
-- System --
------------
system ptest
end ptest;
system implementation ptest.impl
subcomponents
ptest : process node_a.impl;
cpu_rm : processor cpurm.impl;
properties
Actual_Processor_Binding => (reference (cpu_rm)) applies to ptest;
end ptest.impl;
system implementation ptest.rtems_impl extends ptest.impl
properties
Deployment::Execution_platform => LEON_RTEMS_POSIX applies to cpu_rm;
end ptest.rtems_impl;
end PTEST;
#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);
}
package scenario
public
with Ocarina_Config;
system ptest
properties
Ocarina_Config::Timeout_Property => 10500ms;
Ocarina_Config::Referencial_Files =>
("node_a", "node_a.ref");
Ocarina_Config::AADL_Files =>
("ptest.aadl");
Ocarina_Config::Root_System_Name => "ptest.impl";
Ocarina_Config::Generator => polyorb_hi_c;
Ocarina_Config::Needed_Property_Sets =>
(Ocarina_Config::Data_Model,
Ocarina_Config::Deployment,
Ocarina_Config::Cheddar_Properties);
Ocarina_Config::AADL_Version => AADLv2;
end ptest;
system implementation ptest.Impl
end ptest.Impl;
end scenario;
package scenario
public
with Ocarina_Config;
system ptest_rtems
properties
Ocarina_Config::Timeout_Property => 10500ms;
Ocarina_Config::Referencial_Files =>
("node_a", "node_a.ref");
Ocarina_Config::AADL_Files =>
("ptest.aadl");
Ocarina_Config::Root_System_Name => "ptest.rtems_impl";
Ocarina_Config::Generator => polyorb_hi_c;
Ocarina_Config::Needed_Property_Sets =>
(Ocarina_Config::Data_Model,
Ocarina_Config::Deployment,
Ocarina_Config::Cheddar_Properties);
Ocarina_Config::AADL_Version => AADLv2;
end ptest_rtems;
system implementation ptest_rtems.Impl
end ptest_rtems.Impl;
end scenario;
/*
* whetstone.c : adaptation of the Whetstone benchmark
* from Curnow, H.J. and Wichman, B.A. "A Synthetic Benchmark"
* Computer Journal, Volume 19, Issue 1, February 1976., p. 43-49.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <po_hi_time.h>
#include <unistd.h>
#include <math.h>
/*Values from the original Algol Whetstone program
and the Pascal SmallWhetstone program*/
double T = 0.499975;
double T1 = 0.50025;
double T2 = 2.0;
double LOOP = 1.0;
int N8 = 10;
int N9 = 7;
double Value = 0.941377; // Value calculated in main loop
double Tolerance = 0.00001; // Determined by interval arithmetic
double KIPS;
//Interger constant
int I;
int IJ = 1;
int IK = 2;
int IL = 3;
//double
double Y = 1.0;
double Z;
double sum = 0; // Accumulates value of Z
/* Functions initialization */
void CA (double * array, int I);
void P0 (void);
void P3 (double X, double Y, double * Z);
void burnproc(int loop);
void burnproc(int loop)
{
//Temporal Variable
__po_hi_time_t tstart;
__po_hi_time_t tfin;
double * E1;
E1 = (double *)malloc(N9 * sizeof (double));
// Start benchmark timing at this point.
int test1 = __po_hi_get_time(&tstart);
if (test1 < 0)
{ printf("ERROR TIME 1");
fflush (stdout);}
//Main Loop
for (int j=0; j<loop ;j++){
//Initializing the array.
for (int r = 0 ; r < N9 ; r++)
{
E1[r] = 0.0;
}
//Module 6 : Interger Arithmetic
IJ = (IK - IJ) * (IL - IK);
IK = IL - (IK - IJ);
IL = (IL - IK) * (IK + IL);
E1[(IL - 1)] = (double)(IJ + IK + IL);
E1[(IK - 1)] = sin((double)IL);
//Module 8: Procedure Calls
Z = E1[4];
for (int i = 0; i < N8;){
i++;
P3(Y * (double)i , Y + Z, &Z);
}
//Second version of Module 6:
IJ = IL - (IL - 3) * IK;
IL = (IL - IK) * (IK - IJ);
IK = (IL - IK) * IK;
E1[(IL - 1)] = (double)(IJ + IK + IL);
E1[(IK + 1)] = fabs( cos(Z) );
//Module 9 Array References
I = 1;
while( I <= N9){
//P0
E1[IJ] = E1[IK];
E1[IK] = E1[IL];
E1[IL] = E1[IJ];
I++;
}
//Module 11: Standard Mathematical Functions
Z = sqrt( exp( log(E1[(N9 - 1)]) /T1) );
sum = sum + Z;
//Check the current value of the loop computation
/* if (fabs(Z - Value) > Tolerance)
{
sum = 2.0 * sum; // Force error at end
IJ = IJ +1; // Prévents optimization
}*/
}
//Self-validation check
/*
if( fabs(sum/((double)loop) - Value) > (Tolerance*(double)loop ) )
{
printf("Workload Failure");
fflush (stdout);
}
*/
/* Stop benchmark timing at this point. */
int test2 = __po_hi_get_time(&tfin);
if (test2 < 0)
{ printf("ERROR TIME 2");
fflush (stdout);}
/*
----------------------------------------------------------------
Performance in Whetstone KIP's per second is given by
(100*LOOP*loop)/TIME
where TIME is in seconds.
--------------------------------------------------------------------
*/
#ifdef WHETSTONE_DEBUG
float duration = (float)(tfin.sec - tstart.sec)+((float)((tfin.nsec-tstart.nsec))/1000000000.0);
printf("Time duration :%f sec.\n------------------------\n",duration);
fflush (stdout);
if (duration <= 0.0) {
printf("Insufficient duration- Increase the LOOP count\n");
}
else
{
printf("Loops: %f, Iterations: %d.\n",
LOOP, loop, duration);
fflush (stdout);
printf("------------------------\n");
fflush (stdout);
KIPS = (100.0*LOOP*(float)loop)/(float)(duration);
if (KIPS >= 1000.0)
{printf("C Converted Double Precision Whetstones: %.1f MIPS\n", KIPS/1000.0);
fflush (stdout);}
else
{printf("C Converted Double Precision Whetstones: %.1f KIPS\n", KIPS);
fflush (stdout);}
}
printf("---------------------------\n");
fflush (stdout);
printf("---------------------------\n");
fflush (stdout);
#endif /* WHETSTONE_DEBUG */
free (E1);
}
void P3 (double X, double Y, double * Z){
double Xtemp, Ytemp;
Xtemp = (*Z + X) * T;
Ytemp = (Xtemp + Y) * T;
*Z = (Xtemp + Ytemp)/T2;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment