//===========================================================================
|
//===========================================================================
|
//
|
//
|
// test7.c
|
// test7.c
|
//
|
//
|
// uITRON "C" test program seven
|
// uITRON "C" test program seven
|
//
|
//
|
//===========================================================================
|
//===========================================================================
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
// -------------------------------------------
|
// -------------------------------------------
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
//
|
//
|
// eCos is free software; you can redistribute it and/or modify it under
|
// eCos is free software; you can redistribute it and/or modify it under
|
// the terms of the GNU General Public License as published by the Free
|
// the terms of the GNU General Public License as published by the Free
|
// Software Foundation; either version 2 or (at your option) any later version.
|
// Software Foundation; either version 2 or (at your option) any later version.
|
//
|
//
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for more details.
|
// for more details.
|
//
|
//
|
// You should have received a copy of the GNU General Public License along
|
// You should have received a copy of the GNU General Public License along
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
//
|
//
|
// As a special exception, if other files instantiate templates or use macros
|
// As a special exception, if other files instantiate templates or use macros
|
// or inline functions from this file, or you compile this file and link it
|
// or inline functions from this file, or you compile this file and link it
|
// with other works to produce a work based on this file, this file does not
|
// with other works to produce a work based on this file, this file does not
|
// by itself cause the resulting work to be covered by the GNU General Public
|
// by itself cause the resulting work to be covered by the GNU General Public
|
// License. However the source code for this file must still be made available
|
// License. However the source code for this file must still be made available
|
// in accordance with section (3) of the GNU General Public License.
|
// in accordance with section (3) of the GNU General Public License.
|
//
|
//
|
// This exception does not invalidate any other reasons why a work based on
|
// This exception does not invalidate any other reasons why a work based on
|
// this file might be covered by the GNU General Public License.
|
// this file might be covered by the GNU General Public License.
|
//
|
//
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// -------------------------------------------
|
// -------------------------------------------
|
//####ECOSGPLCOPYRIGHTEND####
|
//####ECOSGPLCOPYRIGHTEND####
|
//===========================================================================
|
//===========================================================================
|
//#####DESCRIPTIONBEGIN####
|
//#####DESCRIPTIONBEGIN####
|
//
|
//
|
// Author(s): hmt
|
// Author(s): hmt
|
// Contributors: hmt
|
// Contributors: hmt
|
// Date: 1998-10-01
|
// Date: 1998-10-01
|
// Purpose: uITRON API testing
|
// Purpose: uITRON API testing
|
// Description:
|
// Description:
|
//
|
//
|
//####DESCRIPTIONEND####
|
//####DESCRIPTIONEND####
|
//
|
//
|
//===========================================================================
|
//===========================================================================
|
|
|
#include <pkgconf/uitron.h> // uITRON setup CYGNUM_UITRON_SEMAS
|
#include <pkgconf/uitron.h> // uITRON setup CYGNUM_UITRON_SEMAS
|
// CYGPKG_UITRON et al
|
// CYGPKG_UITRON et al
|
#include <cyg/infra/testcase.h> // testing infrastructure
|
#include <cyg/infra/testcase.h> // testing infrastructure
|
|
|
#ifdef CYGPKG_UITRON // we DO want the uITRON package
|
#ifdef CYGPKG_UITRON // we DO want the uITRON package
|
|
|
#ifdef CYGSEM_KERNEL_SCHED_MLQUEUE // we DO want prioritized threads
|
#ifdef CYGSEM_KERNEL_SCHED_MLQUEUE // we DO want prioritized threads
|
|
|
#ifdef CYGFUN_KERNEL_THREADS_TIMER // we DO want timout-able calls
|
#ifdef CYGFUN_KERNEL_THREADS_TIMER // we DO want timout-able calls
|
|
|
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK // we DO want the realtime clock
|
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK // we DO want the realtime clock
|
|
|
// we're OK if it's C++ or neither of those two is defined:
|
// we're OK if it's C++ or neither of those two is defined:
|
#if defined( __cplusplus ) || \
|
#if defined( __cplusplus ) || \
|
(!defined( CYGIMP_UITRON_INLINE_FUNCS ) && \
|
(!defined( CYGIMP_UITRON_INLINE_FUNCS ) && \
|
!defined( CYGIMP_UITRON_CPP_OUTLINE_FUNCS) )
|
!defined( CYGIMP_UITRON_CPP_OUTLINE_FUNCS) )
|
|
|
// =================== TEST CONFIGURATION ===================
|
// =================== TEST CONFIGURATION ===================
|
#if \
|
#if \
|
/* test configuration for enough tasks */ \
|
/* test configuration for enough tasks */ \
|
(CYGNUM_UITRON_TASKS >= 4) && \
|
(CYGNUM_UITRON_TASKS >= 4) && \
|
(CYGNUM_UITRON_TASKS < 90) && \
|
(CYGNUM_UITRON_TASKS < 90) && \
|
(CYGNUM_UITRON_START_TASKS == 1) && \
|
(CYGNUM_UITRON_START_TASKS == 1) && \
|
( !defined(CYGPKG_UITRON_TASKS_CREATE_DELETE) || \
|
( !defined(CYGPKG_UITRON_TASKS_CREATE_DELETE) || \
|
CYGNUM_UITRON_TASKS_INITIALLY >= 4 ) && \
|
CYGNUM_UITRON_TASKS_INITIALLY >= 4 ) && \
|
\
|
\
|
/* test configuration for enough semaphores */ \
|
/* test configuration for enough semaphores */ \
|
defined( CYGPKG_UITRON_SEMAS ) && \
|
defined( CYGPKG_UITRON_SEMAS ) && \
|
(CYGNUM_UITRON_SEMAS >= 3) && \
|
(CYGNUM_UITRON_SEMAS >= 3) && \
|
(CYGNUM_UITRON_SEMAS < 90) && \
|
(CYGNUM_UITRON_SEMAS < 90) && \
|
( !defined(CYGPKG_UITRON_SEMAS_CREATE_DELETE) || \
|
( !defined(CYGPKG_UITRON_SEMAS_CREATE_DELETE) || \
|
CYGNUM_UITRON_SEMAS_INITIALLY >= 3 ) && \
|
CYGNUM_UITRON_SEMAS_INITIALLY >= 3 ) && \
|
\
|
\
|
/* test configuration for enough flag objects */ \
|
/* test configuration for enough flag objects */ \
|
defined( CYGPKG_UITRON_FLAGS ) && \
|
defined( CYGPKG_UITRON_FLAGS ) && \
|
(CYGNUM_UITRON_FLAGS >= 3) && \
|
(CYGNUM_UITRON_FLAGS >= 3) && \
|
(CYGNUM_UITRON_FLAGS < 90) && \
|
(CYGNUM_UITRON_FLAGS < 90) && \
|
( !defined(CYGPKG_UITRON_FLAGS_CREATE_DELETE) || \
|
( !defined(CYGPKG_UITRON_FLAGS_CREATE_DELETE) || \
|
CYGNUM_UITRON_FLAGS_INITIALLY >= 3 ) && \
|
CYGNUM_UITRON_FLAGS_INITIALLY >= 3 ) && \
|
\
|
\
|
/* test configuration for enough message boxes */ \
|
/* test configuration for enough message boxes */ \
|
defined( CYGPKG_UITRON_MBOXES ) && \
|
defined( CYGPKG_UITRON_MBOXES ) && \
|
(CYGNUM_UITRON_MBOXES >= 3) && \
|
(CYGNUM_UITRON_MBOXES >= 3) && \
|
(CYGNUM_UITRON_MBOXES < 90) && \
|
(CYGNUM_UITRON_MBOXES < 90) && \
|
( !defined(CYGPKG_UITRON_MBOXES_CREATE_DELETE) || \
|
( !defined(CYGPKG_UITRON_MBOXES_CREATE_DELETE) || \
|
CYGNUM_UITRON_MBOXES_INITIALLY >= 3 ) && \
|
CYGNUM_UITRON_MBOXES_INITIALLY >= 3 ) && \
|
\
|
\
|
/* test configuration for enough fixed memory pools */ \
|
/* test configuration for enough fixed memory pools */ \
|
defined( CYGPKG_UITRON_MEMPOOLFIXED ) && \
|
defined( CYGPKG_UITRON_MEMPOOLFIXED ) && \
|
(CYGNUM_UITRON_MEMPOOLFIXED >= 3) && \
|
(CYGNUM_UITRON_MEMPOOLFIXED >= 3) && \
|
(CYGNUM_UITRON_MEMPOOLFIXED < 90) && \
|
(CYGNUM_UITRON_MEMPOOLFIXED < 90) && \
|
( !defined(CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE) || \
|
( !defined(CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE) || \
|
CYGNUM_UITRON_MEMPOOLFIXED_INITIALLY >= 3 ) && \
|
CYGNUM_UITRON_MEMPOOLFIXED_INITIALLY >= 3 ) && \
|
\
|
\
|
/* test configuration for enough variable mempools */ \
|
/* test configuration for enough variable mempools */ \
|
defined( CYGPKG_UITRON_MEMPOOLVAR ) && \
|
defined( CYGPKG_UITRON_MEMPOOLVAR ) && \
|
(CYGNUM_UITRON_MEMPOOLVAR >= 3) && \
|
(CYGNUM_UITRON_MEMPOOLVAR >= 3) && \
|
(CYGNUM_UITRON_MEMPOOLVAR < 90) && \
|
(CYGNUM_UITRON_MEMPOOLVAR < 90) && \
|
( !defined(CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE) || \
|
( !defined(CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE) || \
|
CYGNUM_UITRON_MEMPOOLVAR_INITIALLY >= 3 ) && \
|
CYGNUM_UITRON_MEMPOOLVAR_INITIALLY >= 3 ) && \
|
\
|
\
|
/* the end of the large #if statement */ \
|
/* the end of the large #if statement */ \
|
1
|
1
|
|
|
// ============================ END ============================
|
// ============================ END ============================
|
|
|
|
|
|
|
#include <cyg/compat/uitron/uit_func.h> // uITRON
|
#include <cyg/compat/uitron/uit_func.h> // uITRON
|
|
|
externC void
|
externC void
|
cyg_package_start( void )
|
cyg_package_start( void )
|
{
|
{
|
CYG_TEST_INIT();
|
CYG_TEST_INIT();
|
CYG_TEST_INFO( "Calling cyg_uitron_start()" );
|
CYG_TEST_INFO( "Calling cyg_uitron_start()" );
|
cyg_uitron_start();
|
cyg_uitron_start();
|
}
|
}
|
|
|
// ========================================================================
|
// ========================================================================
|
|
|
typedef enum {
|
typedef enum {
|
START_WAITOP = 0,
|
START_WAITOP = 0,
|
SLEEP = 0,
|
SLEEP = 0,
|
DELAY,
|
DELAY,
|
SEMGET,
|
SEMGET,
|
FLAGWAIT,
|
FLAGWAIT,
|
MSGGET,
|
MSGGET,
|
MEMFIXEDGET,
|
MEMFIXEDGET,
|
MEMVARGET,
|
MEMVARGET,
|
DONE_WAITOP
|
DONE_WAITOP
|
} WAITOP;
|
} WAITOP;
|
|
|
typedef enum {
|
typedef enum {
|
START_TYPE = 0,
|
START_TYPE = 0,
|
PLAIN = 0,
|
PLAIN = 0,
|
TIMED = 1,
|
TIMED = 1,
|
DONE_TYPE
|
DONE_TYPE
|
} WAITTYPE;
|
} WAITTYPE;
|
|
|
typedef enum {
|
typedef enum {
|
START_KILLOP = 0,
|
START_KILLOP = 0,
|
|
|
// These are the 5 ways out of a wait that we perm
|
// These are the 5 ways out of a wait that we perm
|
// with other circumstances:
|
// with other circumstances:
|
SIGNAL = 0, // do the appropriate producer op
|
SIGNAL = 0, // do the appropriate producer op
|
TIMEOUT, // wait for the timeout to fire
|
TIMEOUT, // wait for the timeout to fire
|
RELEASE, // do a rel_wai()
|
RELEASE, // do a rel_wai()
|
DELETE, // delete the object; del_xxx()
|
DELETE, // delete the object; del_xxx()
|
KILL, // do a ter_tsk() on the waiter
|
KILL, // do a ter_tsk() on the waiter
|
|
|
SUSPEND_SIGNAL_RESUME,
|
SUSPEND_SIGNAL_RESUME,
|
SUSPEND_TIMEOUT_RESUME,
|
SUSPEND_TIMEOUT_RESUME,
|
SUSPEND_RELEASE_RESUME,
|
SUSPEND_RELEASE_RESUME,
|
SUSPEND_DELETE_RESUME,
|
SUSPEND_DELETE_RESUME,
|
SUSPEND_KILL, // resume not applicable
|
SUSPEND_KILL, // resume not applicable
|
|
|
SUSPEND_SIGNAL_KILL,
|
SUSPEND_SIGNAL_KILL,
|
SUSPEND_TIMEOUT_KILL,
|
SUSPEND_TIMEOUT_KILL,
|
SUSPEND_RELEASE_KILL,
|
SUSPEND_RELEASE_KILL,
|
SUSPEND_DELETE_KILL,
|
SUSPEND_DELETE_KILL,
|
// SUSPEND_KILL_KILL not applicable
|
// SUSPEND_KILL_KILL not applicable
|
|
|
#if 0
|
#if 0
|
// support these later if _really_ keen.
|
// support these later if _really_ keen.
|
SUSPEND_SIGNAL_DELETE_RESUME,
|
SUSPEND_SIGNAL_DELETE_RESUME,
|
SUSPEND_TIMEOUT_DELETE_RESUME,
|
SUSPEND_TIMEOUT_DELETE_RESUME,
|
SUSPEND_RELEASE_DELETE_RESUME,
|
SUSPEND_RELEASE_DELETE_RESUME,
|
// SUSPEND_DELETE_DELETE_RESUME not applicable
|
// SUSPEND_DELETE_DELETE_RESUME not applicable
|
// SUSPEND_KILL_DELETE_RESUME not applicable
|
// SUSPEND_KILL_DELETE_RESUME not applicable
|
|
|
SUSPEND_SIGNAL_DELETE_KILL,
|
SUSPEND_SIGNAL_DELETE_KILL,
|
SUSPEND_TIMEOUT_DELETE_KILL,
|
SUSPEND_TIMEOUT_DELETE_KILL,
|
SUSPEND_RELEASE_DELETE_KILL,
|
SUSPEND_RELEASE_DELETE_KILL,
|
// SUSPEND_DELETE_DELETE_KILL,
|
// SUSPEND_DELETE_DELETE_KILL,
|
SUSPEND_KILL_DELETE // 2nd kill not applicable
|
SUSPEND_KILL_DELETE // 2nd kill not applicable
|
#endif
|
#endif
|
|
|
DONE_KILLOP
|
DONE_KILLOP
|
} KILLOP;
|
} KILLOP;
|
|
|
// ========================================================================
|
// ========================================================================
|
|
|
char * waitstrings[] =
|
char * waitstrings[] =
|
{ "Sleep ", "Delay ", "Sema ", "Flag ", "Mbox ", "MemFix", "MemVar" };
|
{ "Sleep ", "Delay ", "Sema ", "Flag ", "Mbox ", "MemFix", "MemVar" };
|
|
|
char * typestrings[] =
|
char * typestrings[] =
|
{ " (Plain) : ", " (Timed) : " };
|
{ " (Plain) : ", " (Timed) : " };
|
|
|
char * killstrings[] =
|
char * killstrings[] =
|
{ "Signal",
|
{ "Signal",
|
"Wait-for-timeout",
|
"Wait-for-timeout",
|
"Release-wait",
|
"Release-wait",
|
"Delete-object",
|
"Delete-object",
|
"Kill-task",
|
"Kill-task",
|
|
|
"Suspend/Signal/Resume",
|
"Suspend/Signal/Resume",
|
"Suspend/Wait-for-timeout/Resume",
|
"Suspend/Wait-for-timeout/Resume",
|
"Suspend/Release-wait/Resume",
|
"Suspend/Release-wait/Resume",
|
"Suspend/Delete-object/Resume",
|
"Suspend/Delete-object/Resume",
|
"Suspend/Kill-task",
|
"Suspend/Kill-task",
|
|
|
"Suspend/Signal/Kill-task",
|
"Suspend/Signal/Kill-task",
|
"Suspend/Wait-for-timeout/Kill-task",
|
"Suspend/Wait-for-timeout/Kill-task",
|
"Suspend/Release-wait/Kill-task",
|
"Suspend/Release-wait/Kill-task",
|
"Suspend/Delete-object/Kill-task",
|
"Suspend/Delete-object/Kill-task",
|
|
|
|
|
};
|
};
|
|
|
// ========================================================================
|
// ========================================================================
|
|
|
inline int task2arg( WAITOP wait, WAITTYPE waittype, KILLOP kill )
|
inline int task2arg( WAITOP wait, WAITTYPE waittype, KILLOP kill )
|
{
|
{
|
return waittype + (wait << 1) + (kill << 8);
|
return waittype + (wait << 1) + (kill << 8);
|
}
|
}
|
|
|
inline void decodearg( int arg, WAITOP *pwait, WAITTYPE *pwaittype, KILLOP *pkill )
|
inline void decodearg( int arg, WAITOP *pwait, WAITTYPE *pwaittype, KILLOP *pkill )
|
{
|
{
|
*pwaittype = (arg & 1) ? TIMED : PLAIN;
|
*pwaittype = (arg & 1) ? TIMED : PLAIN;
|
*pwait = (arg >> 1) & 0x7f;
|
*pwait = (arg >> 1) & 0x7f;
|
*pkill = (arg >> 8);
|
*pkill = (arg >> 8);
|
}
|
}
|
|
|
static char *strdog( char *p, char *q )
|
static char *strdog( char *p, char *q )
|
{
|
{
|
while ( 0 != (*p++ = *q++) );
|
while ( 0 != (*p++ = *q++) );
|
return p - 1;
|
return p - 1;
|
}
|
}
|
|
|
static char *
|
static char *
|
makemsg( char *z, WAITOP wait, WAITTYPE waittype, KILLOP kill )
|
makemsg( char *z, WAITOP wait, WAITTYPE waittype, KILLOP kill )
|
{
|
{
|
static char buf[ 1000 ];
|
static char buf[ 1000 ];
|
char *p = buf;
|
char *p = buf;
|
p = strdog( p, z );
|
p = strdog( p, z );
|
p = strdog( p, waitstrings[ wait ] );
|
p = strdog( p, waitstrings[ wait ] );
|
p = strdog( p, typestrings[ waittype ] );
|
p = strdog( p, typestrings[ waittype ] );
|
p = strdog( p, killstrings[ kill ] );
|
p = strdog( p, killstrings[ kill ] );
|
*p = 0;
|
*p = 0;
|
return buf;
|
return buf;
|
}
|
}
|
|
|
// ========================================================================
|
// ========================================================================
|
|
|
volatile int intercom = 0;
|
volatile int intercom = 0;
|
|
|
// ========================================================================
|
// ========================================================================
|
|
|
T_RTSK rtsk;
|
T_RTSK rtsk;
|
|
|
void
|
void
|
do_suspend( void )
|
do_suspend( void )
|
{
|
{
|
ER ercd;
|
ER ercd;
|
ercd = ref_tsk( &rtsk, 2 );
|
ercd = ref_tsk( &rtsk, 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( TTS_WAI == rtsk.tskstat, "bad tskstat !TTS_WAI" );
|
CYG_TEST_CHECK( TTS_WAI == rtsk.tskstat, "bad tskstat !TTS_WAI" );
|
ercd = sus_tsk( 2 );
|
ercd = sus_tsk( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" );
|
ercd = ref_tsk( &rtsk, 2 );
|
ercd = ref_tsk( &rtsk, 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( TTS_WAS == rtsk.tskstat, "bad tskstat !TTS_WAS" );
|
CYG_TEST_CHECK( TTS_WAS == rtsk.tskstat, "bad tskstat !TTS_WAS" );
|
}
|
}
|
|
|
void
|
void
|
do_resume( void )
|
do_resume( void )
|
{
|
{
|
ER ercd;
|
ER ercd;
|
ercd = ref_tsk( &rtsk, 2 );
|
ercd = ref_tsk( &rtsk, 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( TTS_SUS == rtsk.tskstat, "bad tskstat !TTS_SUS" );
|
CYG_TEST_CHECK( TTS_SUS == rtsk.tskstat, "bad tskstat !TTS_SUS" );
|
ercd = dis_dsp();
|
ercd = dis_dsp();
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
ercd = rsm_tsk( 2 );
|
ercd = rsm_tsk( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "rsm_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "rsm_tsk bad ercd" );
|
ercd = ref_tsk( &rtsk, 2 );
|
ercd = ref_tsk( &rtsk, 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( TTS_RDY == rtsk.tskstat, "bad tskstat !TTS_RDY" );
|
CYG_TEST_CHECK( TTS_RDY == rtsk.tskstat, "bad tskstat !TTS_RDY" );
|
ercd = ena_dsp();
|
ercd = ena_dsp();
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
}
|
}
|
|
|
// ========================================================================
|
// ========================================================================
|
|
|
#define T1_WAIT (7)
|
#define T1_WAIT (7)
|
#define T2_WAIT (5)
|
#define T2_WAIT (5)
|
|
|
#define T1_MALLOC (110)
|
#define T1_MALLOC (110)
|
#ifdef CYGSEM_KERNEL_MEMORY_COALESCE
|
#ifdef CYGSEM_KERNEL_MEMORY_COALESCE
|
#define T2_MALLOC (100)
|
#define T2_MALLOC (100)
|
#else
|
#else
|
#define T2_MALLOC T1_MALLOC
|
#define T2_MALLOC T1_MALLOC
|
#endif
|
#endif
|
|
|
VP vptmp;
|
VP vptmp;
|
VP vp = NULL;
|
VP vp = NULL;
|
VP vp1 = NULL;
|
VP vp1 = NULL;
|
VP t2vp = NULL;
|
VP t2vp = NULL;
|
VP t2vp_backup = NULL;
|
VP t2vp_backup = NULL;
|
|
|
UINT scratch;
|
UINT scratch;
|
|
|
T_MSG *msg = (T_MSG *)&scratch;
|
T_MSG *msg = (T_MSG *)&scratch;
|
T_MSG *msg1;
|
T_MSG *msg1;
|
|
|
void
|
void
|
do_prep( WAITOP wait )
|
do_prep( WAITOP wait )
|
{
|
{
|
ER ercd;
|
ER ercd;
|
switch ( wait ) {
|
switch ( wait ) {
|
case SLEEP:
|
case SLEEP:
|
case DELAY:
|
case DELAY:
|
case SEMGET:
|
case SEMGET:
|
case FLAGWAIT:
|
case FLAGWAIT:
|
case MSGGET:
|
case MSGGET:
|
// do nothing for all of those
|
// do nothing for all of those
|
break;
|
break;
|
case MEMFIXEDGET:
|
case MEMFIXEDGET:
|
// allocate all the memory in the pool; remember a couple
|
// allocate all the memory in the pool; remember a couple
|
// for freeing as the signalling operation:
|
// for freeing as the signalling operation:
|
t2vp = NULL;
|
t2vp = NULL;
|
vp = vptmp = NULL;
|
vp = vptmp = NULL;
|
do {
|
do {
|
vp1 = vptmp;
|
vp1 = vptmp;
|
vptmp = vp;
|
vptmp = vp;
|
ercd = pget_blf( &vp, 1 );
|
ercd = pget_blf( &vp, 1 );
|
} while ( E_OK == ercd );
|
} while ( E_OK == ercd );
|
CYG_TEST_CHECK( E_TMOUT == ercd, "get_blf bad ercd" );
|
CYG_TEST_CHECK( E_TMOUT == ercd, "get_blf bad ercd" );
|
CYG_TEST_CHECK( NULL != vp, "no allocated block to free" );
|
CYG_TEST_CHECK( NULL != vp, "no allocated block to free" );
|
CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" );
|
CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" );
|
break;
|
break;
|
case MEMVARGET:
|
case MEMVARGET:
|
// allocate all the memory in the pool; remember a couple
|
// allocate all the memory in the pool; remember a couple
|
// for freeing as the signalling operation:
|
// for freeing as the signalling operation:
|
t2vp = NULL;
|
t2vp = NULL;
|
vp = vptmp = NULL;
|
vp = vptmp = NULL;
|
do {
|
do {
|
vp1 = vptmp;
|
vp1 = vptmp;
|
vptmp = vp;
|
vptmp = vp;
|
ercd = pget_blk( &vp, 1, T1_MALLOC );
|
ercd = pget_blk( &vp, 1, T1_MALLOC );
|
} while ( E_OK == ercd );
|
} while ( E_OK == ercd );
|
CYG_TEST_CHECK( E_TMOUT == ercd, "get_blk bad ercd" );
|
CYG_TEST_CHECK( E_TMOUT == ercd, "get_blk bad ercd" );
|
CYG_TEST_CHECK( NULL != vp, "no allocated block to free" );
|
CYG_TEST_CHECK( NULL != vp, "no allocated block to free" );
|
CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" );
|
CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" );
|
break;
|
break;
|
default:
|
default:
|
CYG_TEST_FAIL( "bad switch" );
|
CYG_TEST_FAIL( "bad switch" );
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
void
|
void
|
do_tidyup( WAITOP wait )
|
do_tidyup( WAITOP wait )
|
{
|
{
|
ER ercd;
|
ER ercd;
|
switch ( wait ) {
|
switch ( wait ) {
|
case SLEEP:
|
case SLEEP:
|
case DELAY:
|
case DELAY:
|
case SEMGET:
|
case SEMGET:
|
case MSGGET:
|
case MSGGET:
|
// do nothing for all of those
|
// do nothing for all of those
|
break;
|
break;
|
case FLAGWAIT:
|
case FLAGWAIT:
|
// clear the flag variable
|
// clear the flag variable
|
ercd = clr_flg( 1, 0 );
|
ercd = clr_flg( 1, 0 );
|
CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd, tidy vp" );
|
CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd, tidy vp" );
|
break;
|
break;
|
case MEMFIXEDGET:
|
case MEMFIXEDGET:
|
if ( NULL != vp ) {
|
if ( NULL != vp ) {
|
ercd = rel_blf( 1, vp );
|
ercd = rel_blf( 1, vp );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd, tidy vp" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd, tidy vp" );
|
}
|
}
|
if ( NULL != vp1 ) {
|
if ( NULL != vp1 ) {
|
ercd = rel_blf( 1, vp1 );
|
ercd = rel_blf( 1, vp1 );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd, tidy vp1" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd, tidy vp1" );
|
}
|
}
|
if ( NULL != t2vp ) {
|
if ( NULL != t2vp ) {
|
ercd = rel_blf( 1, t2vp );
|
ercd = rel_blf( 1, t2vp );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd, tidy t2vp" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd, tidy t2vp" );
|
}
|
}
|
break;
|
break;
|
case MEMVARGET:
|
case MEMVARGET:
|
if ( NULL != vp ) {
|
if ( NULL != vp ) {
|
ercd = rel_blk( 1, vp );
|
ercd = rel_blk( 1, vp );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd, tidy vp" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd, tidy vp" );
|
}
|
}
|
if ( NULL != vp1 ) {
|
if ( NULL != vp1 ) {
|
ercd = rel_blk( 1, vp1 );
|
ercd = rel_blk( 1, vp1 );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd, tidy vp1" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd, tidy vp1" );
|
}
|
}
|
if ( NULL != t2vp ) {
|
if ( NULL != t2vp ) {
|
ercd = rel_blk( 1, t2vp );
|
ercd = rel_blk( 1, t2vp );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd, tidy t2vp" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd, tidy t2vp" );
|
}
|
}
|
break;
|
break;
|
default:
|
default:
|
CYG_TEST_FAIL( "bad switch" );
|
CYG_TEST_FAIL( "bad switch" );
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
void
|
void
|
do_recreate( WAITOP wait )
|
do_recreate( WAITOP wait )
|
{
|
{
|
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
|
static T_CSEM t_csem = { NULL, 0, 0 };
|
static T_CSEM t_csem = { NULL, 0, 0 };
|
#endif
|
#endif
|
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
|
static T_CMBX t_cmbx = { NULL, 0 };
|
static T_CMBX t_cmbx = { NULL, 0 };
|
#endif
|
#endif
|
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
|
static T_CFLG t_cflg = { NULL, 0, 0 };
|
static T_CFLG t_cflg = { NULL, 0, 0 };
|
#endif
|
#endif
|
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
static T_CMPF t_cmpf = { NULL, 0, 20, 95 };
|
static T_CMPF t_cmpf = { NULL, 0, 20, 95 };
|
#endif
|
#endif
|
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
static T_CMPL t_cmpl = { NULL, 0, 2000 };
|
static T_CMPL t_cmpl = { NULL, 0, 2000 };
|
#endif
|
#endif
|
ER ercd = E_OK;
|
ER ercd = E_OK;
|
switch ( wait ) {
|
switch ( wait ) {
|
case SLEEP:
|
case SLEEP:
|
case DELAY:
|
case DELAY:
|
// do nothing for all of those
|
// do nothing for all of those
|
break;
|
break;
|
case SEMGET:
|
case SEMGET:
|
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
|
// create the semaphore
|
// create the semaphore
|
ercd = cre_sem( 1, &t_csem );
|
ercd = cre_sem( 1, &t_csem );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_recreate SEMGET" );
|
CYG_TEST_FAIL( "bad call to do_recreate SEMGET" );
|
#endif
|
#endif
|
break;
|
break;
|
case FLAGWAIT:
|
case FLAGWAIT:
|
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
|
// create the flag
|
// create the flag
|
ercd = cre_flg( 1, &t_cflg );
|
ercd = cre_flg( 1, &t_cflg );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_recreate FLAGWAIT" );
|
CYG_TEST_FAIL( "bad call to do_recreate FLAGWAIT" );
|
#endif
|
#endif
|
break;
|
break;
|
case MSGGET:
|
case MSGGET:
|
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
|
// create the mbox
|
// create the mbox
|
ercd = cre_mbx( 1, &t_cmbx );
|
ercd = cre_mbx( 1, &t_cmbx );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_recreate MSGGET" );
|
CYG_TEST_FAIL( "bad call to do_recreate MSGGET" );
|
#endif
|
#endif
|
break;
|
break;
|
case MEMFIXEDGET:
|
case MEMFIXEDGET:
|
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
// create the mempool
|
// create the mempool
|
ercd = cre_mpf( 1, &t_cmpf );
|
ercd = cre_mpf( 1, &t_cmpf );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_recreate MEMFIXEDGET" );
|
CYG_TEST_FAIL( "bad call to do_recreate MEMFIXEDGET" );
|
#endif
|
#endif
|
break;
|
break;
|
case MEMVARGET:
|
case MEMVARGET:
|
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
// create the mempool
|
// create the mempool
|
ercd = cre_mpl( 1, &t_cmpl );
|
ercd = cre_mpl( 1, &t_cmpl );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_recreate MEMVARGET" );
|
CYG_TEST_FAIL( "bad call to do_recreate MEMVARGET" );
|
#endif
|
#endif
|
break;
|
break;
|
default:
|
default:
|
CYG_TEST_FAIL( "bad switch" );
|
CYG_TEST_FAIL( "bad switch" );
|
break;
|
break;
|
}
|
}
|
// this is just to use ercd to prevent warnings
|
// this is just to use ercd to prevent warnings
|
CYG_TEST_CHECK( E_OK == ercd, "<blank> bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "<blank> bad ercd" );
|
}
|
}
|
|
|
|
|
|
|
void
|
void
|
do_signal( WAITOP wait )
|
do_signal( WAITOP wait )
|
{
|
{
|
ER ercd;
|
ER ercd;
|
switch ( wait ) {
|
switch ( wait ) {
|
case SLEEP:
|
case SLEEP:
|
// send a wakeup
|
// send a wakeup
|
ercd = wup_tsk( 2 );
|
ercd = wup_tsk( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
break;
|
break;
|
case DELAY:
|
case DELAY:
|
// simply wait for task 2's delay to complete
|
// simply wait for task 2's delay to complete
|
ercd = dly_tsk( T1_WAIT );
|
ercd = dly_tsk( T1_WAIT );
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
break;
|
break;
|
case SEMGET:
|
case SEMGET:
|
// signal the semaphore
|
// signal the semaphore
|
ercd = sig_sem( 1 );
|
ercd = sig_sem( 1 );
|
CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
|
break;
|
break;
|
case FLAGWAIT:
|
case FLAGWAIT:
|
// set the flag bits
|
// set the flag bits
|
ercd = set_flg( 1, 0xff );
|
ercd = set_flg( 1, 0xff );
|
CYG_TEST_CHECK( E_OK == ercd, "set_flg bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "set_flg bad ercd" );
|
break;
|
break;
|
case MSGGET:
|
case MSGGET:
|
// send a message
|
// send a message
|
ercd = snd_msg( 1, msg );
|
ercd = snd_msg( 1, msg );
|
CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" );
|
break;
|
break;
|
case MEMFIXEDGET:
|
case MEMFIXEDGET:
|
// release a couple of blocks we allocated earlier. I hope.
|
// release a couple of blocks we allocated earlier. I hope.
|
CYG_TEST_CHECK( NULL != vp, "no allocated block to free" );
|
CYG_TEST_CHECK( NULL != vp, "no allocated block to free" );
|
CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" );
|
CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" );
|
ercd = rel_blf( 1, vp );
|
ercd = rel_blf( 1, vp );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
|
vp = NULL;
|
vp = NULL;
|
ercd = rel_blf( 1, vp1 );
|
ercd = rel_blf( 1, vp1 );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd1" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd1" );
|
vp1 = NULL;
|
vp1 = NULL;
|
break;
|
break;
|
case MEMVARGET:
|
case MEMVARGET:
|
// release a couple of blocks we allocated earlier. I hope.
|
// release a couple of blocks we allocated earlier. I hope.
|
CYG_TEST_CHECK( NULL != vp, "no allocated block to free" );
|
CYG_TEST_CHECK( NULL != vp, "no allocated block to free" );
|
CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" );
|
CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" );
|
ercd = rel_blk( 1, vp );
|
ercd = rel_blk( 1, vp );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
|
vp = NULL;
|
vp = NULL;
|
ercd = rel_blk( 1, vp1 );
|
ercd = rel_blk( 1, vp1 );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd1" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd1" );
|
vp1 = NULL;
|
vp1 = NULL;
|
break;
|
break;
|
default:
|
default:
|
CYG_TEST_FAIL( "bad switch" );
|
CYG_TEST_FAIL( "bad switch" );
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
void
|
void
|
do_delete( WAITOP wait )
|
do_delete( WAITOP wait )
|
{
|
{
|
ER ercd = E_OK;
|
ER ercd = E_OK;
|
switch ( wait ) {
|
switch ( wait ) {
|
case SLEEP:
|
case SLEEP:
|
case DELAY:
|
case DELAY:
|
CYG_TEST_FAIL( "bad call to do_delete( SLEEP or DELAY )" );
|
CYG_TEST_FAIL( "bad call to do_delete( SLEEP or DELAY )" );
|
break;
|
break;
|
case SEMGET:
|
case SEMGET:
|
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
|
// delete the semaphore
|
// delete the semaphore
|
ercd = del_sem( 1 );
|
ercd = del_sem( 1 );
|
CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_delete( SEMGET )" );
|
CYG_TEST_FAIL( "bad call to do_delete( SEMGET )" );
|
#endif
|
#endif
|
break;
|
break;
|
case FLAGWAIT:
|
case FLAGWAIT:
|
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
|
// delete the flag
|
// delete the flag
|
ercd = del_flg( 1 );
|
ercd = del_flg( 1 );
|
CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_delete( FLAGWAIT )" );
|
CYG_TEST_FAIL( "bad call to do_delete( FLAGWAIT )" );
|
#endif
|
#endif
|
break;
|
break;
|
case MSGGET:
|
case MSGGET:
|
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
|
// delete the mbox
|
// delete the mbox
|
ercd = del_mbx( 1 );
|
ercd = del_mbx( 1 );
|
CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_delete( MSGGET )" );
|
CYG_TEST_FAIL( "bad call to do_delete( MSGGET )" );
|
#endif
|
#endif
|
break;
|
break;
|
case MEMFIXEDGET:
|
case MEMFIXEDGET:
|
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
// delete the mempool
|
// delete the mempool
|
ercd = del_mpf( 1 );
|
ercd = del_mpf( 1 );
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_delete( MEMFIXEDGET )" );
|
CYG_TEST_FAIL( "bad call to do_delete( MEMFIXEDGET )" );
|
#endif
|
#endif
|
break;
|
break;
|
case MEMVARGET:
|
case MEMVARGET:
|
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
// delete the mempool
|
// delete the mempool
|
ercd = del_mpl( 1 );
|
ercd = del_mpl( 1 );
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
|
#else
|
#else
|
CYG_TEST_FAIL( "bad call to do_delete( MEMVARGET )" );
|
CYG_TEST_FAIL( "bad call to do_delete( MEMVARGET )" );
|
#endif
|
#endif
|
break;
|
break;
|
default:
|
default:
|
CYG_TEST_FAIL( "bad switch" );
|
CYG_TEST_FAIL( "bad switch" );
|
break;
|
break;
|
}
|
}
|
// this is just to use ercd to prevent warnings
|
// this is just to use ercd to prevent warnings
|
CYG_TEST_CHECK( E_OK == ercd, "<blank> bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "<blank> bad ercd" );
|
}
|
}
|
|
|
|
|
|
|
ER
|
ER
|
do_wait( WAITOP wait, WAITTYPE type )
|
do_wait( WAITOP wait, WAITTYPE type )
|
{
|
{
|
switch ( wait ) {
|
switch ( wait ) {
|
case SLEEP:
|
case SLEEP:
|
return ( PLAIN == type ) ? slp_tsk() : tslp_tsk( T2_WAIT );
|
return ( PLAIN == type ) ? slp_tsk() : tslp_tsk( T2_WAIT );
|
case DELAY:
|
case DELAY:
|
return dly_tsk( T2_WAIT ); // forget the type
|
return dly_tsk( T2_WAIT ); // forget the type
|
case SEMGET:
|
case SEMGET:
|
return ( PLAIN == type ) ? wai_sem( 1 ) : twai_sem( 1, T2_WAIT );
|
return ( PLAIN == type ) ? wai_sem( 1 ) : twai_sem( 1, T2_WAIT );
|
case FLAGWAIT:
|
case FLAGWAIT:
|
return ( PLAIN == type ) ?
|
return ( PLAIN == type ) ?
|
wai_flg( &scratch, 1, 0x55, TWF_ANDW ) :
|
wai_flg( &scratch, 1, 0x55, TWF_ANDW ) :
|
twai_flg( &scratch, 1, 0xaa, TWF_ANDW, T2_WAIT );
|
twai_flg( &scratch, 1, 0xaa, TWF_ANDW, T2_WAIT );
|
case MSGGET:
|
case MSGGET:
|
return ( PLAIN == type ) ?
|
return ( PLAIN == type ) ?
|
rcv_msg( &msg1, 1 ) :
|
rcv_msg( &msg1, 1 ) :
|
trcv_msg( &msg1, 1, T2_WAIT );
|
trcv_msg( &msg1, 1, T2_WAIT );
|
case MEMFIXEDGET:
|
case MEMFIXEDGET:
|
return ( PLAIN == type ) ?
|
return ( PLAIN == type ) ?
|
get_blf( &t2vp, 1 ) :
|
get_blf( &t2vp, 1 ) :
|
tget_blf( &t2vp, 1, T2_WAIT );
|
tget_blf( &t2vp, 1, T2_WAIT );
|
case MEMVARGET:
|
case MEMVARGET:
|
return ( PLAIN == type ) ?
|
return ( PLAIN == type ) ?
|
get_blk( &t2vp, 1, T2_MALLOC ) :
|
get_blk( &t2vp, 1, T2_MALLOC ) :
|
tget_blk( &t2vp, 1, T2_MALLOC, T2_WAIT );
|
tget_blk( &t2vp, 1, T2_MALLOC, T2_WAIT );
|
default:
|
default:
|
CYG_TEST_FAIL( "bad switch" );
|
CYG_TEST_FAIL( "bad switch" );
|
break;
|
break;
|
}
|
}
|
CYG_TEST_FAIL( "Bad wait in do_wait" );
|
CYG_TEST_FAIL( "Bad wait in do_wait" );
|
return E_SYS;
|
return E_SYS;
|
}
|
}
|
|
|
// ========================================================================
|
// ========================================================================
|
void task1( unsigned int arg )
|
void task1( unsigned int arg )
|
{
|
{
|
ER ercd;
|
ER ercd;
|
WAITOP wait;
|
WAITOP wait;
|
WAITTYPE type;
|
WAITTYPE type;
|
KILLOP kill;
|
KILLOP kill;
|
|
|
CYG_TEST_INFO( "Task 1 running" );
|
CYG_TEST_INFO( "Task 1 running" );
|
|
|
ercd = chg_pri( 1, 8 );
|
ercd = chg_pri( 1, 8 );
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
|
|
for ( wait = START_WAITOP; wait < DONE_WAITOP ; wait++) {
|
for ( wait = START_WAITOP; wait < DONE_WAITOP ; wait++) {
|
for ( type = START_TYPE; type < DONE_TYPE ; type++ ) {
|
for ( type = START_TYPE; type < DONE_TYPE ; type++ ) {
|
for ( kill = START_KILLOP; kill < DONE_KILLOP ; kill++ ) {
|
for ( kill = START_KILLOP; kill < DONE_KILLOP ; kill++ ) {
|
|
|
// These clauses deal with a couple of special cases:
|
// These clauses deal with a couple of special cases:
|
// [doing it this way helps keep the rest of the code
|
// [doing it this way helps keep the rest of the code
|
// nicely general and orthogonal]
|
// nicely general and orthogonal]
|
//
|
//
|
// 1) DELAY: dly_tsk(): when this times out, the retcode is
|
// 1) DELAY: dly_tsk(): when this times out, the retcode is
|
// E_OK rather than E_TMOUT, and it always times out. The
|
// E_OK rather than E_TMOUT, and it always times out. The
|
// "signalling" method here is just to wait yourself. So we
|
// "signalling" method here is just to wait yourself. So we
|
// do not test DELAY with TIMED type.
|
// do not test DELAY with TIMED type.
|
//
|
//
|
// 2) PLAIN tests with TIMEOUT kill operations: a PLAIN test
|
// 2) PLAIN tests with TIMEOUT kill operations: a PLAIN test
|
// will not time out, it'll wait forever, so waiting for it
|
// will not time out, it'll wait forever, so waiting for it
|
// so to do is pointless; further, we would check for the
|
// so to do is pointless; further, we would check for the
|
// wrong error code. So we do not test PLAIN tests with
|
// wrong error code. So we do not test PLAIN tests with
|
// TIMOUT kill operations.
|
// TIMOUT kill operations.
|
//
|
//
|
// 3) SLEEP or DELAY tests with DELETE operations: there is
|
// 3) SLEEP or DELAY tests with DELETE operations: there is
|
// no synchronization to delete in those cases.
|
// no synchronization to delete in those cases.
|
// 3a) Individual object types are tested for delete support,
|
// 3a) Individual object types are tested for delete support,
|
// and if there is none, the test is skipped.
|
// and if there is none, the test is skipped.
|
|
|
if ( DELAY == wait && TIMED == type )
|
if ( DELAY == wait && TIMED == type )
|
continue;
|
continue;
|
|
|
if ( PLAIN == type &&
|
if ( PLAIN == type &&
|
( ( TIMEOUT == kill) ||
|
( ( TIMEOUT == kill) ||
|
(SUSPEND_TIMEOUT_RESUME == kill) ||
|
(SUSPEND_TIMEOUT_RESUME == kill) ||
|
(SUSPEND_TIMEOUT_KILL == kill) ) )
|
(SUSPEND_TIMEOUT_KILL == kill) ) )
|
continue;
|
continue;
|
|
|
if ( (
|
if ( (
|
#ifndef CYGPKG_UITRON_SEMAS_CREATE_DELETE
|
#ifndef CYGPKG_UITRON_SEMAS_CREATE_DELETE
|
(SEMGET == wait) ||
|
(SEMGET == wait) ||
|
#endif
|
#endif
|
#ifndef CYGPKG_UITRON_FLAGS_CREATE_DELETE
|
#ifndef CYGPKG_UITRON_FLAGS_CREATE_DELETE
|
(FLAGWAIT == wait) ||
|
(FLAGWAIT == wait) ||
|
#endif
|
#endif
|
#ifndef CYGPKG_UITRON_MBOXES_CREATE_DELETE
|
#ifndef CYGPKG_UITRON_MBOXES_CREATE_DELETE
|
(MSGGET == wait) ||
|
(MSGGET == wait) ||
|
#endif
|
#endif
|
#ifndef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
#ifndef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
(MEMFIXEDGET == wait) ||
|
(MEMFIXEDGET == wait) ||
|
#endif
|
#endif
|
#ifndef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
#ifndef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
(MEMVARGET == wait) ||
|
(MEMVARGET == wait) ||
|
#endif
|
#endif
|
(SLEEP == wait) ||
|
(SLEEP == wait) ||
|
(DELAY == wait)
|
(DELAY == wait)
|
) &&
|
) &&
|
((DELETE == kill) ||
|
((DELETE == kill) ||
|
(SUSPEND_DELETE_RESUME == kill) ||
|
(SUSPEND_DELETE_RESUME == kill) ||
|
(SUSPEND_DELETE_KILL == kill)) )
|
(SUSPEND_DELETE_KILL == kill)) )
|
continue;
|
continue;
|
|
|
|
|
CYG_TEST_INFO( makemsg( "T1: ", wait, type, kill ) );
|
CYG_TEST_INFO( makemsg( "T1: ", wait, type, kill ) );
|
|
|
intercom = 0;
|
intercom = 0;
|
|
|
// prepare the synchronization objects
|
// prepare the synchronization objects
|
// (actually, just empty the mempools)
|
// (actually, just empty the mempools)
|
do_prep( wait );
|
do_prep( wait );
|
|
|
// start task 2 at a higher priority than myself
|
// start task 2 at a higher priority than myself
|
ercd = dis_dsp();
|
ercd = dis_dsp();
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
ercd = sta_tsk( 2, task2arg( wait, type, kill ) );
|
ercd = sta_tsk( 2, task2arg( wait, type, kill ) );
|
CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
|
ercd = chg_pri( 2, 5 );
|
ercd = chg_pri( 2, 5 );
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
ercd = ena_dsp();
|
ercd = ena_dsp();
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
// task 2 should run now, until it waits.
|
// task 2 should run now, until it waits.
|
|
|
ercd = ref_tsk( &rtsk, 2 );
|
ercd = ref_tsk( &rtsk, 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( TTS_WAI == rtsk.tskstat, "bad tskstat" );
|
CYG_TEST_CHECK( TTS_WAI == rtsk.tskstat, "bad tskstat" );
|
CYG_TEST_CHECK( 5 == rtsk.tskpri, "bad tskpri" );
|
CYG_TEST_CHECK( 5 == rtsk.tskpri, "bad tskpri" );
|
|
|
switch ( kill ) {
|
switch ( kill ) {
|
case SIGNAL:
|
case SIGNAL:
|
// signal the task appropriately
|
// signal the task appropriately
|
do_signal( wait );
|
do_signal( wait );
|
// it should now have run to completion
|
// it should now have run to completion
|
break;
|
break;
|
case TIMEOUT:
|
case TIMEOUT:
|
// wait for the timeout to occur
|
// wait for the timeout to occur
|
ercd = dly_tsk( T1_WAIT );
|
ercd = dly_tsk( T1_WAIT );
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
// it should now have run to completion
|
// it should now have run to completion
|
break;
|
break;
|
case RELEASE:
|
case RELEASE:
|
// hit the task with a release-wait
|
// hit the task with a release-wait
|
ercd = rel_wai( 2 );
|
ercd = rel_wai( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_wai bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_wai bad ercd" );
|
// it should now have run to completion
|
// it should now have run to completion
|
break;
|
break;
|
case DELETE:
|
case DELETE:
|
// delete the object appropriately
|
// delete the object appropriately
|
do_delete( wait );
|
do_delete( wait );
|
// it should now have run to completion
|
// it should now have run to completion
|
break;
|
break;
|
case KILL:
|
case KILL:
|
// kill the task
|
// kill the task
|
ercd = ter_tsk( 2 );
|
ercd = ter_tsk( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
// it should now have terminated without running
|
// it should now have terminated without running
|
break;
|
break;
|
case SUSPEND_SIGNAL_RESUME:
|
case SUSPEND_SIGNAL_RESUME:
|
// suspend the task
|
// suspend the task
|
do_suspend();
|
do_suspend();
|
// signal the task appropriately
|
// signal the task appropriately
|
do_signal( wait );
|
do_signal( wait );
|
// resume the task
|
// resume the task
|
do_resume();
|
do_resume();
|
// it should now have run to completion
|
// it should now have run to completion
|
break;
|
break;
|
case SUSPEND_TIMEOUT_RESUME:
|
case SUSPEND_TIMEOUT_RESUME:
|
// suspend the task
|
// suspend the task
|
do_suspend();
|
do_suspend();
|
// wait for the timeout to occur
|
// wait for the timeout to occur
|
ercd = dly_tsk( T1_WAIT );
|
ercd = dly_tsk( T1_WAIT );
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
// resume the task
|
// resume the task
|
do_resume();
|
do_resume();
|
// it should now have run to completion
|
// it should now have run to completion
|
break;
|
break;
|
case SUSPEND_RELEASE_RESUME:
|
case SUSPEND_RELEASE_RESUME:
|
// suspend the task
|
// suspend the task
|
do_suspend();
|
do_suspend();
|
// hit the task with a release-wait
|
// hit the task with a release-wait
|
ercd = rel_wai( 2 );
|
ercd = rel_wai( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_wai bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_wai bad ercd" );
|
// resume the task
|
// resume the task
|
do_resume();
|
do_resume();
|
// it should now have run to completion
|
// it should now have run to completion
|
break;
|
break;
|
case SUSPEND_DELETE_RESUME:
|
case SUSPEND_DELETE_RESUME:
|
// suspend the task
|
// suspend the task
|
do_suspend();
|
do_suspend();
|
// delete the object appropriately
|
// delete the object appropriately
|
do_delete( wait );
|
do_delete( wait );
|
// resume the task
|
// resume the task
|
do_resume();
|
do_resume();
|
// it should now have run to completion
|
// it should now have run to completion
|
break;
|
break;
|
case SUSPEND_KILL:
|
case SUSPEND_KILL:
|
// suspend the task
|
// suspend the task
|
do_suspend();
|
do_suspend();
|
// kill the task
|
// kill the task
|
ercd = ter_tsk( 2 );
|
ercd = ter_tsk( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
// it should now have terminated without running
|
// it should now have terminated without running
|
break;
|
break;
|
case SUSPEND_SIGNAL_KILL:
|
case SUSPEND_SIGNAL_KILL:
|
// suspend the task
|
// suspend the task
|
do_suspend();
|
do_suspend();
|
// signal the task appropriately
|
// signal the task appropriately
|
do_signal( wait );
|
do_signal( wait );
|
// kill the task
|
// kill the task
|
ercd = ter_tsk( 2 );
|
ercd = ter_tsk( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
// it should now have terminated without running
|
// it should now have terminated without running
|
break;
|
break;
|
case SUSPEND_TIMEOUT_KILL:
|
case SUSPEND_TIMEOUT_KILL:
|
// suspend the task
|
// suspend the task
|
do_suspend();
|
do_suspend();
|
// wait for the timeout to occur
|
// wait for the timeout to occur
|
ercd = dly_tsk( T1_WAIT );
|
ercd = dly_tsk( T1_WAIT );
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
// kill the task
|
// kill the task
|
ercd = ter_tsk( 2 );
|
ercd = ter_tsk( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
// it should now have terminated without running
|
// it should now have terminated without running
|
break;
|
break;
|
case SUSPEND_RELEASE_KILL:
|
case SUSPEND_RELEASE_KILL:
|
// suspend the task
|
// suspend the task
|
do_suspend();
|
do_suspend();
|
// hit the task with a release-wait
|
// hit the task with a release-wait
|
ercd = rel_wai( 2 );
|
ercd = rel_wai( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_wai bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "rel_wai bad ercd" );
|
// kill the task
|
// kill the task
|
ercd = ter_tsk( 2 );
|
ercd = ter_tsk( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
// it should now have terminated without running
|
// it should now have terminated without running
|
break;
|
break;
|
case SUSPEND_DELETE_KILL:
|
case SUSPEND_DELETE_KILL:
|
// suspend the task
|
// suspend the task
|
do_suspend();
|
do_suspend();
|
// delete the object appropriately
|
// delete the object appropriately
|
do_delete( wait );
|
do_delete( wait );
|
// kill the task
|
// kill the task
|
ercd = ter_tsk( 2 );
|
ercd = ter_tsk( 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
// it should now have terminated without running
|
// it should now have terminated without running
|
break;
|
break;
|
default:
|
default:
|
CYG_TEST_FAIL( "bad switch" );
|
CYG_TEST_FAIL( "bad switch" );
|
break;
|
break;
|
}
|
}
|
|
|
// task 2 should be dormant now, however it got there
|
// task 2 should be dormant now, however it got there
|
ercd = ref_tsk( &rtsk, 2 );
|
ercd = ref_tsk( &rtsk, 2 );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
CYG_TEST_CHECK( TTS_DMT == rtsk.tskstat, "bad tskstat" );
|
CYG_TEST_CHECK( TTS_DMT == rtsk.tskstat, "bad tskstat" );
|
|
|
if ( (SUSPEND_SIGNAL_KILL == kill) &&
|
if ( (SUSPEND_SIGNAL_KILL == kill) &&
|
((MEMFIXEDGET == wait) || (MEMVARGET == wait)) ) {
|
((MEMFIXEDGET == wait) || (MEMVARGET == wait)) ) {
|
// it was a killed successful memory alloc, so we have
|
// it was a killed successful memory alloc, so we have
|
// lost the pointer to memory allocated; there is an
|
// lost the pointer to memory allocated; there is an
|
// implicit storeleak problem when the task trying
|
// implicit storeleak problem when the task trying
|
// to allocate is signalled then killed.
|
// to allocate is signalled then killed.
|
// Recreate the pointer from an old version:
|
// Recreate the pointer from an old version:
|
CYG_TEST_CHECK( NULL == t2vp, "t2vp WAS allocated!" );
|
CYG_TEST_CHECK( NULL == t2vp, "t2vp WAS allocated!" );
|
t2vp = t2vp_backup;
|
t2vp = t2vp_backup;
|
}
|
}
|
|
|
switch ( kill ) {
|
switch ( kill ) {
|
case KILL:
|
case KILL:
|
case SUSPEND_KILL:
|
case SUSPEND_KILL:
|
case SUSPEND_SIGNAL_KILL:
|
case SUSPEND_SIGNAL_KILL:
|
case SUSPEND_TIMEOUT_KILL:
|
case SUSPEND_TIMEOUT_KILL:
|
case SUSPEND_RELEASE_KILL:
|
case SUSPEND_RELEASE_KILL:
|
case SUSPEND_DELETE_KILL:
|
case SUSPEND_DELETE_KILL:
|
// if task 2 was killed, expect only one increment
|
// if task 2 was killed, expect only one increment
|
CYG_TEST_CHECK( 1 == intercom, "intercom bad value !1" );
|
CYG_TEST_CHECK( 1 == intercom, "intercom bad value !1" );
|
break;
|
break;
|
default:
|
default:
|
// otherwise expect two increments
|
// otherwise expect two increments
|
CYG_TEST_CHECK( 2 == intercom, "intercom bad value !2" );
|
CYG_TEST_CHECK( 2 == intercom, "intercom bad value !2" );
|
break;
|
break;
|
}
|
}
|
|
|
// tidy up or recreate the synchronization objects
|
// tidy up or recreate the synchronization objects
|
if ( (DELETE == kill) ||
|
if ( (DELETE == kill) ||
|
(SUSPEND_DELETE_RESUME == kill) ||
|
(SUSPEND_DELETE_RESUME == kill) ||
|
(SUSPEND_DELETE_KILL == kill) )
|
(SUSPEND_DELETE_KILL == kill) )
|
do_recreate( wait );
|
do_recreate( wait );
|
else
|
else
|
do_tidyup( wait );
|
do_tidyup( wait );
|
}
|
}
|
}
|
}
|
}
|
}
|
CYG_TEST_PASS("synchronization interaction tests");
|
CYG_TEST_PASS("synchronization interaction tests");
|
|
|
// all done
|
// all done
|
CYG_TEST_EXIT( "All done" );
|
CYG_TEST_EXIT( "All done" );
|
ext_tsk();
|
ext_tsk();
|
}
|
}
|
|
|
|
|
|
|
void task2( unsigned int arg )
|
void task2( unsigned int arg )
|
{
|
{
|
ER ercd;
|
ER ercd;
|
WAITOP wait;
|
WAITOP wait;
|
WAITTYPE waittype;
|
WAITTYPE waittype;
|
KILLOP kill;
|
KILLOP kill;
|
|
|
decodearg( arg, &wait, &waittype, &kill );
|
decodearg( arg, &wait, &waittype, &kill );
|
|
|
// CYG_TEST_INFO( makemsg( " 2: ", wait, waittype, kill ) );
|
// CYG_TEST_INFO( makemsg( " 2: ", wait, waittype, kill ) );
|
|
|
intercom++;
|
intercom++;
|
ercd = do_wait( wait, waittype );
|
ercd = do_wait( wait, waittype );
|
intercom++;
|
intercom++;
|
|
|
switch ( kill ) {
|
switch ( kill ) {
|
case SIGNAL:
|
case SIGNAL:
|
case SUSPEND_SIGNAL_RESUME:
|
case SUSPEND_SIGNAL_RESUME:
|
// we expect to have been signalled correctly
|
// we expect to have been signalled correctly
|
CYG_TEST_CHECK( E_OK == ercd, "T2 wait bad ercd" );
|
CYG_TEST_CHECK( E_OK == ercd, "T2 wait bad ercd" );
|
// here we know that the op completed OK
|
// here we know that the op completed OK
|
if ( (MEMFIXEDGET == wait) || (MEMVARGET == wait) ) {
|
if ( (MEMFIXEDGET == wait) || (MEMVARGET == wait) ) {
|
// it was a successful memory alloc of whichever type,
|
// it was a successful memory alloc of whichever type,
|
// so we can save away a copy of t2vp for working round an
|
// so we can save away a copy of t2vp for working round an
|
// implicit storeleak problem when the task trying to allocate
|
// implicit storeleak problem when the task trying to allocate
|
// is signalled then killed:
|
// is signalled then killed:
|
CYG_TEST_CHECK( NULL != t2vp, "No t2vp allocated!" );
|
CYG_TEST_CHECK( NULL != t2vp, "No t2vp allocated!" );
|
t2vp_backup = t2vp;
|
t2vp_backup = t2vp;
|
}
|
}
|
break;
|
break;
|
case TIMEOUT:
|
case TIMEOUT:
|
case SUSPEND_TIMEOUT_RESUME:
|
case SUSPEND_TIMEOUT_RESUME:
|
// we expect to have timed out - if it's a timeout op.
|
// we expect to have timed out - if it's a timeout op.
|
CYG_TEST_CHECK( E_TMOUT == ercd, "T2 timeout bad ercd, !E_TMOUT" );
|
CYG_TEST_CHECK( E_TMOUT == ercd, "T2 timeout bad ercd, !E_TMOUT" );
|
break;
|
break;
|
case RELEASE:
|
case RELEASE:
|
case SUSPEND_RELEASE_RESUME:
|
case SUSPEND_RELEASE_RESUME:
|
// we expect to have suffered a release wait.
|
// we expect to have suffered a release wait.
|
CYG_TEST_CHECK( E_RLWAI == ercd, "T2 release bad ercd, !E_RLWAI" );
|
CYG_TEST_CHECK( E_RLWAI == ercd, "T2 release bad ercd, !E_RLWAI" );
|
break;
|
break;
|
case DELETE:
|
case DELETE:
|
case SUSPEND_DELETE_RESUME:
|
case SUSPEND_DELETE_RESUME:
|
// we expect to be told the object is gone
|
// we expect to be told the object is gone
|
CYG_TEST_CHECK( E_DLT == ercd, "T2 release bad ercd, !E_DLT" );
|
CYG_TEST_CHECK( E_DLT == ercd, "T2 release bad ercd, !E_DLT" );
|
break;
|
break;
|
case KILL:
|
case KILL:
|
case SUSPEND_KILL:
|
case SUSPEND_KILL:
|
case SUSPEND_SIGNAL_KILL:
|
case SUSPEND_SIGNAL_KILL:
|
case SUSPEND_TIMEOUT_KILL:
|
case SUSPEND_TIMEOUT_KILL:
|
case SUSPEND_RELEASE_KILL:
|
case SUSPEND_RELEASE_KILL:
|
case SUSPEND_DELETE_KILL:
|
case SUSPEND_DELETE_KILL:
|
// we expect to have been killed here, ie. this won't execute!
|
// we expect to have been killed here, ie. this won't execute!
|
CYG_TEST_FAIL( "Task 2 ran to completion!" );
|
CYG_TEST_FAIL( "Task 2 ran to completion!" );
|
break;
|
break;
|
default:
|
default:
|
CYG_TEST_FAIL( "bad switch" );
|
CYG_TEST_FAIL( "bad switch" );
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
void task3( unsigned int arg )
|
void task3( unsigned int arg )
|
{
|
{
|
}
|
}
|
|
|
void task4( unsigned int arg )
|
void task4( unsigned int arg )
|
{
|
{
|
}
|
}
|
|
|
#else // not enough (or too many) uITRON objects configured in
|
#else // not enough (or too many) uITRON objects configured in
|
#define N_A_MSG "not enough uITRON objects to run test"
|
#define N_A_MSG "not enough uITRON objects to run test"
|
#endif // not enough (or too many) uITRON objects configured in
|
#endif // not enough (or too many) uITRON objects configured in
|
#else // not C++ and some C++ specific options enabled
|
#else // not C++ and some C++ specific options enabled
|
#define N_A_MSG "C++ specific options selected but this is C"
|
#define N_A_MSG "C++ specific options selected but this is C"
|
#endif // not C++ and some C++ specific options enabled
|
#endif // not C++ and some C++ specific options enabled
|
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
|
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
|
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
#else // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
#else // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
|
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
|
#endif // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
#endif // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
#else // ! CYGIMP_THREAD_PRIORITY - can't test without it
|
#else // ! CYGIMP_THREAD_PRIORITY - can't test without it
|
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
|
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
|
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE - can't test without it
|
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE - can't test without it
|
#else // ! CYGPKG_UITRON
|
#else // ! CYGPKG_UITRON
|
#define N_A_MSG "uITRON Compatibility layer disabled"
|
#define N_A_MSG "uITRON Compatibility layer disabled"
|
#endif // CYGPKG_UITRON
|
#endif // CYGPKG_UITRON
|
|
|
#ifdef N_A_MSG
|
#ifdef N_A_MSG
|
void
|
void
|
cyg_start( void )
|
cyg_start( void )
|
{
|
{
|
CYG_TEST_INIT();
|
CYG_TEST_INIT();
|
CYG_TEST_NA( N_A_MSG );
|
CYG_TEST_NA( N_A_MSG );
|
}
|
}
|
#endif // N_A_MSG defined ie. we are N/A.
|
#endif // N_A_MSG defined ie. we are N/A.
|
|
|
// EOF test7.c
|
// EOF test7.c
|
|
|