Index: testsuites/sptests/spedfsched04/Makefile.am
===================================================================
--- testsuites/sptests/spedfsched04/Makefile.am	(revision c5430e0618fbe1517417a0b353c12924a8934554)
+++ testsuites/sptests/spedfsched04/Makefile.am	(revision 166a9f67cde9085a74d6d5d962160b3c92b3e3d7)
@@ -1,5 +1,5 @@
 
 rtems_tests_PROGRAMS = spedfsched04
-spedfsched04_SOURCES = init.c
+spedfsched04_SOURCES = init.c ../../support/src/spin.c
 	
 dist_rtems_tests_DATA = spedfsched04.scn
Index: testsuites/sptests/spedfsched04/init.c
===================================================================
--- testsuites/sptests/spedfsched04/init.c	(revision c5430e0618fbe1517417a0b353c12924a8934554)
+++ testsuites/sptests/spedfsched04/init.c	(revision 166a9f67cde9085a74d6d5d962160b3c92b3e3d7)
@@ -1,23 +1,24 @@
 /**
- * @brief A heuristic example to demonstrate how the postponed jobs are handled.
+ * @brief A heuristic example to demonstrate how the postponed jobs are handled in EDF.
  *
  * Given two tasks with implicit deadline under EDF policy.
- * Task 1 has (4, 5) and task 2 has (4, 6), where (execution time, period/deadline).
- * For the simplicity, we only execute the first task twice.
+ * Task 1 has (400, 500) and task 2 has (450, 550), where (required ticks, period/deadline).
+ * For the simplicity, we only execute the first task three times.
  * In the original implementation in v4.11, no matter how many periods are
  * expired, only one job will be released with a shifted deadline assignment.
  *
- * In this example, the first job of task 2 will be blocked by the second job
- * of task 1, so that there at least one following job is postponed.
- * Due to overhead/delay, the second following job will be postponed as well.
+ * In this example, task 2 will be blocked by the second and third jobs
+ * of task 1, so that there are two jobs are postponed.
+ * Due to the domino effects, the following jobs of task 2 will be postponed until Job 9.
  *
  * If the overrun handling is correct, the period of task 2 changes back to
- * normal status at time 22.
- * Otherwise, the release time of job 3 is no longer periodic.
+ * normal status at Job 9.
+ * Otherwise, the release time of job 3 is no longer periodic
+ * and there is no more postponed jobs.
  *
  */
 
 /*
- *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
+ *  COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
  *
  *  The license and distribution terms for this file may be
@@ -31,15 +32,11 @@
 
 #include <rtems/cpuuse.h>
-#include <rtems/counter.h>
-
-#include <stdio.h>
-#include <inttypes.h>
-
-#include "tmacros.h"
+#include <tmacros.h>
+#include "test_support.h"
 
 const char rtems_test_name[] = "SPEDFSCHED 4";
 
-static const uint32_t Periods[] = { 5000, 6000 };
-static const uint32_t Iterations[] = { 4000, 4000 };
+static const uint32_t Periods[] = { 500, 550 };
+static const uint32_t Iterations[] = { 400, 450 };
 static const rtems_name Task_name[] = {
   rtems_build_name( 'T', 'A', '1', ' ' ),
@@ -47,5 +44,5 @@
 };
 static const rtems_task_priority Prio[3] = { 2, 5 };
-static const uint32_t testnumber = 11; /* stop condition */
+static const uint32_t testnumber = 9; /* stop condition */
 
 static uint32_t tsk_counter[] = { 0, 0 };
