summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spcbssched02
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-09-15 15:56:01 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-09-15 15:56:01 +0000
commitbd1b8de26546f0e86d76bec2e407a08245560f83 (patch)
treeabf16b06b8fa2a6eb50273f5c62140a57ce787e0 /testsuites/sptests/spcbssched02
parent2011-09-15 Petr Benes <benesp16@fel.cvut.cz> (diff)
downloadrtems-bd1b8de26546f0e86d76bec2e407a08245560f83.tar.bz2
2011-09-15 Petr Benes <benesp16@fel.cvut.cz>
PR 1907/testing * Makefile.am, configure.ac: Add tests for the CBS (Constant Bandwidth Server) scheduler. * spcbssched01/.cvsignore, spcbssched01/Makefile.am, spcbssched01/init.c, spcbssched01/spcbssched01.doc, spcbssched01/spcbssched01.scn, spcbssched01/system.h, spcbssched01/task1.c, spcbssched02/.cvsignore, spcbssched02/Makefile.am, spcbssched02/init.c, spcbssched02/spcbssched02.doc, spcbssched02/spcbssched02.scn, spcbssched02/system.h, spcbssched02/task_periodic.c, spcbssched03/.cvsignore, spcbssched03/Makefile.am, spcbssched03/cbsparams.h, spcbssched03/init.c, spcbssched03/spcbssched03.doc, spcbssched03/spcbssched03.scn, spcbssched03/system.h, spcbssched03/tasks_aperiodic.c, spcbssched03/tasks_periodic.c: New files.
Diffstat (limited to 'testsuites/sptests/spcbssched02')
-rw-r--r--testsuites/sptests/spcbssched02/.cvsignore2
-rw-r--r--testsuites/sptests/spcbssched02/Makefile.am28
-rw-r--r--testsuites/sptests/spcbssched02/init.c227
-rw-r--r--testsuites/sptests/spcbssched02/spcbssched02.doc22
-rw-r--r--testsuites/sptests/spcbssched02/spcbssched02.scn30
-rw-r--r--testsuites/sptests/spcbssched02/system.h62
-rw-r--r--testsuites/sptests/spcbssched02/task_periodic.c138
7 files changed, 509 insertions, 0 deletions
diff --git a/testsuites/sptests/spcbssched02/.cvsignore b/testsuites/sptests/spcbssched02/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/sptests/spcbssched02/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/sptests/spcbssched02/Makefile.am b/testsuites/sptests/spcbssched02/Makefile.am
new file mode 100644
index 0000000000..664978c91c
--- /dev/null
+++ b/testsuites/sptests/spcbssched02/Makefile.am
@@ -0,0 +1,28 @@
+##
+## $Id$
+##
+
+MANAGERS = io rate_monotonic semaphore clock
+
+rtems_tests_PROGRAMS = spcbssched02
+spcbssched02_SOURCES = init.c task_periodic.c system.h
+
+dist_rtems_tests_DATA = spcbssched02.scn
+dist_rtems_tests_DATA += spcbssched02.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+spcbssched02_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spcbssched02_OBJECTS) $(spcbssched02_LDADD)
+LINK_LIBS = $(spcbssched02_LDLIBS)
+
+spcbssched02$(EXEEXT): $(spcbssched02_OBJECTS) $(spcbssched02_DEPENDENCIES)
+ @rm -f spcbssched02$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spcbssched02/init.c b/testsuites/sptests/spcbssched02/init.c
new file mode 100644
index 0000000000..7cb305cd74
--- /dev/null
+++ b/testsuites/sptests/spcbssched02/init.c
@@ -0,0 +1,227 @@
+/* Init
+ *
+ * This routine is the initialization task for this test program.
+ * It is a user initialization task and has the responsibility for creating
+ * and starting the tasks that make up the test. If the time of day
+ * clock is required for the test, it should also be set to a known
+ * value by this function.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ rtems_cbs_server_id server_id, server_id2;
+ time_t approved_budget, exec_time, abs_time, remaining_budget;
+ rtems_cbs_parameters params, params1, params2, params3, params4;
+
+ Priority = 30;
+ Period = 30;
+ Execution = 10;
+ Phase = 0;
+
+ params.deadline = 1;
+ params.budget = 1;
+
+ params1 = params2 = params3 = params4 = params;
+ params1.budget = -1;
+ params2.budget = SCHEDULER_EDF_PRIO_MSB + 1;
+ params3.deadline = -1;
+ params4.deadline = SCHEDULER_EDF_PRIO_MSB + 1;
+
+ puts( "\n\n*** TEST CBS SCHEDULER 2 ***" );
+
+ Task_name = rtems_build_name( 'P', 'T', '1', ' ' );
+
+ status = rtems_task_create(
+ Task_name,
+ Priority,
+ RTEMS_MINIMUM_STACK_SIZE * 4,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id
+ );
+ directive_failed( status, "rtems_task_create loop" );
+
+ printf( "Init: Initializing the CBS\n" );
+ if ( rtems_cbs_initialize() )
+ printf( "ERROR: CBS INITIALIZATION FAILED\n" );
+
+ /* Error checks for Create server and Destroy server */
+ printf( "Init: Create server and Destroy server\n" );
+ if ( rtems_cbs_destroy_server( -5 ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_destroy_server( 5 ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_destroy_server( 0 ) != SCHEDULER_CBS_ERROR_NOSERVER )
+ printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_create_server( &params1, NULL, &server_id ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_create_server( &params2, NULL, &server_id ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_create_server( &params3, NULL, &server_id ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_create_server( &params4, NULL, &server_id ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_create_server( &params, NULL, &server_id2 ) )
+ printf( "ERROR: CREATE SERVER FAILED\n" );
+ if ( rtems_cbs_create_server( &params, NULL, &server_id ) )
+ printf( "ERROR: CREATE SERVER FAILED\n" );
+ if ( rtems_cbs_create_server( &params, NULL, &server_id ) !=
+ SCHEDULER_CBS_ERROR_FULL )
+ printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
+
+ /* Error checks for Attach thread and Detach thread */
+ printf( "Init: Attach thread\n" );
+ if ( rtems_cbs_attach_thread( -5, RTEMS_SELF ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_attach_thread( 5, RTEMS_SELF ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_attach_thread( server_id, 1234 ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_attach_thread( server_id, RTEMS_SELF ) )
+ printf( "ERROR: ATTACH THREAD FAILED\n" );
+ if ( rtems_cbs_attach_thread( server_id, RTEMS_SELF ) !=
+ SCHEDULER_CBS_ERROR_FULL )
+ printf( "ERROR: ATTACH THREAD AGAIN PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_attach_thread( server_id, Task_id ) !=
+ SCHEDULER_CBS_ERROR_FULL )
+ printf( "ERROR: ATTACH THREAD TO FULL SERVER PASSED UNEXPECTEDLY \n" );
+ if ( rtems_cbs_destroy_server( server_id ) )
+ printf( "ERROR: DESTROY SERVER WITH THREAD ATTACHED FAILED\n" );
+ if ( rtems_cbs_attach_thread( server_id, RTEMS_SELF ) !=
+ SCHEDULER_CBS_ERROR_NOSERVER )
+ printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
+
+ printf( "Init: Detach thread\n" );
+ if ( rtems_cbs_detach_thread( -5, RTEMS_SELF ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_detach_thread( 5, RTEMS_SELF ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_detach_thread( server_id2, 1234 ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY \n" );
+ if ( rtems_cbs_detach_thread( server_id, RTEMS_SELF ) !=
+ SCHEDULER_CBS_ERROR_NOSERVER )
+ printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY4\n" );
+ rtems_cbs_destroy_server( server_id2 );
+
+ /* Error checks for Set parameters and Get parameters */
+ printf( "Init: Set parameters and Get parameters\n" );
+ if ( rtems_cbs_set_parameters( -5, &params ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_set_parameters( 5, &params ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_set_parameters( server_id, &params ) !=
+ SCHEDULER_CBS_ERROR_NOSERVER )
+ printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
+
+ if ( rtems_cbs_get_parameters( -5, &params ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: GET PARAMETERS PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_get_parameters( 5, &params ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: GET PARAMETERS PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_get_parameters( server_id, &params ) !=
+ SCHEDULER_CBS_ERROR_NOSERVER )
+ printf( "ERROR: GET PARAMETERS PASSED UNEXPECTEDLY\n" );
+
+ if ( rtems_cbs_set_parameters( server_id, &params1 ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_set_parameters( server_id, &params2 ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_set_parameters( server_id, &params3 ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_set_parameters( server_id, &params4 ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
+
+ /* Error checks for Get server id */
+ printf( "Init: Get server id\n" );
+ if ( rtems_cbs_get_server_id( RTEMS_SELF, &server_id ) !=
+ SCHEDULER_CBS_ERROR_NOSERVER )
+ printf( "ERROR: GET SERVER ID PASSED UNEXPECTEDLY\n" );
+
+ /* Error checks for Get approved budget */
+ printf( "Init: Get approved budget\n" );
+ if ( rtems_cbs_get_approved_budget( -5, &approved_budget ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_get_approved_budget( 5, &approved_budget ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_get_approved_budget( server_id, &approved_budget ) !=
+ SCHEDULER_CBS_ERROR_NOSERVER )
+ printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
+
+ /* Error checks for Get remaining budget */
+ printf( "Init: Get remaining budget\n" );
+ if ( rtems_cbs_get_remaining_budget( -5, &remaining_budget ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_get_remaining_budget( 5, &remaining_budget ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_get_remaining_budget( server_id, &remaining_budget ) !=
+ SCHEDULER_CBS_ERROR_NOSERVER )
+ printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
+
+ /* Error checks for Get execution time */
+ printf( "Init: Get execution time\n" );
+ if ( rtems_cbs_get_execution_time( -5, &exec_time, &abs_time ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_get_execution_time( 5, &exec_time, &abs_time ) !=
+ SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
+ printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
+ if ( rtems_cbs_get_execution_time( server_id, &exec_time, &abs_time ) !=
+ SCHEDULER_CBS_ERROR_NOSERVER )
+ printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
+
+ /* Restart CBS library */
+ printf( "Init: Cleaning up CBS\n" );
+ if ( rtems_cbs_cleanup() )
+ printf( "ERROR: CBS CLEANUP FAILED\n" );
+ printf( "Init: Initializing the CBS\n" );
+ if ( rtems_cbs_initialize() )
+ printf( "ERROR: CBS INITIALIZATION FAILED\n" );
+
+ /* Start periodic task */
+ printf( "Init: Starting periodic task\n" );
+ status = rtems_task_start( Task_id, Task_Periodic, 1 );
+ directive_failed( status, "rtems_task_start periodic" );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
+}
diff --git a/testsuites/sptests/spcbssched02/spcbssched02.doc b/testsuites/sptests/spcbssched02/spcbssched02.doc
new file mode 100644
index 0000000000..6a2934c282
--- /dev/null
+++ b/testsuites/sptests/spcbssched02/spcbssched02.doc
@@ -0,0 +1,22 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-1999.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spcbssched02
+
+directives:
+
+
+concepts:
+
+ a. Verifies CBS library functionality.
diff --git a/testsuites/sptests/spcbssched02/spcbssched02.scn b/testsuites/sptests/spcbssched02/spcbssched02.scn
new file mode 100644
index 0000000000..0a38bd8dbb
--- /dev/null
+++ b/testsuites/sptests/spcbssched02/spcbssched02.scn
@@ -0,0 +1,30 @@
+*** TEST CBS SCHEDULER 2 ***
+Init: Initializing the CBS
+Init: Create server and Destroy server
+Init: Attach thread
+Init: Detach thread
+Init: Set parameters and Get parameters
+Init: Get server id
+Init: Get approved budget
+Init: Get remaining budget
+Init: Get execution time
+Init: Cleaning up CBS
+Init: Initializing the CBS
+Init: Starting periodic task
+Periodic task: Create server and Attach thread
+Periodic task: ID and Get parameters
+Periodic task: Detach thread and Destroy server
+Periodic task: Remaining budget and Execution time
+Periodic task: Set parameters
+Periodic task: Approved budget
+Periodic task: Starting periodic behavior
+P1-S ticks:1
+P1-F ticks:11
+P1-S ticks:31
+P1-F ticks:41
+P1-S ticks:61
+P1-F ticks:71
+P1-S ticks:91
+P1-F ticks:101
+P1-S ticks:121
+*** END OF TEST CBS SCHEDULER 2 ***
diff --git a/testsuites/sptests/spcbssched02/system.h b/testsuites/sptests/spcbssched02/system.h
new file mode 100644
index 0000000000..01191431b7
--- /dev/null
+++ b/testsuites/sptests/spcbssched02/system.h
@@ -0,0 +1,62 @@
+/* system.h
+ *
+ * This include file contains information that is included in every
+ * function in the test set.
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <tmacros.h>
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Task_Periodic(
+ rtems_task_argument argument
+);
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 100000
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_MAXIMUM_PERIODS 10
+
+#define CONFIGURE_INIT_TASK_PRIORITY 100
+#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_EXTRA_TASK_STACKS (6 * 4 * RTEMS_MINIMUM_STACK_SIZE)
+
+#define CONFIGURE_SCHEDULER_CBS
+
+#include <rtems/confdefs.h>
+
+#include <rtems/rtems/clock.h>
+#include <rtems/score/isr.h>
+#include <rtems/rtems/intr.h>
+#include <rtems/cbs.h>
+
+/* global variables */
+
+rtems_id Task_id;
+rtems_name Task_name;
+rtems_task_priority Priority;
+time_t Period;
+time_t Execution;
+time_t Phase;
+
+/* end of include file */
diff --git a/testsuites/sptests/spcbssched02/task_periodic.c b/testsuites/sptests/spcbssched02/task_periodic.c
new file mode 100644
index 0000000000..c59a514782
--- /dev/null
+++ b/testsuites/sptests/spcbssched02/task_periodic.c
@@ -0,0 +1,138 @@
+/* Tasks_Periodic
+ *
+ * This routine serves as a test task for the CBS scheduler
+ * implementation.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include "system.h"
+
+rtems_task Task_Periodic(
+ rtems_task_argument argument
+)
+{
+ rtems_id rmid;
+ rtems_status_code status;
+
+ time_t approved_budget, exec_time, abs_time, remaining_budget;
+
+ int start, stop, now;
+
+ rtems_cbs_server_id server_id, tsid;
+ rtems_cbs_parameters params, tparams;
+
+ params.deadline = Period;
+ params.budget = Execution+1;
+
+ printf( "Periodic task: Create server and Attach thread\n" );
+ if ( rtems_cbs_create_server( &params, NULL, &server_id ) )
+ printf( "ERROR: CREATE SERVER FAILED\n" );
+ if ( rtems_cbs_attach_thread( server_id, Task_id ) )
+ printf( "ERROR: ATTACH THREAD FAILED\n" );
+
+ printf( "Periodic task: ID and Get parameters\n" );
+ if ( rtems_cbs_get_server_id( Task_id, &tsid ) )
+ printf( "ERROR: GET SERVER ID FAILED\n" );
+ if ( tsid != server_id )
+ printf( "ERROR: SERVER ID MISMATCH\n" );
+ if ( rtems_cbs_get_parameters( server_id, &tparams ) )
+ printf( "ERROR: GET PARAMETERS FAILED\n" );
+ if ( params.deadline != tparams.deadline ||
+ params.budget != tparams.budget )
+ printf( "ERROR: PARAMETERS MISMATCH\n" );
+
+ printf( "Periodic task: Detach thread and Destroy server\n" );
+ if ( rtems_cbs_detach_thread( server_id, Task_id ) )
+ printf( "ERROR: DETACH THREAD FAILED\n" );
+ if ( rtems_cbs_destroy_server( server_id ) )
+ printf( "ERROR: DESTROY SERVER FAILED\n" );
+ if ( rtems_cbs_create_server( &params, NULL, &server_id ) )
+ printf( "ERROR: CREATE SERVER FAILED\n" );
+
+ printf( "Periodic task: Remaining budget and Execution time\n" );
+ if ( rtems_cbs_get_remaining_budget( server_id, &remaining_budget ) )
+ printf( "ERROR: GET REMAINING BUDGET FAILED\n" );
+ if ( remaining_budget != params.budget )
+ printf( "ERROR: REMAINING BUDGET MISMATCH\n" );
+ if ( rtems_cbs_get_execution_time( server_id, &exec_time, &abs_time ) )
+ printf( "ERROR: GET EXECUTION TIME FAILED\n" );
+
+ printf( "Periodic task: Set parameters\n" );
+ if ( rtems_cbs_attach_thread( server_id, Task_id ) )
+ printf( "ERROR: ATTACH THREAD FAILED\n" );
+ params.deadline = Period * 2;
+ params.budget = Execution * 2 +1;
+ if ( rtems_cbs_set_parameters( server_id, &params ) )
+ printf( "ERROR: SET PARAMS FAILED\n" );
+ if ( rtems_cbs_get_parameters( server_id, &tparams ) )
+ printf( "ERROR: GET PARAMS FAILED\n" );
+ if ( params.deadline != tparams.deadline ||
+ params.budget != tparams.budget )
+ printf( "ERROR: PARAMS MISMATCH\n" );
+ params.deadline = Period;
+ params.budget = Execution+1;
+ if ( rtems_cbs_set_parameters( server_id, &params ) )
+ printf( "ERROR: SET PARAMS FAILED\n" );
+ if ( rtems_cbs_get_approved_budget( server_id, &approved_budget ) )
+ printf( "ERROR: GET APPROVED BUDGET FAILED\n" );
+
+ printf( "Periodic task: Approved budget\n" );
+ if ( approved_budget != params.budget )
+ printf( "ERROR: APPROVED BUDGET MISMATCH\n" );
+
+ status = rtems_rate_monotonic_create( argument, &rmid );
+ directive_failed( status, "rtems_rate_monotonic_create" );
+
+ /* Starting periodic behavior of the task */
+ printf( "Periodic task: Starting periodic behavior\n" );
+ status = rtems_task_wake_after( 1 + Phase );
+ directive_failed( status, "rtems_task_wake_after" );
+
+ while ( FOREVER ) {
+ if ( rtems_rate_monotonic_period(rmid, Period) == RTEMS_TIMEOUT )
+ printf( "P%" PRIdPTR " - Deadline miss\n", argument );
+
+ rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start );
+ printf( "P%" PRIdPTR "-S ticks:%d\n", argument, start );
+ if ( start > 4*Period+Phase ) break; /* stop */
+ /* active computing */
+ while(FOREVER) {
+ rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now );
+ if ( now >= start + Execution ) break;
+
+ if ( rtems_cbs_get_execution_time( server_id, &exec_time, &abs_time ) )
+ printf( "ERROR: GET EXECUTION TIME FAILED\n" );
+ if ( rtems_cbs_get_remaining_budget( server_id, &remaining_budget) )
+ printf( "ERROR: GET REMAINING BUDGET FAILED\n" );
+ if ( (remaining_budget + exec_time) > (Execution + 1) ) {
+ printf( "ERROR: REMAINING BUDGET AND EXECUTION TIME MISMATCH\n" );
+ rtems_test_exit( 0 );
+ }
+ }
+ rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop );
+ printf( "P%" PRIdPTR "-F ticks:%d\n", argument, stop );
+ }
+
+ /* delete period and SELF */
+ status = rtems_rate_monotonic_delete( rmid );
+ if ( status != RTEMS_SUCCESSFUL ) {
+ printf("rtems_rate_monotonic_delete failed with status of %d.\n", status);
+ rtems_test_exit( 0 );
+ }
+ if ( rtems_cbs_cleanup() )
+ printf( "ERROR: CBS CLEANUP\n" );
+
+ fflush(stdout);
+ puts( "*** END OF TEST CBS SCHEDULER 2 ***" );
+ rtems_test_exit( 0 );
+}