+#include "system.h"
+
+rtems_task Task_1(
+ rtems_task_argument argument
+)
+{
+ rtems_name name;
+ rtems_id period;
+ rtems_status_code status;
+ char output1[50];
+ char output2[50];
+ unsigned32 start, stop, period_length, max_i, max_j;
+ unsigned32 i,j,k,l;
+
+ name = rtems_build_name( 'P', 'E', 'R', 'A' );
+ status = rtems_rate_monotonic_create( name, &period );
+ if ( status != RTEMS_SUCCESSFUL ) {
+ printf( "rtems_monotonic_create failed with status of %d.\n", status);
+ exit( 1 );
+ }
+
+ period_length = 7;
+ max_i = 10000; max_j = 4000;
+ while ( 1 ) {
+ if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT)
+ puts("P1 - Deadline miss");
+
+ rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start);
+ sprintf(output1,"P1-S ticks:%d",start);
+ puts(output1);
+
+ if ( start >= 30 ) break;
+
+ /* active computing */
+ for ( i = 1 ; i < max_i; i++)
+ {
+ j = i/12 ; j++;
+ for ( j = 1; j < max_j; j++)
+ {
+ k = j/ 3;
+ k++;
+ }
+ }
+
+ rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop);
+ sprintf(output2,"P1-F ticks:%d",stop);
+ puts(output2);
+ }
+
+ /* missed period so delete period and SELF */
+ status = rtems_rate_monotonic_delete( period );
+ if ( status != RTEMS_SUCCESSFUL ) {
+ printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
+ rtems_test_exit( 0 );
+ }
+
+ puts( "*** END OF TEST - edf***" );
+ rtems_test_exit( 0 );
+}
+
+rtems_task Task_2(
+ rtems_task_argument argument
+)
+{
+ rtems_name name;
+ rtems_id period;
+ rtems_status_code status;
+ char output1[50];
+ char output2[50];
+ unsigned32 start, stop, period_length, max_i, max_j;
+ unsigned32 i,j,k,l;
+
+ name = rtems_build_name( 'P', 'E', 'R', 'B' );
+ status = rtems_rate_monotonic_create( name, &period );
+ if ( status != RTEMS_SUCCESSFUL ) {
+ printf( "rtems_monotonic_create failed with status of %d.\n", status );
+ exit( 1 );
+ }
+
+ period_length = 10;
+ max_i = 10000; max_j = 6000;
+ while ( 1 ) {
+ if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT)
+ puts("P2 - Deadline miss");
+
+ rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start);
+ sprintf(output1,"P2-S ticks:%d",start);
+ puts(output1);
+
+ if ( _Watchdog_Ticks_since_boot >= 30 ) {
+ break;
+ }
+
+ /* active computing */
+
+ for ( i = 1 ; i < max_i; i++)
+ {
+ j = i/12 ; j++;
+ for ( j = 1; j < max_j; j++)
+ {
+ k = j/ 3;
+ k++;
+ }
+ }
+
+ rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop);
+ sprintf(output2,"P2-F ticks:%d",stop);
+ puts(output2);
+ }
+
+ /* missed period so delete period and SELF */
+ status = rtems_rate_monotonic_delete( period );
+ if ( status != RTEMS_SUCCESSFUL ) {
+ printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
+ rtems_test_exit( 0 );
+ }
+
+ puts( "*** END OF TEST - edf***" );
+ rtems_test_exit( 0 );
+}