@@ -59,12 +56,11 @@
 )
 {
-  rtems_status_code status;
-  rtems_id    RM_period;
-  rtems_id    selfid=rtems_task_self();
-  uint32_t    start, end, flag=0, index;
-  rtems_counter_ticks t0;
+  rtems_status_code                         status;
+  rtems_id                                  RM_period;
+  rtems_id                                  selfid=rtems_task_self();
+  rtems_rate_monotonic_period_status        period_status;
+  uint32_t                                  flag=0;
 
-  t0 = rtems_counter_nanoseconds_to_ticks( 1000000 ); //1ms ticks counter
-  /*create period*/
+  /* create period */
   status = rtems_rate_monotonic_create( Task_name[ argument ], &RM_period );
   directive_failed( status, "rtems_rate_monotonic_create" );
@@ -72,20 +68,27 @@
   while ( FOREVER ) {
     status = rtems_rate_monotonic_period( RM_period, Periods[ argument ] );
-    if( flag == 0 && status == RTEMS_TIMEOUT ){
-      flag = 1;
-      printf( "RTEMS_TIMEOUT\n" );
-    } else if ( flag == 1 && status == RTEMS_SUCCESSFUL ) {
-      flag = 0;
-      printf( "RTEMS_SUCCESSFUL\n" );
-    }
 
-    start = rtems_clock_get_ticks_since_boot();
-    printf( "Job %" PRIu32 " Task %" PRIuPTR " starts at tick %" PRIu32 ".\n", tsk_counter[ argument ]+1, argument, start );
-    for( index = 0; index < Iterations[ argument ]; index++ ){
-      rtems_counter_delay_ticks( t0 );
-    }
-    end = rtems_clock_get_ticks_since_boot();
-    printf( "					Job %" PRIu32" Task %" PRIuPTR " ends at tick %" PRIu32".\n", tsk_counter[ argument ]+1, argument, end );
+    /* Do some work */
+    rtems_test_spin_for_ticks( Iterations[ argument ] );
+
     if( argument == 1 ){
+      if( status == RTEMS_TIMEOUT ){
+        if( flag == 0 ){
+          puts( "First time RTEMS_TIMEOUT" );
+          puts( "Task 2 should have 2 postponed job due to preemption." );
+          rtems_test_assert( period_status.postponed_jobs_count == 2 );
+          flag = 1;
+        }
+      } else if ( flag == 1 && status == RTEMS_SUCCESSFUL ) {
+        puts( "RTEMS_SUCCESSFUL" );
+        puts( "Overrun handling is finished, now Task 2 becomes normal." );
+        rtems_test_assert( period_status.postponed_jobs_count == 0 );
+        flag = 0;
+      }
+
+      /* Check the status */
+      status = rtems_rate_monotonic_get_status( RM_period, &period_status );
+      directive_failed( status, "rate_monotonic_get_status" );
+
       if( tsk_counter[ argument ] == testnumber ){
         TEST_END();
@@ -98,5 +101,6 @@
     tsk_counter[ argument ]+=1;
     if ( argument == 0 ){
-      if( tsk_counter[ argument ] == 2 ){
+      if( tsk_counter[ argument ] == 3 ){
+        puts("Task 1 has released 3 jobs and finished.");
         status = rtems_rate_monotonic_delete( RM_period );
         directive_failed( status, "rtems_rate_monotonic_delete" );
@@ -117,5 +121,4 @@
   TEST_BEGIN();
 
-  printf( "\nTicks per second in your system: %" PRIu32 "\n", rtems_clock_get_ticks_per_second() );
 
   /* Create two tasks */
@@ -127,5 +130,4 @@
     directive_failed( status, "rtems_task_create loop" );
   }
-
 
   /* After creating the periods for tasks, start to run them sequencially. */
Index: testsuites/sptests/spedfsched04/spedfsched04.scn
===================================================================
--- testsuites/sptests/spedfsched04/spedfsched04.scn	(revision c5430e0618fbe1517417a0b353c12924a8934554)
+++ testsuites/sptests/spedfsched04/spedfsched04.scn	(revision 166a9f67cde9085a74d6d5d962160b3c92b3e3d7)
@@ -1,24 +1,7 @@
-
-
 *** BEGIN OF TEST SPEDFSCHED 4 ***
-
-Ticks per second in your system: 1000
-Job 1 Task 1 starts at tick 14.
-                                        Job 1 Task 1 ends at tick 4023.
-Job 1 Task 2 starts at tick 4025.
-Job 2 Task 1 starts at tick 5013.
-                                        Job 2 Task 1 ends at tick 9023.
-                                        Job 1 Task 2 ends at tick 12045.
-System TIMEOUT
-Job 2 Task 2 starts at tick 12045.
-                                        Job 2 Task 2 ends at tick 16054.
-Job 3 Task 2 starts at tick 16054.
-                                        Job 3 Task 2 ends at tick 20061.
-System SUCCESSFUL
-Job 4 Task 2 starts at tick 22025.
-                                        Job 4 Task 2 ends at tick 26033.
-Job 5 Task 2 starts at tick 28025.
-                                        Job 5 Task 2 ends at tick 32033.
-Job 6 Task 2 starts at tick 34025.
-                                        Job 6 Task 2 ends at tick 38033.
+Task 1 has released 3 jobs and finished.
+First time RTEMS_TIMEOUT
+Task 2 should have 2 postponed job due to preemption.
+RTEMS_SUCCESSFUL
+Overrun handling is finished, now Task 2 becomes normal.
 *** END OF TEST SPEDFSCHED 4 ***
Index: testsuites/sptests/sprmsched01/Makefile.am
===================================================================
--- testsuites/sptests/sprmsched01/Makefile.am	(revision c5430e0618fbe1517417a0b353c12924a8934554)
+++ testsuites/sptests/sprmsched01/Makefile.am	(revision 166a9f67cde9085a74d6d5d962160b3c92b3e3d7)
@@ -1,6 +1,6 @@
 
 rtems_tests_PROGRAMS = sprmsched01
-sprmsched01_SOURCES = init.c
-	
+sprmsched01_SOURCES = init.c ../../support/src/spin.c
+
 dist_rtems_tests_DATA = sprmsched01.scn
 dist_rtems_tests_DATA += sprmsched01.doc
Index: testsuites/sptests/sprmsched01/init.c
===================================================================
--- testsuites/sptests/sprmsched01/init.c	(revision c5430e0618fbe1517417a0b353c12924a8934554)
+++ testsuites/sptests/sprmsched01/init.c	(revision 166a9f67cde9085a74d6d5d962160b3c92b3e3d7)
@@ -1,4 +1,4 @@
 /**
- * @brief A heuristic example to demonstrate how the postponed jobs are handled.
+ * @brief A heuristic example to demonstrate how the postponed jobs are handled in RMS.
  *
  * Given two tasks with implicit deadline under fixed-priority scheudling.
@@ -21,5 +21,5 @@
 
 /*
- *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
+ *  COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
  *
  *  The license and distribution terms for this file may be
@@ -33,15 +33,11 @@
 
 #include <rtems/cpuuse.h>
-#include <rtems/counter.h>
-
-#include <stdio.h>
-#include <inttypes.h>
-
-#include "tmacros.h"
+#include <tmacros.h>
+#include "test_support.h"
 
 const char rtems_test_name[] = "SPRMSCHED 1";
 
-static const uint32_t Periods[] = { 10000, 2000 };
-static const uint32_t Iterations[] = { 6000, 1000 };
+static const uint32_t Periods[] = { 1000, 200 };
+static const uint32_t Iterations[] = { 600, 100 };
 static const rtems_name Task_name[] = {
   rtems_build_name( 'T', 'A', '1', ' ' ),
@@ -49,5 +45,5 @@
 };
 static const rtems_task_priority Prio[3] = { 2, 5 };
-static const uint32_t testnumber = 11; /* stop condition */
+static const uint32_t testnumber = 9; /* stop condition */
 
 static uint32_t tsk_counter[] = { 0, 0 };
@@ -61,11 +57,10 @@
 )
 {
-  rtems_status_code status;
-  rtems_id    RM_period;
-  rtems_id    selfid=rtems_task_self();
-  uint32_t    start, end, flag=0, index;
-  rtems_counter_ticks t0;
+  rtems_status_code                          status;
+  rtems_id                                   RM_period;
+  rtems_id                                   selfid=rtems_task_self();
+  rtems_rate_monotonic_period_status         period_status;
+  uint32_t                                   flag=0;
 
-  t0 = rtems_counter_nanoseconds_to_ticks( 1000000 ); //1ms ticks counter
   /*create period*/
   status = rtems_rate_monotonic_create( Task_name[ argument ], &RM_period );
@@ -74,24 +69,27 @@
   while ( FOREVER ) {
     status = rtems_rate_monotonic_period( RM_period, Periods[ argument ] );
-    //directive_failed( status, "rtems_rate_monotonic_period" ); let TIMEOUT pass
-    if( argument == 1 && flag == 0 && status == RTEMS_TIMEOUT ){
-      flag = 1;
-      printf( "RTEMS_TIMEOUT\n" );
-    } else if ( flag == 1 && status == RTEMS_SUCCESSFUL ) {
-      flag = 0;
-      printf( "RTEMS_SUCCESSFUL\n" );
-    }
 
-    start = rtems_clock_get_ticks_since_boot();
-    if ( argument == 1 )
-      printf( "Job %" PRIu32 " Task %" PRIuPTR " starts at tick %" PRIu32 ".\n", tsk_counter[ argument ]+1, argument, start );
-    else
-      printf( "Task %" PRIuPTR " starts at tick %" PRIu32 ".\n", argument, start );
-    for( index = 0; index < Iterations[ argument ]; index++ ){
-      rtems_counter_delay_ticks( t0 );
-    }
-    end = rtems_clock_get_ticks_since_boot();
-    printf( "					Job %" PRIu32" Task %" PRIuPTR " ends at tick %" PRIu32".\n", tsk_counter[ argument ]+1, argument, end );
+    /* Do some work */
+    rtems_test_spin_for_ticks( Iterations[ argument ] );
+
     if( argument == 1 ){
+      if( status == RTEMS_TIMEOUT ){
+        if( flag == 0 ){
+          puts( "First time RTEMS_TIMEOUT" );
+          puts( "Task 2 should have 3 postponed jobs due to preemption." );
+          rtems_test_assert( period_status.postponed_jobs_count == 3 );
+          flag = 1;
+        }
+      } else if ( flag == 1 && status == RTEMS_SUCCESSFUL ) {
+        puts( "RTEMS_SUCCESSFUL" );
+        puts( "Overrun handling is finished, now Task 2 becomes normal." );
+        rtems_test_assert( period_status.postponed_jobs_count == 0 );
+        flag = 0;
+      }
+
+      /* Check the status */
+      status = rtems_rate_monotonic_get_status( RM_period, &period_status );
+      directive_failed( status, "rate_monotonic_get_status" );
+
       if( tsk_counter[ argument ] == testnumber ){
         TEST_END();
@@ -105,4 +103,5 @@
     if ( argument == 0 ){
       if( tsk_counter[ argument ] == 2 ){
+        puts( "Task 1 has released two jobs" );
         status = rtems_rate_monotonic_delete( RM_period );
         directive_failed( status, "rtems_rate_monotonic_delete" );
@@ -122,6 +121,4 @@
 
   TEST_BEGIN();
-
-  printf( "\nTicks per second in your system: %" PRIu32 "\n", rtems_clock_get_ticks_per_second() );
 
   /* Create two tasks */
Index: testsuites/sptests/sprmsched01/sprmsched01.scn
===================================================================
--- testsuites/sptests/sprmsched01/sprmsched01.scn	(revision c5430e0618fbe1517417a0b353c12924a8934554)
+++ testsuites/sptests/sprmsched01/sprmsched01.scn	(revision 166a9f67cde9085a74d6d5d962160b3c92b3e3d7)
@@ -1,50 +1,7 @@
-
-
-*** BEGIN OF TEST Rate Monotonic 01 - Overrun Test ***
-
-Ticks per second in your system: 1000
-Job 1 Task 1 starts at tick 13.
-                                        Job 1 Task 1 ends at tick 6021.
-Job 1 Task 2 starts at tick 6022.
-                                        Job 1 Task 2 ends at tick 7024.
-Job 2 Task 2 starts at tick 8022.
-                                        Job 2 Task 2 ends at tick 9023.
-Job 2 Task 1 starts at tick 10013.
-                                        Job 2 Task 1 ends at tick 16021.
-Job 3 Task 2 starts at tick 16023.
-                                        Job 3 Task 2 ends at tick 17024.
-RTEMS_TIMEOUT
-Job 4 Task 2 starts at tick 17025.
-                                        Job 4 Task 2 ends at tick 18026.
-Job 5 Task 2 starts at tick 18026.
-                                        Job 5 Task 2 ends at tick 19027.
-Job 6 Task 2 starts at tick 19028.
-                                        Job 6 Task 2 ends at tick 20029.
-Job 7 Task 2 starts at tick 20029.
-                                        Job 7 Task 2 ends at tick 21031.
-Job 8 Task 2 starts at tick 21031.
-                                        Job 8 Task 2 ends at tick 22033.
-Job 9 Task 2 starts at tick 22033.
-                                        Job 9 Task 2 ends at tick 23035.
+*** BEGIN OF TEST SPRMSCHED 1 ***
+Task 1 has released two jobs
+First time RTEMS_TIMEOUT
+Task 2 should have 3 postponed jobs due to preemption.
 RTEMS_SUCCESSFUL
-Job 10 Task 2 starts at tick 24022.
-                                        Job 10 Task 2 ends at tick 25023.
-Job 11 Task 2 starts at tick 26022.
-                                        Job 11 Task 2 ends at tick 27024.
-Job 12 Task 2 starts at tick 28022.
-                                        Job 12 Task 2 ends at tick 29024.
-Job 13 Task 2 starts at tick 30022.
-                                        Job 13 Task 2 ends at tick 31023.
-Job 14 Task 2 starts at tick 32022.
-                                        Job 14 Task 2 ends at tick 33023.
-Job 15 Task 2 starts at tick 34022.
-                                        Job 15 Task 2 ends at tick 35023.
-Job 16 Task 2 starts at tick 36022.
-                                        Job 16 Task 2 ends at tick 37023.
-Period information by period
---- CPU times are in seconds ---
---- Wall times are in seconds ---
-   ID     OWNER COUNT MISSED          CPU TIME                  WALL TIME
-                                    MIN/MAX/AVG                MIN/MAX/AVG
-0x42010002 TA2     15      6 1.001686/7.012146/2.404131 1.001698/13.013378/5.204723
-*** END OF TEST Rate Monotonic 01 ***
+Overrun handling is finished, now Task 2 becomes normal.
+*** END OF TEST SPRMSCHED 1 ***
