OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/rtos/rtems/c/src/tests/sptests/sp26
    from Rev 30 to Rev 173
    Reverse comparison

Rev 30 → Rev 173

/init.c
0,0 → 1,38
/* 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
*
* 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.OARcorp.com/rtems/license.html.
*
* $Id: init.c,v 1.2 2001-09-27 12:02:36 chris Exp $
*/
 
#define TEST_INIT
#include "system.h"
 
 
rtems_task Init(
rtems_task_argument argument
)
{
puts( "\n\n*** TEST 26 ***" );
 
task1();
/* does not return */
puts( "Init - task1 should not have returned" );
exit( 0 );
}
/task1.c
0,0 → 1,118
/*
* 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.OARcorp.com/rtems/license.html.
*
* $Id: task1.c,v 1.2 2001-09-27 12:02:36 chris Exp $
*/
 
#include <stdio.h>
#include <rtems.h>
#include <rtems/error.h>
 
static rtems_id taskId1;
static rtems_id taskId2;
rtems_interval ticksPerSecond;
 
static int
isSuspended (rtems_id tid)
{
rtems_status_code sc;
 
sc = rtems_task_is_suspended (tid);
if (sc == RTEMS_ALREADY_SUSPENDED)
return 1;
if (sc != RTEMS_SUCCESSFUL)
printf ("rtems_task_is_suspended: %s\n", rtems_status_text (sc));
return 0;
}
 
static void
subTask1 (rtems_task_argument arg)
{
rtems_status_code sc;
 
rtems_task_wake_after (ticksPerSecond * 3);
sc = rtems_event_send (taskId2, 1);
if (sc != RTEMS_SUCCESSFUL) {
printf ("subTask1 - Can't send event (%d)\n", sc);
rtems_task_suspend (RTEMS_SELF);
}
rtems_task_wake_after (ticksPerSecond * 3);
printf ("subTask1 - Event sent\n");
rtems_task_suspend (RTEMS_SELF);
printf ("subTask1 - Back to task 1\n");
rtems_task_wake_after (ticksPerSecond * 3);
rtems_task_suspend (RTEMS_SELF);
}
 
static void
subTask2 (rtems_task_argument arg)
{
rtems_status_code sc;
rtems_event_set ev;
 
rtems_task_wake_after (ticksPerSecond * 1);
sc = rtems_event_receive (1, RTEMS_WAIT|RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &ev);
if (sc != RTEMS_SUCCESSFUL) {
printf ("subTask2 - Can't receive event (%d)\n", sc);
rtems_task_suspend (RTEMS_SELF);
}
printf ("subTask2 - Task 1 suspended? - should be 0: %d\n",
isSuspended (taskId1));
rtems_task_wake_after (ticksPerSecond * 4);
printf ("subTask2 - Task 1 suspended? - should be 1: %d\n",
isSuspended (taskId1));
rtems_task_resume (taskId1);
printf ("subTask2 - Task 1 suspended? - should be 0: %d\n",
isSuspended (taskId1));
rtems_task_wake_after (ticksPerSecond * 4);
printf ("subTask2 - Task 1 suspended? - should be 1: %d\n",
isSuspended (taskId1));
puts( "*** END OF TEST 26 ***" );
exit( 0 );
}
 
static void
createTask (char c, rtems_id *tid)
{
rtems_status_code sc;
 
sc = rtems_task_create (rtems_build_name('S','u','b',c),
100,
RTEMS_MINIMUM_STACK_SIZE * 4,
RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
tid);
if (sc != RTEMS_SUCCESSFUL) {
printf ("Can't create task (%d)\n", sc);
rtems_task_suspend (RTEMS_SELF);
}
}
 
static void
startTask (rtems_id tid, rtems_task_entry entry_point)
{
rtems_status_code sc;
 
sc = rtems_task_start (tid, entry_point, 0);
if (sc != RTEMS_SUCCESSFUL) {
printf ("Can't start task (%d)\n", sc);
rtems_task_suspend (RTEMS_SELF);
}
}
 
void
task1 (void)
{
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
createTask ('1', &taskId1);
createTask ('2', &taskId2);
startTask (taskId1, subTask1);
startTask (taskId2, subTask2);
rtems_task_suspend (RTEMS_SELF);
}
/Makefile.am
0,0 → 1,38
##
## $Id: Makefile.am,v 1.2 2001-09-27 12:02:36 chris Exp $
##
 
AUTOMAKE_OPTIONS = foreign 1.4
 
TEST = sp26
 
MANAGERS = io region event
 
C_FILES = init.c task1.c
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
 
H_FILES = system.h
noinst_HEADERS = $(H_FILES)
 
DOCTYPES = scn doc
DOCS = $(DOCTYPES:%=$(TEST).%)
 
SRCS = $(C_FILES) $(H_FILES)
OBJS = $(C_O_FILES)
 
PRINT_SRCS = $(DOCS)
 
PGM = ${ARCH}/$(TEST).exe
 
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/sptests.am
 
${PGM}: $(OBJS) $(LINK_FILES)
$(make-exe)
 
all-local: $(ARCH) $(TMPINSTALL_FILES)
 
EXTRA_DIST = $(C_FILES) $(DOCS)
 
include $(top_srcdir)/../../../../automake/local.am
/system.h
0,0 → 1,45
/* 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.OARcorp.com/rtems/license.html.
*
* $Id: system.h,v 1.2 2001-09-27 12:02:36 chris Exp $
*/
 
#include <tmacros.h>
 
/* functions */
 
rtems_task Init(
rtems_task_argument argument
);
 
void task1(void);
 
/* configuration information */
 
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
 
#define CONFIGURE_MAXIMUM_TASKS 5
#define CONFIGURE_MAXIMUM_REGIONS 1
 
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
#include <confdefs.h>
 
/* global variables */
 
TEST_EXTERN rtems_id Task_id[ 6 ]; /* array of task ids */
TEST_EXTERN rtems_name Task_name[ 6 ]; /* array of task names */
#define BASE_PRIORITY 140
/* end of include file */
/sp26.scn
0,0 → 1,8
*** TEST 26 ***
subTask2 - Task 1 suspended? - should be 0: 0
subTask1 - Event sent
subTask2 - Task 1 suspended? - should be 1: 1
subTask2 - Task 1 suspended? - should be 0: 0
subTask1 - Back to task 1
subTask2 - Task 1 suspended? - should be 1: 1
*** END OF TEST 26 ***
/sp26.doc
0,0 → 1,23
#
# $Id: sp26.doc,v 1.2 1999/11/17 17:51:33 joel Exp $
#
# 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.OARcorp.com/rtems/license.html.
#
 
 
This file describes the directives and concepts tested by this test set.
 
test set name: sp26
 
directives:
task_is_suspended
 
concepts:
 
a. task_is_suspended operates correctly.
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.