Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Ticket #1908: qreslib.diff

File qreslib.diff, 26.2 KB (added by Petr Benes, on 09/01/11 at 21:06:30)

QoS library for CBS scheduler

  • cpukit/Makefile.am

    diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
    index bea480a..7977e5c 100644
    a b SUBDIRS += libi2c 
    1515SUBDIRS += libmisc
    1616SUBDIRS += libmd
    1717SUBDIRS += libgnat
     18SUBDIRS += libqos
    1819SUBDIRS += wrapup
    1920
    2021SUBDIRS += zlib
  • cpukit/configure.ac

    diff --git a/cpukit/configure.ac b/cpukit/configure.ac
    index 20de11a..93c5b43 100644
    a b librpc/Makefile 
    359359libmisc/Makefile
    360360libi2c/Makefile
    361361libmd/Makefile
     362libqos/Makefile
    362363zlib/Makefile
    363364ftpd/Makefile
    364365telnetd/Makefile
  • new file cpukit/libqos/Makefile.am

    diff --git a/cpukit/libqos/Makefile.am b/cpukit/libqos/Makefile.am
    new file mode 100644
    index 0000000..3223dcd
    - +  
     1##
     2## $Id$
     3##
     4
     5include $(top_srcdir)/automake/multilib.am
     6include $(top_srcdir)/automake/compile.am
     7
     8include_HEADERS = qreslib.h
     9include_HEADERS += qreslib.inl
     10
     11include $(srcdir)/preinstall.am
     12include $(top_srcdir)/automake/local.am
  • new file cpukit/libqos/qreslib.h

    diff --git a/cpukit/libqos/qreslib.h b/cpukit/libqos/qreslib.h
    new file mode 100644
    index 0000000..97f9e46
    - +  
     1/*
     2 *  Copyright (C) 2011 Petr Benes.
     3 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
     4 *
     5 *  The license and distribution terms for this file may be
     6 *  found in the file LICENSE in this distribution or at
     7 *  http://www.rtems.com/license/LICENSE.
     8 *
     9 *  $Id$
     10 */
     11
     12#ifndef CONFIGURE_SCHEDULER_CBS
     13  #error "qreslib.h available only with CONFIGURE_SCHEDULER_CBS"
     14#endif
     15
     16#ifndef _QRESLIB_H
     17#define _QRESLIB_H
     18
     19#ifdef __cplusplus
     20extern "C" {
     21#endif
     22
     23#include <stdint.h>
     24#include <rtems/score/schedulercbs.h>
     25
     26/** Return values. */
     27typedef int qos_rv;
     28
     29/** Return codes. */
     30#define QOS_OK                   SCHEDULER_CBS_OK
     31#define QOS_E_GENERIC            SCHEDULER_CBS_ERROR_GENERIC
     32#define QOS_E_NO_MEMORY          SCHEDULER_CBS_ERROR_NO_MEMORY
     33#define QOS_E_INVALID_PARAM      SCHEDULER_CBS_ERROR_INVALID_PARAMETER
     34#define QOS_E_UNAUTHORIZED       SCHEDULER_CBS_ERROR_UNAUTHORIZED
     35#define QOS_E_UNIMPLEMENTED      SCHEDULER_CBS_ERROR_UNIMPLEMENTED
     36#define QOS_E_MISSING_COMPONENT  SCHEDULER_CBS_ERROR_MISSING_COMPONENT
     37#define QOS_E_INCONSISTENT_STATE SCHEDULER_CBS_ERROR_INCONSISTENT_STATE
     38#define QOS_E_SYSTEM_OVERLOAD    SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD
     39#define QOS_E_INTERNAL_ERROR     SCHEDULER_CBS_ERROR_INTERNAL_ERROR
     40#define QOS_E_NOT_FOUND          SCHEDULER_CBS_ERROR_NOT_FOUND
     41#define QOS_E_FULL               SCHEDULER_CBS_ERROR_FULL
     42#define QOS_E_EMPTY              SCHEDULER_CBS_ERROR_EMPTY
     43#define QOS_E_NOSERVER           SCHEDULER_CBS_ERROR_NOSERVER
     44
     45/** Server id. */
     46typedef Scheduler_CBS_Server_id qres_sid_t;
     47
     48/** Task id. */
     49typedef rtems_id tid_t;
     50
     51/** Time value. */
     52typedef time_t qres_time_t;
     53
     54/** Absolute time value */
     55typedef time_t qres_atime_t;
     56
     57/** Server parameters. */
     58typedef struct {
     59  /** Relative deadline of the server. */
     60  uint32_t P;
     61  /** Budget (computation time) of the server. */
     62  uint32_t Q;
     63} qres_params_t;
     64
     65#include <qreslib.inl>
     66
     67#ifdef __cplusplus
     68}
     69#endif
     70
     71#endif
     72/* end of include file */
  • new file cpukit/libqos/qreslib.inl

    diff --git a/cpukit/libqos/qreslib.inl b/cpukit/libqos/qreslib.inl
    new file mode 100644
    index 0000000..42aaf35
    - +  
     1/**
     2 * @file qreslib.inl
     3 *
     4 *  This include file contains all the constants and structures associated
     5 *  with the QoS RES library.
     6 *
     7 * @note The library is available only together with CBS scheduler.
     8 */
     9
     10/*
     11 *  Copyright (C) 2011 Petr Benes.
     12 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
     13 *
     14 *  The license and distribution terms for this file may be
     15 *  found in the file LICENSE in this distribution or at
     16 *  http://www.rtems.com/license/LICENSE.
     17 *
     18 *  $Id$
     19 */
     20
     21#ifndef _QRESLIB_H
     22# error "Never use <qreslib.inl> directly; include <qreslib.h> instead."
     23#endif
     24
     25#include <rtems/score/schedulercbs.h>
     26
     27/**
     28 *  @brief qres init
     29 *
     30 *  Initializes the QoS RES library.
     31 */
     32RTEMS_INLINE_ROUTINE qos_rv qres_init ( void )
     33{
     34  return _Scheduler_CBS_Initialize();
     35}
     36
     37/**
     38 *  @brief qres cleanup
     39 *
     40 *  Cleanup resources associated to the QoS RES Library.
     41 */
     42RTEMS_INLINE_ROUTINE qos_rv qres_cleanup ( void )
     43{
     44  return _Scheduler_CBS_Cleanup();
     45}
     46
     47/**
     48 *  @brief qres create server
     49 *
     50 *  Create a new server with specified parameters.
     51 */
     52RTEMS_INLINE_ROUTINE qos_rv qres_create_server (
     53  qres_params_t *params,
     54  qres_sid_t    *server_id
     55)
     56{
     57  return _Scheduler_CBS_Create_server(
     58             (Scheduler_CBS_Parameters *) params,
     59             server_id
     60         );
     61}
     62
     63/**
     64 *  @brief qres attach thread
     65 *
     66 *  Attach a task to an already existing server.
     67 */
     68RTEMS_INLINE_ROUTINE qos_rv qres_attach_thread (
     69  qres_sid_t server_id,
     70  pid_t      pid,
     71  tid_t      task_id
     72)
     73{
     74  return _Scheduler_CBS_Attach_thread( server_id, task_id );
     75}
     76
     77/**
     78 *  @brief qres detach thread
     79 *
     80 *  Detach from the QoS Server.
     81 */
     82RTEMS_INLINE_ROUTINE qos_rv qres_detach_thread (
     83  qres_sid_t server_id,
     84  pid_t      pid,
     85  tid_t      task_id
     86)
     87{
     88  return _Scheduler_CBS_Detach_thread( server_id, task_id );
     89}
     90
     91/**
     92 *  @brief qres destroy server
     93 *
     94 *  Detach all tasks from a server and destroy it.
     95 */
     96RTEMS_INLINE_ROUTINE qos_rv qres_destroy_server (
     97  qres_sid_t server_id
     98)
     99{
     100  return _Scheduler_CBS_Destroy_server( server_id );
     101}
     102
     103/**
     104 *  @brief qres get server id
     105 *
     106 *  Get a thread server id, or QOS_E_NOT_FOUND if it is not
     107 *  attached to any server.
     108 */
     109RTEMS_INLINE_ROUTINE qos_rv qres_get_sid (
     110  pid_t       pid,
     111  tid_t       task_id,
     112  qres_sid_t *server_id
     113)
     114{
     115  return _Scheduler_CBS_Get_server_id( task_id, server_id );
     116}
     117
     118/**
     119 *  @brief qres get params
     120 *
     121 *  Retrieve QoS scheduling parameters.
     122 */
     123RTEMS_INLINE_ROUTINE qos_rv qres_get_params (
     124  qres_sid_t     server_id,
     125  qres_params_t *params
     126)
     127{
     128  return _Scheduler_CBS_Get_parameters(
     129             server_id,
     130             (Scheduler_CBS_Parameters *) params
     131         );
     132}
     133
     134/**
     135 *  @brief qres set params
     136 *
     137 *  Change QoS scheduling parameters.
     138 */
     139RTEMS_INLINE_ROUTINE qos_rv qres_set_params (
     140  qres_sid_t     server_id,
     141  qres_params_t *params
     142)
     143{
     144  return _Scheduler_CBS_Set_parameters(
     145             server_id,
     146             (Scheduler_CBS_Parameters *) params
     147         );
     148}
     149
     150/**
     151 *  @brief qres get execution time
     152 *
     153 *  Retrieve time info relative to the current server.
     154 */
     155RTEMS_INLINE_ROUTINE qos_rv qres_get_exec_time (
     156  qres_sid_t    server_id,
     157  qres_time_t  *exec_time,
     158  qres_atime_t *abs_time
     159)
     160{
     161  return _Scheduler_CBS_Get_execution_time( server_id, exec_time, abs_time );
     162}
     163
     164/**
     165 *  @brief qres get current budget
     166 *
     167 *  Retrieve remaining budget for the current server instance.
     168 */
     169RTEMS_INLINE_ROUTINE qos_rv qres_get_curr_budget (
     170  qres_sid_t   server_id,
     171  qres_time_t *current_budget
     172)
     173{
     174  return _Scheduler_CBS_Get_remaining_budget( server_id, current_budget );
     175}
     176
     177/**
     178 *  @brief qres get approved budget
     179 *
     180 *  Retrieve the budget that has been approved for the subsequent
     181 *  server instances.
     182 */
     183RTEMS_INLINE_ROUTINE qos_rv qres_get_appr_budget (
     184  qres_sid_t   server_id,
     185  qres_time_t *appr_budget
     186)
     187{
     188  return _Scheduler_CBS_Get_approved_budget( server_id, appr_budget );
     189}
  • testsuites/sptests/Makefile.am

    diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
    index d05c901..f0cd57a 100644
    a b SUBDIRS = \ 
    3131    spintrcritical17 spmkdir spmountmgr01 spheapprot \
    3232    spsimplesched01 spsimplesched02 spsimplesched03 spnsext01 \
    3333    spedfsched01 spedfsched02 spedfsched03 \
    34     spcbssched01 spcbssched02 spcbssched03
     34    spcbssched01 spcbssched02 spcbssched03 spqreslib
    3535
    3636include $(top_srcdir)/../automake/subdirs.am
    3737include $(top_srcdir)/../automake/local.am
  • testsuites/sptests/configure.ac

    diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
    index 51c2520..d067a15 100644
    a b spnsext01/Makefile 
    170170spobjgetnext/Makefile
    171171spprintk/Makefile
    172172spprivenv01/Makefile
     173spqreslib/Makefile
    173174sprbtree01/Makefile
    174175spsimplesched01/Makefile
    175176spsimplesched02/Makefile
  • new file testsuites/sptests/spqreslib/Makefile.am

    diff --git a/testsuites/sptests/spqreslib/Makefile.am b/testsuites/sptests/spqreslib/Makefile.am
    new file mode 100644
    index 0000000..bd8323f
    - +  
     1##
     2## $Id$
     3##
     4
     5MANAGERS = io rate_monotonic semaphore clock
     6
     7rtems_tests_PROGRAMS = spqreslib
     8spqreslib_SOURCES = init.c task_periodic.c system.h
     9
     10dist_rtems_tests_DATA = spqreslib.scn
     11dist_rtems_tests_DATA += spqreslib.doc
     12
     13include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
     14include $(top_srcdir)/../automake/compile.am
     15include $(top_srcdir)/../automake/leaf.am
     16
     17spqreslib_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
     18
     19AM_CPPFLAGS += -I$(top_srcdir)/../support/include
     20
     21LINK_OBJS = $(spqreslib_OBJECTS) $(spqreslib_LDADD)
     22LINK_LIBS = $(spqreslib_LDLIBS)
     23
     24spqreslib$(EXEEXT): $(spqreslib_OBJECTS) $(spqreslib_DEPENDENCIES)
     25        @rm -f spqreslib$(EXEEXT)
     26        $(make-exe)
     27
     28include $(top_srcdir)/../automake/local.am
  • new file testsuites/sptests/spqreslib/init.c

    diff --git a/testsuites/sptests/spqreslib/init.c b/testsuites/sptests/spqreslib/init.c
    new file mode 100644
    index 0000000..20745d7
    - +  
     1/*  Init
     2 *
     3 *  This routine is the initialization task for this test program.
     4 *  It is a user initialization task and has the responsibility for creating
     5 *  and starting the tasks that make up the test.  If the time of day
     6 *  clock is required for the test, it should also be set to a known
     7 *  value by this function.
     8 *
     9 *  Input params:
     10 *    argument - task argument
     11 *
     12 *  Output params:  NONE
     13 *
     14 *  The license and distribution terms for this file may be
     15 *  found in the file LICENSE in this distribution or at
     16 *  http://www.rtems.com/license/LICENSE.
     17 *
     18 *  $Id$
     19 */
     20
     21#define CONFIGURE_INIT
     22#include "system.h"
     23
     24rtems_task Init(
     25  rtems_task_argument argument
     26)
     27{
     28  rtems_status_code status;
     29  qres_sid_t server_id, server_id2;
     30  time_t approved_budget, exec_time, abs_time, current_budget;
     31  qres_params_t params, params1, params2, params3, params4;
     32
     33  Priority = 30;
     34  Period    = 30;
     35  Execution = 10;
     36  Phase = 0;
     37
     38  params.P = 1;
     39  params.Q = 1;
     40
     41  params1 = params2 = params3 = params4 = params;
     42  params1.Q = -1;
     43  params2.Q = SCHEDULER_EDF_PRIO_MSB + 1;
     44  params3.P = -1;
     45  params4.P = SCHEDULER_EDF_PRIO_MSB + 1;
     46
     47  puts( "\n\n*** TEST QRES LIBRARY ***" );
     48
     49  Task_name = rtems_build_name( 'P', 'T', '1', ' ' );
     50
     51  status = rtems_task_create(
     52    Task_name,
     53    Priority,
     54    RTEMS_MINIMUM_STACK_SIZE * 4,
     55    RTEMS_DEFAULT_MODES,
     56    RTEMS_DEFAULT_ATTRIBUTES,
     57    &Task_id
     58  );
     59  directive_failed( status, "rtems_task_create loop" );
     60
     61  printf( "Init: Initializing the qres library\n" );
     62  if ( qres_init() )
     63    printf( "ERROR: QRES INITIALIZATION FAILED\n" );
     64
     65  /* Error checks for Create server and Destroy server  */
     66  printf( "Init: Create server and Destroy server\n" );
     67  if ( qres_destroy_server( -5 ) !=
     68       QOS_E_INVALID_PARAM )
     69    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
     70  if ( qres_destroy_server( 5 ) !=
     71       QOS_E_INVALID_PARAM )
     72    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
     73  if ( qres_destroy_server( 0 ) != QOS_E_NOSERVER )
     74    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
     75  if ( qres_create_server( &params1, &server_id ) !=
     76       QOS_E_INVALID_PARAM )
     77    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
     78  if ( qres_create_server( &params2, &server_id ) !=
     79       QOS_E_INVALID_PARAM )
     80    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
     81  if ( qres_create_server( &params3, &server_id ) !=
     82       QOS_E_INVALID_PARAM )
     83    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
     84  if ( qres_create_server( &params4, &server_id ) !=
     85       QOS_E_INVALID_PARAM )
     86    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
     87  if ( qres_create_server( &params, &server_id2 ) )
     88    printf( "ERROR: CREATE SERVER FAILED\n" );
     89  if ( qres_create_server( &params, &server_id ) )
     90    printf( "ERROR: CREATE SERVER FAILED\n" );
     91  if ( qres_create_server( &params, &server_id ) !=
     92       QOS_E_FULL )
     93    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
     94
     95  /* Error checks for Attach thread and Detach thread */
     96  printf( "Init: Attach thread\n" );
     97  if ( qres_attach_thread( -5, 0, RTEMS_SELF ) !=
     98       QOS_E_INVALID_PARAM )
     99    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
     100  if ( qres_attach_thread( 5, 0, RTEMS_SELF ) !=
     101       QOS_E_INVALID_PARAM )
     102    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
     103  if ( qres_attach_thread( server_id, 0, 1234 ) !=
     104       QOS_E_INVALID_PARAM )
     105    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
     106  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) )
     107    printf( "ERROR: ATTACH THREAD FAILED\n" );
     108  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
     109       QOS_E_FULL )
     110    printf( "ERROR: ATTACH THREAD AGAIN PASSED UNEXPECTEDLY\n" );
     111  if ( qres_attach_thread( server_id, 0, Task_id ) !=
     112       QOS_E_FULL )
     113    printf( "ERROR: ATTACH THREAD TO FULL SERVER PASSED UNEXPECTEDLY \n" );
     114  if ( qres_destroy_server( server_id ) )
     115    printf( "ERROR: DESTROY SERVER WITH THREAD ATTACHED FAILED\n" );
     116  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
     117       QOS_E_NOSERVER )
     118    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
     119
     120  printf( "Init: Detach thread\n" );
     121  if ( qres_detach_thread( -5, 0, RTEMS_SELF ) !=
     122       QOS_E_INVALID_PARAM )
     123    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
     124  if ( qres_detach_thread( 5, 0, RTEMS_SELF ) !=
     125       QOS_E_INVALID_PARAM )
     126    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
     127  if ( qres_detach_thread( server_id2, 0, 1234 ) !=
     128       QOS_E_INVALID_PARAM )
     129    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY \n" );
     130  if ( qres_detach_thread( server_id, 0, RTEMS_SELF ) !=
     131       QOS_E_NOSERVER )
     132    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY4\n" );
     133  qres_destroy_server( server_id2 );
     134
     135  /* Error checks for Set params and Get params */
     136  printf( "Init: Set params and Get params\n" );
     137  if ( qres_set_params( -5, &params ) !=
     138       QOS_E_INVALID_PARAM )
     139    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
     140  if ( qres_set_params( 5, &params ) !=
     141       QOS_E_INVALID_PARAM )
     142    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
     143  if ( qres_set_params( server_id, &params ) !=
     144       QOS_E_NOSERVER )
     145    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
     146
     147  if ( qres_get_params( -5, &params ) !=
     148       QOS_E_INVALID_PARAM )
     149    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
     150  if ( qres_get_params( 5, &params ) !=
     151       QOS_E_INVALID_PARAM )
     152    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
     153  if ( qres_get_params( server_id, &params ) !=
     154       QOS_E_NOSERVER )
     155    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
     156
     157  if ( qres_set_params( server_id, &params1 ) !=
     158       QOS_E_INVALID_PARAM )
     159    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
     160  if ( qres_set_params( server_id, &params2 ) !=
     161       QOS_E_INVALID_PARAM )
     162    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
     163  if ( qres_set_params( server_id, &params3 ) !=
     164       QOS_E_INVALID_PARAM )
     165    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
     166  if ( qres_set_params( server_id, &params4 ) !=
     167       QOS_E_INVALID_PARAM )
     168    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
     169
     170  /* Error checks for Get server id */
     171  printf( "Init: Get server id\n" );
     172  if ( qres_get_sid( 0, RTEMS_SELF, &server_id ) !=
     173       QOS_E_NOSERVER )
     174    printf( "ERROR: GET SERVER ID PASSED UNEXPECTEDLY\n" );
     175
     176  /* Error checks for Get approved budget */
     177  printf( "Init: Get approved budget\n" );
     178  if ( qres_get_appr_budget( -5, &approved_budget ) !=
     179       QOS_E_INVALID_PARAM )
     180    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
     181  if ( qres_get_appr_budget( 5, &approved_budget ) !=
     182       QOS_E_INVALID_PARAM )
     183    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
     184  if ( qres_get_appr_budget( server_id, &approved_budget ) !=
     185       QOS_E_NOSERVER )
     186    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
     187
     188  /* Error checks for Get current budget */
     189  printf( "Init: Get current budget\n" );
     190  if ( qres_get_curr_budget( -5, &current_budget ) !=
     191       QOS_E_INVALID_PARAM )
     192    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
     193  if ( qres_get_curr_budget( 5, &current_budget ) !=
     194       QOS_E_INVALID_PARAM )
     195    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
     196  if ( qres_get_curr_budget( server_id, &current_budget ) !=
     197       QOS_E_NOSERVER )
     198    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
     199
     200  /* Error checks for Get execution time */
     201  printf( "Init: Get execution time\n" );
     202  if ( qres_get_exec_time( -5, &exec_time, &abs_time ) !=
     203       QOS_E_INVALID_PARAM )
     204    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
     205  if ( qres_get_exec_time( 5, &exec_time, &abs_time ) !=
     206       QOS_E_INVALID_PARAM )
     207    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
     208  if ( qres_get_exec_time( server_id, &exec_time, &abs_time ) !=
     209       QOS_E_NOSERVER )
     210    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
     211
     212  /* Restart QRES library */
     213  printf( "Init: Cleaning up QRES\n" );
     214  if ( qres_cleanup() )
     215    printf( "ERROR: QRES CLEANUP FAILED\n" );
     216  printf( "Init: Initializing the QRES\n" );
     217  if ( qres_init() )
     218    printf( "ERROR: QRES INITIALIZATION FAILED\n" );
     219
     220  /* Start periodic task */
     221  printf( "Init: Starting periodic task\n" );
     222  status = rtems_task_start( Task_id, Task_Periodic, 1 );
     223  directive_failed( status, "rtems_task_start periodic" );
     224
     225  status = rtems_task_delete( RTEMS_SELF );
     226  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
     227}
  • new file testsuites/sptests/spqreslib/spqreslib.doc

    diff --git a/testsuites/sptests/spqreslib/spqreslib.doc b/testsuites/sptests/spqreslib/spqreslib.doc
    new file mode 100644
    index 0000000..f590216
    - +  
     1#
     2#  $Id$
     3#
     4#  COPYRIGHT (c) 1989-1999.
     5#  On-Line Applications Research Corporation (OAR).
     6#
     7#  The license and distribution terms for this file may be
     8#  found in the file LICENSE in this distribution or at
     9#  http://www.rtems.com/license/LICENSE.
     10#
     11
     12
     13This file describes the directives and concepts tested by this test set.
     14
     15test set name:  spqreslib
     16
     17directives:
     18
     19
     20concepts:
     21
     22  a.  Verifies QRES library functionality.
  • new file testsuites/sptests/spqreslib/spqreslib.scn

    diff --git a/testsuites/sptests/spqreslib/spqreslib.scn b/testsuites/sptests/spqreslib/spqreslib.scn
    new file mode 100644
    index 0000000..de79c34
    - +  
     1*** TEST QRES LIBRARY ***
     2Init: Initializing the qres library
     3Init: Create server and Destroy server
     4Init: Attach thread
     5Init: Detach thread
     6Init: Set params and Get params
     7Init: Get server id
     8Init: Get approved budget
     9Init: Get current budget
     10Init: Get execution time
     11Init: Cleaning up QRES
     12Init: Initializing the QRES
     13Init: Starting periodic task
     14Periodic task: Create server and Attach thread
     15Periodic task: ID and Get parameters
     16Periodic task: Detach thread and Destroy server
     17Periodic task: Current budget and Execution time
     18Periodic task: Set parameters
     19Periodic task: Approved budget
     20Periodic task: Starting periodic behavior
     21P1-S ticks:1
     22P1-F ticks:11
     23P1-S ticks:31
     24P1-F ticks:41
     25P1-S ticks:61
     26P1-F ticks:71
     27P1-S ticks:91
     28P1-F ticks:101
     29P1-S ticks:121
     30*** END OF TEST QRES LIBRARY ***
  • new file testsuites/sptests/spqreslib/system.h

    diff --git a/testsuites/sptests/spqreslib/system.h b/testsuites/sptests/spqreslib/system.h
    new file mode 100644
    index 0000000..f99b5f4
    - +  
     1/*  system.h
     2 *
     3 *  This include file contains information that is included in every
     4 *  function in the test set.
     5 *
     6 *  COPYRIGHT (c) 1989-1999.
     7 *  On-Line Applications Research Corporation (OAR).
     8 *
     9 *  The license and distribution terms for this file may be
     10 *  found in the file LICENSE in this distribution or at
     11 *  http://www.rtems.com/license/LICENSE.
     12 *
     13 *  $Id$
     14 */
     15
     16#include <tmacros.h>
     17
     18/* functions */
     19
     20rtems_task Init(
     21  rtems_task_argument argument
     22);
     23
     24rtems_task Task_Periodic(
     25  rtems_task_argument argument
     26);
     27
     28/* configuration information */
     29
     30#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     31#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     32
     33#define CONFIGURE_MICROSECONDS_PER_TICK 100000
     34
     35#define CONFIGURE_MAXIMUM_TASKS               2
     36#define CONFIGURE_MAXIMUM_PERIODS             10
     37
     38#define CONFIGURE_INIT_TASK_PRIORITY          100
     39#define CONFIGURE_INIT_TASK_INITIAL_MODES     RTEMS_DEFAULT_MODES
     40#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
     41
     42#define CONFIGURE_EXTRA_TASK_STACKS         (6 * 4 * RTEMS_MINIMUM_STACK_SIZE)
     43
     44#define CONFIGURE_SCHEDULER_CBS
     45
     46#include <rtems/confdefs.h>
     47
     48#include <rtems/rtems/clock.h>
     49#include <rtems/score/isr.h>
     50#include <rtems/rtems/intr.h>
     51#include <qreslib.h>
     52
     53/* global variables */
     54
     55rtems_id   Task_id;
     56rtems_name Task_name;
     57rtems_task_priority Priority;
     58time_t  Period;
     59time_t  Execution;
     60time_t  Phase;
     61
     62/* end of include file */
  • new file testsuites/sptests/spqreslib/task_periodic.c

    diff --git a/testsuites/sptests/spqreslib/task_periodic.c b/testsuites/sptests/spqreslib/task_periodic.c
    new file mode 100644
    index 0000000..3b2e682
    - +  
     1/*  Tasks_Periodic
     2 *
     3 *  This routine serves as a test task for the CBS scheduler
     4 *  implementation.
     5 *
     6 *  Input parameters:
     7 *    argument - task argument
     8 *
     9 *  Output parameters:  NONE
     10 *
     11 *  The license and distribution terms for this file may be
     12 *  found in the file LICENSE in this distribution or at
     13 *  http://www.rtems.com/license/LICENSE.
     14 *
     15 *  $Id$
     16 */
     17
     18#include "system.h"
     19
     20rtems_task Task_Periodic(
     21  rtems_task_argument argument
     22)
     23{
     24  rtems_id          rmid;
     25  rtems_status_code status;
     26
     27  time_t approved_budget, exec_time, abs_time, current_budget;
     28
     29  int start, stop, now;
     30
     31  qres_sid_t server_id, tsid;
     32  qres_params_t params, tparams;
     33
     34  params.P = Period;
     35  params.Q = Execution+1;
     36
     37  printf( "Periodic task: Create server and Attach thread\n" );
     38  if ( qres_create_server( &params, &server_id ) )
     39    printf( "ERROR: CREATE SERVER FAILED\n" );
     40  if ( qres_attach_thread( server_id, 0, Task_id ) )
     41    printf( "ERROR: ATTACH THREAD FAILED\n" );
     42
     43  printf( "Periodic task: ID and Get parameters\n" );
     44  if ( qres_get_sid( 0, Task_id, &tsid ) )
     45    printf( "ERROR: GET SERVER ID FAILED\n" );
     46  if ( tsid != server_id )
     47    printf( "ERROR: SERVER ID MISMATCH\n" );
     48  if ( qres_get_params( server_id, &tparams ) )
     49    printf( "ERROR: GET PARAMETERS FAILED\n" );
     50  if ( params.P != tparams.P ||
     51       params.Q != tparams.Q )
     52    printf( "ERROR: PARAMETERS MISMATCH\n" );
     53
     54  printf( "Periodic task: Detach thread and Destroy server\n" );
     55  if ( qres_detach_thread( server_id, 0, Task_id ) )
     56    printf( "ERROR: DETACH THREAD FAILED\n" );
     57  if ( qres_destroy_server( server_id ) )
     58    printf( "ERROR: DESTROY SERVER FAILED\n" );
     59  if ( qres_create_server( &params, &server_id ) )
     60    printf( "ERROR: CREATE SERVER FAILED\n" );
     61
     62  printf( "Periodic task: Current budget and Execution time\n" );
     63  if ( qres_get_curr_budget( server_id, &current_budget ) )
     64    printf( "ERROR: GET REMAINING BUDGET FAILED\n" );
     65  if ( current_budget != params.Q )
     66    printf( "ERROR: REMAINING BUDGET MISMATCH\n" );
     67  if ( qres_get_exec_time( server_id, &exec_time, &abs_time ) )
     68    printf( "ERROR: GET EXECUTION TIME FAILED\n" );
     69
     70  printf( "Periodic task: Set parameters\n" );
     71  if ( qres_attach_thread( server_id, 0, Task_id ) )
     72    printf( "ERROR: ATTACH THREAD FAILED\n" );
     73  params.P = Period * 2;
     74  params.Q = Execution * 2 +1;
     75  if ( qres_set_params( server_id, &params ) )
     76    printf( "ERROR: SET PARAMS FAILED\n" );
     77  if ( qres_get_params( server_id, &tparams ) )
     78    printf( "ERROR: GET PARAMS FAILED\n" );
     79  if ( params.P != tparams.P ||
     80       params.Q != tparams.Q )
     81    printf( "ERROR: PARAMS MISMATCH\n" );
     82  params.P = Period;
     83  params.Q = Execution+1;
     84  if ( qres_set_params( server_id, &params ) )
     85    printf( "ERROR: SET PARAMS FAILED\n" );
     86  if ( qres_get_appr_budget( server_id, &approved_budget ) )
     87    printf( "ERROR: GET APPROVED BUDGET FAILED\n" );
     88
     89  printf( "Periodic task: Approved budget\n" );
     90  if ( approved_budget != params.Q )
     91    printf( "ERROR: APPROVED BUDGET MISMATCH\n" );
     92
     93  status = rtems_rate_monotonic_create( argument, &rmid );
     94  directive_failed( status, "rtems_rate_monotonic_create" );
     95
     96  /* Starting periodic behavior of the task */
     97  printf( "Periodic task: Starting periodic behavior\n" );
     98  status = rtems_task_wake_after( 1 + Phase );
     99  directive_failed( status, "rtems_task_wake_after" );
     100
     101  while ( FOREVER ) {
     102    if ( rtems_rate_monotonic_period(rmid, Period) == RTEMS_TIMEOUT )
     103      printf( "P%d - Deadline miss\n", argument );
     104
     105    rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start );
     106    printf( "P%d-S ticks:%d\n", argument, start );
     107    if ( start > 4*Period+Phase ) break; /* stop */
     108    /* active computing */
     109    while(FOREVER) {
     110      rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now );
     111      if ( now >= start + Execution ) break;
     112
     113      if ( qres_get_exec_time( server_id, &exec_time, &abs_time ) )
     114        printf( "ERROR: GET EXECUTION TIME FAILED\n" );
     115      if ( qres_get_curr_budget( server_id, &current_budget) )
     116        printf( "ERROR: GET CURRENT BUDGET FAILED\n" );
     117      if ( (current_budget + exec_time) > (Execution + 1) ) {
     118        printf( "ERROR: CURRENT BUDGET AND EXECUTION TIME MISMATCH\n" );
     119        rtems_test_exit( 0 );
     120      }
     121    }
     122    rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop );
     123    printf( "P%d-F ticks:%d\n", argument, stop );
     124  }
     125
     126  /* delete period and SELF */
     127  status = rtems_rate_monotonic_delete( rmid );
     128  if ( status != RTEMS_SUCCESSFUL ) {
     129    printf("rtems_rate_monotonic_delete failed with status of %d.\n", status);
     130    rtems_test_exit( 0 );
     131  }
     132  if ( qres_cleanup() )
     133    printf( "ERROR: QRES CLEANUP\n" );
     134
     135  fflush(stdout);
     136  puts( "*** END OF TEST QRES LIBRARY ***" );
     137  rtems_test_exit( 0 );
     138}