Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:35

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*  Task_1
0004  *
0005  *  This test serves as a test task.  It creates and deletes
0006  *  the remaining tasks, twice so that the tasks displayed by
0007  *  the top command grow past the max tasks displayed then shrink
0008  *  back down.
0009  *
0010  *  Input parameters:
0011  *    argument - task argument
0012  *
0013  *  Output parameters:  NONE
0014  *
0015  *  COPYRIGHT (c) 2014.
0016  *  On-Line Applications Research Corporation (OAR).
0017  *
0018  * Redistribution and use in source and binary forms, with or without
0019  * modification, are permitted provided that the following conditions
0020  * are met:
0021  * 1. Redistributions of source code must retain the above copyright
0022  *    notice, this list of conditions and the following disclaimer.
0023  * 2. Redistributions in binary form must reproduce the above copyright
0024  *    notice, this list of conditions and the following disclaimer in the
0025  *    documentation and/or other materials provided with the distribution.
0026  *
0027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0037  * POSSIBILITY OF SUCH DAMAGE.
0038  */
0039 
0040 #ifdef HAVE_CONFIG_H
0041 #include "config.h"
0042 #endif
0043 
0044 #include "system.h"
0045 
0046 static void create_and_start( uint32_t i )
0047 {
0048   rtems_status_code status;
0049   char              str[30];
0050   char              name[6];
0051 
0052   sprintf(name, "TA%02" PRId32 " ", i);
0053 
0054   Task_name[ i ] =  rtems_build_name(
0055     name[0], name[1], name[2], name[3]
0056   );
0057 
0058   status = rtems_task_create(
0059     Task_name[ i ],
0060     1,
0061     RTEMS_MINIMUM_STACK_SIZE,
0062     RTEMS_TIMESLICE,
0063     RTEMS_FLOATING_POINT,
0064     &Task_id[ i ]
0065   );
0066   sprintf(str,"rtems_task_create of %s", name);
0067   directive_failed( status, str );
0068 
0069   status = rtems_task_start( Task_id[ i ], Task_3, i );
0070   sprintf(str, "rtems_task_start of %s", name);
0071   directive_failed( status, str);
0072 }
0073 
0074 rtems_task Task_1(
0075   rtems_task_argument argument
0076 )
0077 {
0078   rtems_status_code status;
0079   char              str[80];
0080   uint32_t          i,j;
0081 
0082   for(j=0; j<2; j++) {
0083 
0084     for( i=3; i<TASK_COUNT; i++) {
0085       create_and_start(i);
0086       status = rtems_task_wake_after (TicksPerSecond * 5);
0087       directive_failed( status, "rtems_task_wake_after" );
0088     }
0089 
0090     status = rtems_task_wake_after (TicksPerSecond * 10);
0091     directive_failed( status, "rtems_task_wake_after" );
0092 
0093     for( i=3; i<TASK_COUNT; i++) {
0094       status = rtems_task_delete( Task_id[i] );
0095       sprintf(str, "task delete TA%02" PRId32 "", i);
0096       directive_failed( status, str );
0097       status = rtems_task_wake_after (TicksPerSecond * 5);
0098       directive_failed( status, "rtems_task_wake_after" );
0099     }
0100   }
0101 
0102   TEST_END();
0103   rtems_test_exit( 0 );
0104 }