diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-11-16 14:50:09 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-11-23 12:52:06 +0100 |
commit | c42be504c92d76d2e06d0fc8ebd05fc913376d2d (patch) | |
tree | 259f8a712a6139f427888647955bc3c95480877e /testsuites | |
parent | score: Add RTEMS_ALIAS() (diff) | |
download | rtems-c42be504c92d76d2e06d0fc8ebd05fc913376d2d.tar.bz2 |
posix: Add self-contained pthread spinlock
Turn pthread_spinlock_t into a self-contained object. On uni-processor
configurations, interrupts are disabled in the lock/trylock operations
and the previous interrupt status is restored in the corresponding
unlock operations. On SMP configurations, a ticket lock is a acquired
and released in addition.
The self-contained pthread_spinlock_t object is defined by Newlib in
<sys/_pthreadtypes.h>.
typedef struct {
struct _Ticket_lock_Control _lock;
__uint32_t _interrupt_state;
} pthread_spinlock_t;
This implementation is simple and efficient. However, this test case of
the Linux Test Project would fail due to call of printf() and sleep()
during spin lock ownership:
https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_lock/1-2.c
There is only limited support for profiling on SMP configurations.
Delete CORE spinlock implementation.
Update #2674.
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/psxtests/Makefile.am | 2 | ||||
-rw-r--r-- | testsuites/psxtests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/psxtests/psxconfig01/init.c | 13 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin01/main.c | 2 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin01/psxspin01.scn | 46 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin01/test.c | 196 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/Makefile.am | 24 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/main.c | 59 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/psxspin02.doc | 25 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/psxspin02.scn | 8 | ||||
-rw-r--r-- | testsuites/psxtests/psxspin02/test.c | 108 | ||||
-rw-r--r-- | testsuites/sptests/spsysinit01/init.c | 17 |
12 files changed, 67 insertions, 434 deletions
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index a3bffb900f..0ff5cb300e 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -11,7 +11,7 @@ _SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \ psxitimer psxmsgq01 psxmsgq02 psxmsgq03 psxmsgq04 \ psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxsignal01 psxsignal02 \ psxsignal03 psxsignal04 psxsignal05 psxsignal06 \ - psxspin01 psxspin02 psxsysconf \ + psxspin01 psxsysconf \ psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \ psxintrcritical01 psxstack01 psxstack02 \ psxeintr_join psxgetattrnp01 psxclock01 diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index be4a21f6c7..29f9a192fa 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -197,7 +197,6 @@ psxsignal04/Makefile psxsignal05/Makefile psxsignal06/Makefile psxspin01/Makefile -psxspin02/Makefile psxstack01/Makefile psxstack02/Makefile psxstat/Makefile diff --git a/testsuites/psxtests/psxconfig01/init.c b/testsuites/psxtests/psxconfig01/init.c index 582fd11197..1513b54d73 100644 --- a/testsuites/psxtests/psxconfig01/init.c +++ b/testsuites/psxtests/psxconfig01/init.c @@ -67,7 +67,6 @@ const char rtems_test_name[] = "PSXCONFIG 1"; #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 7 #define CONFIGURE_MAXIMUM_POSIX_RWLOCKS 31 #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 41 -#define CONFIGURE_MAXIMUM_POSIX_SPINLOCKS 17 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION #define CONFIGURE_MAXIMUM_POSIX_THREADS 3 @@ -515,18 +514,6 @@ static rtems_task Init(rtems_task_argument argument) ); #endif -#ifdef CONFIGURE_MAXIMUM_POSIX_SPINLOCKS - for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_SPINLOCKS; ++i) { - pthread_spinlock_t spinlock; - eno = pthread_spin_init(&spinlock, 0); - rtems_test_assert(eno == 0); - } - rtems_resource_snapshot_take(&snapshot); - rtems_test_assert( - snapshot.posix_api.active_spinlocks == CONFIGURE_MAXIMUM_POSIX_SPINLOCKS - ); -#endif - #ifdef CONFIGURE_MAXIMUM_POSIX_THREADS for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_THREADS; ++i) { pthread_t thread; diff --git a/testsuites/psxtests/psxspin01/main.c b/testsuites/psxtests/psxspin01/main.c index 6793784f75..4c3bc27fc5 100644 --- a/testsuites/psxtests/psxspin01/main.c +++ b/testsuites/psxtests/psxspin01/main.c @@ -41,8 +41,6 @@ rtems_task Init( #define CONFIGURE_MAXIMUM_TASKS 2 -#define CONFIGURE_MAXIMUM_POSIX_SPINLOCKS 1 - #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION #define CONFIGURE_RTEMS_INIT_TASKS_TABLE diff --git a/testsuites/psxtests/psxspin01/psxspin01.scn b/testsuites/psxtests/psxspin01/psxspin01.scn index 5c0e752969..dae970f1a0 100644 --- a/testsuites/psxtests/psxspin01/psxspin01.scn +++ b/testsuites/psxtests/psxspin01/psxspin01.scn @@ -1,32 +1,18 @@ *** BEGIN OF TEST PSXSPIN 1 *** -pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ) -- EINVAL -pthread_spin_init( NULL, PTHREAD_PROCESS_SHARED ) -- EINVAL -pthread_spin_init( &spinlock, 0x1234 ) -- EINVAL -pthread_spin_init( &spinlock, PTHREAD_PROCESS_SHARED ) -- EINVAL -pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK -pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- EAGAIN -pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- EAGAIN -pthread_spin_lock( NULL ) -- EINVAL -pthread_spin_trylock( NULL ) -- EINVAL -pthread_spin_unlock( NULL ) -- EINVAL -pthread_spin_destroy( NULL ) -- EINVAL -pthread_spin_lock( &spinlock ) -- EINVAL -pthread_spin_trylock( &spinlock ) -- EINVAL -pthread_spin_unlock( &spinlock ) -- EINVAL -pthread_spin_destroy( &spinlock ) -- EINVAL -pthread_spin_unlock( &Spinlock ) -- EPERM -pthread_spin_lock( &Spinlock ) -- OK -pthread_spin_lock( &Spinlock ) -- EDEADLK -pthread_spin_trylock( &Spinlock ) -- EDEADLK -pthread_spin_unlock( &Spinlock ) -- OK -pthread_spin_trylock( &Spinlock ) -- OK -pthread_spin_unlock( &Spinlock ) -- OK -pthread_spin_lock( &Spinlock ) from Thread -- OK -sleep to allow main thread to run -pthread_spin_unlock( &Spinlock ) -- EPERM -pthread_spin_lock( &Spinlock ) -- OK -pthread_spin_unlock( &Spinlock ) from Thread -- OK -pthread_spin_destroy( &Spinlock ) -- EBUSY -pthread_spin_unlock( &Spinlock ) -- OK -pthread_spin_destroy( &Spinlock ) -- OK +pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK +pthread_spin_destroy( &spinlock ) -- OK +pthread_spin_init( &spinlock, PTHREAD_PROCESS_SHARED ) -- OK +pthread_spin_destroy( &spinlock ) -- OK +pthread_spin_init( &spinlock, 0x1234 ) -- OK +pthread_spin_init( &spinlock2, 0 ) -- OK +pthread_spin_lock( &spinlock ) -- OK +pthread_spin_lock( &spinlock2 ) -- OK +pthread_spin_unlock( &spinlock2 ) -- OK +pthread_spin_unlock( &spinlock ) -- OK +pthread_spin_trylock( &spinlock ) -- OK +pthread_spin_trylock( &spinlock2 ) -- OK +pthread_spin_unlock( &spinlock2 ) -- OK +pthread_spin_unlock( &spinlock ) -- OK +pthread_spin_destroy( &spinlock2 ) -- OK +pthread_spin_destroy( &spinlock ) -- OK *** END OF TEST PSXSPIN 1 *** diff --git a/testsuites/psxtests/psxspin01/test.c b/testsuites/psxtests/psxspin01/test.c index 270cdcfc86..33153addda 100644 --- a/testsuites/psxtests/psxspin01/test.c +++ b/testsuites/psxtests/psxspin01/test.c @@ -17,6 +17,7 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK #include "tmacros.h" #include <stdio.h> #include <errno.h> @@ -30,38 +31,6 @@ const char rtems_test_name[] = "PSXSPIN 1"; /* forward declarations to avoid warnings */ int test_main(void); -rtems_task SpinlockThread(rtems_task_argument arg); - -pthread_spinlock_t Spinlock; - -volatile int mainThreadSpinning; - -rtems_task SpinlockThread(rtems_task_argument arg) -{ - int status; - - if ( mainThreadSpinning ) { - puts( "main thread is not supposed to be spinning yet" ); - exit(0); - } - puts( "pthread_spin_lock( &Spinlock ) from Thread -- OK" ); - status = pthread_spin_lock( &Spinlock ); - rtems_test_assert( status == 0 ); - - puts( "sleep to allow main thread to run" ); - sleep( 1 ); - - if ( !mainThreadSpinning ) { - puts( "main thread is not spinning on lock" ); - exit(0); - } - - puts( "pthread_spin_unlock( &Spinlock ) from Thread -- OK" ); - status = pthread_spin_unlock( &Spinlock ); - rtems_test_assert( status == 0 ); - - rtems_task_delete( RTEMS_SELF ); -} /* * main entry point to the test @@ -77,158 +46,93 @@ int main( #endif { pthread_spinlock_t spinlock; + pthread_spinlock_t spinlock2; int status; - rtems_status_code rstatus; - rtems_id taskid; TEST_BEGIN(); - puts( "pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ) -- EINVAL" ); - status = pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ); - rtems_test_assert( status == EINVAL ); - - puts( "pthread_spin_init( NULL, PTHREAD_PROCESS_SHARED ) -- EINVAL" ); - status = pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ); - rtems_test_assert( status == EINVAL ); - - puts( "pthread_spin_init( &spinlock, 0x1234 ) -- EINVAL" ); - status = pthread_spin_init( &spinlock, 0x1234 ); - rtems_test_assert( status == EINVAL ); - - puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_SHARED ) -- EINVAL" ); - status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_SHARED ); - rtems_test_assert( status == EINVAL ); - - /* This successfully creates one */ - puts( "pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK" ); - status = pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ); + puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK" ); + status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ); rtems_test_assert( status == 0 ); - puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- EAGAIN" ); - status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ); - rtems_test_assert( status == EAGAIN ); + puts( "pthread_spin_destroy( &spinlock ) -- OK" ); + status = pthread_spin_destroy( &spinlock ); + rtems_test_assert( status == 0 ); - puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- EAGAIN" ); + puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_SHARED ) -- OK" ); status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ); - rtems_test_assert( status == EAGAIN ); - - puts( "pthread_spin_lock( NULL ) -- EINVAL" ); - status = pthread_spin_lock( NULL ); - rtems_test_assert( status == EINVAL ); + rtems_test_assert( status == 0 ); - puts( "pthread_spin_trylock( NULL ) -- EINVAL" ); - status = pthread_spin_trylock( NULL ); - rtems_test_assert( status == EINVAL ); + puts( "pthread_spin_destroy( &spinlock ) -- OK" ); + status = pthread_spin_destroy( &spinlock ); + rtems_test_assert( status == 0 ); - puts( "pthread_spin_unlock( NULL ) -- EINVAL" ); - status = pthread_spin_unlock( NULL ); - rtems_test_assert( status == EINVAL ); + puts( "pthread_spin_init( &spinlock, 0x1234 ) -- OK" ); + status = pthread_spin_init( &spinlock, 0x1234 ); + rtems_test_assert( status == 0 ); - puts( "pthread_spin_destroy( NULL ) -- EINVAL" ); - status = pthread_spin_destroy( NULL ); - rtems_test_assert( status == EINVAL ); + puts( "pthread_spin_init( &spinlock2, 0 ) -- OK" ); + status = pthread_spin_init( &spinlock2, 0 ); + rtems_test_assert( status == 0 ); - spinlock = 0; + rtems_test_assert( _ISR_Get_level() == 0 ); - puts( "pthread_spin_lock( &spinlock ) -- EINVAL" ); + puts( "pthread_spin_lock( &spinlock ) -- OK" ); status = pthread_spin_lock( &spinlock ); - rtems_test_assert( status == EINVAL ); + rtems_test_assert( status == 0 ); - puts( "pthread_spin_trylock( &spinlock ) -- EINVAL" ); - status = pthread_spin_trylock( &spinlock ); - rtems_test_assert( status == EINVAL ); + rtems_test_assert( _ISR_Get_level() != 0 ); - puts( "pthread_spin_unlock( &spinlock ) -- EINVAL" ); - status = pthread_spin_unlock( &spinlock ); - rtems_test_assert( status == EINVAL ); - - puts( "pthread_spin_destroy( &spinlock ) -- EINVAL" ); - status = pthread_spin_destroy( &spinlock ); - rtems_test_assert( status == EINVAL ); + puts( "pthread_spin_lock( &spinlock2 ) -- OK" ); + status = pthread_spin_lock( &spinlock2 ); + rtems_test_assert( status == 0 ); - puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" ); - status = pthread_spin_unlock( &Spinlock ); - rtems_test_assert( status == EPERM ); + rtems_test_assert( _ISR_Get_level() != 0 ); - /* Now some basic locking and unlocking with a deadlock verification */ - puts( "pthread_spin_lock( &Spinlock ) -- OK" ); - status = pthread_spin_lock( &Spinlock ); + puts( "pthread_spin_unlock( &spinlock2 ) -- OK" ); + status = pthread_spin_unlock( &spinlock2 ); rtems_test_assert( status == 0 ); - puts( "pthread_spin_lock( &Spinlock ) -- EDEADLK" ); - status = pthread_spin_lock( &Spinlock ); - rtems_test_assert( status == EDEADLK ); - - puts( "pthread_spin_trylock( &Spinlock ) -- EDEADLK" ); - status = pthread_spin_trylock( &Spinlock ); - rtems_test_assert( status == EDEADLK ); + rtems_test_assert( _ISR_Get_level() != 0 ); - puts( "pthread_spin_unlock( &Spinlock ) -- OK" ); - status = pthread_spin_unlock( &Spinlock ); + puts( "pthread_spin_unlock( &spinlock ) -- OK" ); + status = pthread_spin_unlock( &spinlock ); rtems_test_assert( status == 0 ); - /* Try lock/unlock pair */ - puts( "pthread_spin_trylock( &Spinlock ) -- OK" ); - status = pthread_spin_trylock( &Spinlock ); - rtems_test_assert( status == 0 ); + rtems_test_assert( _ISR_Get_level() == 0 ); - puts( "pthread_spin_unlock( &Spinlock ) -- OK" ); - status = pthread_spin_unlock( &Spinlock ); + puts( "pthread_spin_trylock( &spinlock ) -- OK" ); + status = pthread_spin_trylock( &spinlock ); rtems_test_assert( status == 0 ); - /* Let another thread lock a spinlock and we contend with it */ - - mainThreadSpinning = 0; + rtems_test_assert( _ISR_Get_level() != 0 ); - /* Create a helper task */ - rstatus = rtems_task_create( - rtems_build_name( 'S', 'P', 'I', 'N' ), - 1, - RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, - &taskid - ); - rtems_test_assert( rstatus == RTEMS_SUCCESSFUL ); + puts( "pthread_spin_trylock( &spinlock2 ) -- OK" ); + status = pthread_spin_trylock( &spinlock2 ); + rtems_test_assert( status == 0 ); - rstatus = rtems_task_start( taskid, SpinlockThread, 0 ); - rtems_test_assert( rstatus == RTEMS_SUCCESSFUL ); - /* We should be preempted immediately. The thread is expected to: - * + verify we haven't set the main thread spinning flag - * + lock the spinlock - * + delay - */ + rtems_test_assert( _ISR_Get_level() != 0 ); - mainThreadSpinning = 1; + puts( "pthread_spin_unlock( &spinlock2 ) -- OK" ); + status = pthread_spin_unlock( &spinlock2 ); + rtems_test_assert( status == 0 ); - puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" ); - status = pthread_spin_unlock( &Spinlock ); - rtems_test_assert( status == EPERM ); + rtems_test_assert( _ISR_Get_level() != 0 ); - puts( "pthread_spin_lock( &Spinlock ) -- OK" ); - status = pthread_spin_lock( &Spinlock ); + puts( "pthread_spin_unlock( &spinlock ) -- OK" ); + status = pthread_spin_unlock( &spinlock ); rtems_test_assert( status == 0 ); - /* The thread wakes up, unlocks spin lock, and deletes itself. - * So when we get back here, about a second has passed and we now - * have the spinlock locked. - */ + rtems_test_assert( _ISR_Get_level() == 0 ); - /* spin lock should be locked when we return so destroying it gives busy */ - puts( "pthread_spin_destroy( &Spinlock ) -- EBUSY" ); - status = pthread_spin_destroy( &Spinlock ); - rtems_test_assert( status == EBUSY ); - - /* Unlock it for a normal destroy */ - puts( "pthread_spin_unlock( &Spinlock ) -- OK" ); - status = pthread_spin_unlock( &Spinlock ); + puts( "pthread_spin_destroy( &spinlock2 ) -- OK" ); + status = pthread_spin_destroy( &spinlock2 ); rtems_test_assert( status == 0 ); - puts( "pthread_spin_destroy( &Spinlock ) -- OK" ); - status = pthread_spin_destroy( &Spinlock ); + puts( "pthread_spin_destroy( &spinlock ) -- OK" ); + status = pthread_spin_destroy( &spinlock ); rtems_test_assert( status == 0 ); - /*************** END OF TEST *****************/ TEST_END(); exit(0); } diff --git a/testsuites/psxtests/psxspin02/Makefile.am b/testsuites/psxtests/psxspin02/Makefile.am deleted file mode 100644 index ad56e2ae28..0000000000 --- a/testsuites/psxtests/psxspin02/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ - -rtems_tests_PROGRAMS = psxspin02 -psxspin02_SOURCES = main.c test.c ../include/pmacros.h - -dist_rtems_tests_DATA = psxspin02.scn -dist_rtems_tests_DATA += psxspin02.doc - -include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg -include $(top_srcdir)/../automake/compile.am -include $(top_srcdir)/../automake/leaf.am - - -AM_CPPFLAGS += -I$(top_srcdir)/include -AM_CPPFLAGS += -I$(top_srcdir)/../support/include - -LINK_OBJS = $(psxspin02_OBJECTS) -LINK_LIBS = $(psxspin02_LDLIBS) - -psxspin02$(EXEEXT): $(psxspin02_OBJECTS) \ - $(psxspin02_DEPENDENCIES) - @rm -f psxspin02$(EXEEXT) - $(make-exe) - -include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psxspin02/main.c b/testsuites/psxtests/psxspin02/main.c deleted file mode 100644 index 15eb51ea6c..0000000000 --- a/testsuites/psxtests/psxspin02/main.c +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file - * - * Simple test program wrapper for Spinlocks - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#define CONFIGURE_INIT - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <bsp.h> -#include <pmacros.h> - -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument ignored); -void test_main(void); - -rtems_task Init( - rtems_task_argument ignored -) -{ - test_main(); - rtems_test_exit( 0 ); -} - -/* configuration information */ - -#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER -#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER - -#define CONFIGURE_MAXIMUM_TASKS 2 - -#define CONFIGURE_MAXIMUM_POSIX_SPINLOCKS 1 - -#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION - -#define CONFIGURE_RTEMS_INIT_TASKS_TABLE -#define CONFIGURE_INIT_TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE * 2) -#define CONFIGURE_INIT_TASK_PRIORITY 2 -#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT - -#define CONFIGURE_EXTRA_TASK_STACKS RTEMS_MINIMUM_STACK_SIZE - -#define CONFIGURE_INIT - -#include <rtems/confdefs.h> - -/* end of file */ diff --git a/testsuites/psxtests/psxspin02/psxspin02.doc b/testsuites/psxtests/psxspin02/psxspin02.doc deleted file mode 100644 index 43a871d4a9..0000000000 --- a/testsuites/psxtests/psxspin02/psxspin02.doc +++ /dev/null @@ -1,25 +0,0 @@ -# COPYRIGHT (c) 1989-2009. -# On-Line Applications Research Corporation (OAR). -# -# The license and distribution terms for this file may be -# found in the file LICENSE in this distribution or at -# http://www.rtems.org/license/LICENSE. -# - -This file describes the directives and concepts tested by this test set. - -test set name: psxspin02 - -directives: - - pthread_spin_lock - pthread_spin_trylock - pthread_spin_unlock - -concepts: - -+ Ensure that attempting to obtain a locked spin lock with - pthread_spin_trylock returns the correct error. - -+ Ensure that attempting to release a locked spin lock from a thread which - did not lock it returns the correct error. diff --git a/testsuites/psxtests/psxspin02/psxspin02.scn b/testsuites/psxtests/psxspin02/psxspin02.scn deleted file mode 100644 index 8e71ca6e1b..0000000000 --- a/testsuites/psxtests/psxspin02/psxspin02.scn +++ /dev/null @@ -1,8 +0,0 @@ -*** POSIX SPINLOCK TEST 02 *** -pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK -pthread_spin_lock( &Spinlock ) -- OK -pthread_spin_trylock( &Spinlock ) -- EBUSY -pthread_spin_unlock( &Spinlock ) -- EPERM -pthread_spin_unlock( &Spinlock ) -- OK -pthread_spin_destroy( &Spinlock ) -- OK -*** END OF POSIX SPINLOCK TEST 02 *** diff --git a/testsuites/psxtests/psxspin02/test.c b/testsuites/psxtests/psxspin02/test.c deleted file mode 100644 index 36bcbb91ba..0000000000 --- a/testsuites/psxtests/psxspin02/test.c +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @file - * - * This test exercises the POSIX Spinlock manager. - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "tmacros.h" -#include <stdio.h> -#include <errno.h> -#include <stdlib.h> - -#include <pthread.h> - -#include <rtems.h> /* for task creation */ - -const char rtems_test_name[] = "PSXSPIN 2"; - -/* forward declarations to avoid warnings */ -int test_main(void); -rtems_task SpinlockThread(rtems_task_argument arg); - -pthread_spinlock_t Spinlock; - -rtems_task SpinlockThread(rtems_task_argument arg) -{ - int status; - - puts( "pthread_spin_trylock( &Spinlock ) -- EBUSY" ); - status = pthread_spin_trylock( &Spinlock ); - rtems_test_assert( status == EBUSY ); - - puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" ); - status = pthread_spin_unlock( &Spinlock ); - rtems_test_assert( status == EPERM ); - - rtems_task_delete( RTEMS_SELF ); -} - -/* - * main entry point to the test - */ - -#if defined(__rtems__) -int test_main(void) -#else -int main( - int argc, - char **argv -) -#endif -{ - int status; - rtems_status_code rstatus; - rtems_id taskid; - - TEST_BEGIN(); - - /* This successfully creates one */ - puts( "pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK" ); - status = pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ); - rtems_test_assert( status == 0 ); - - /* Lock it */ - puts( "pthread_spin_lock( &Spinlock ) -- OK" ); - status = pthread_spin_lock( &Spinlock ); - rtems_test_assert( status == 0 ); - - /* Create a helper task */ - rstatus = rtems_task_create( - rtems_build_name( 'S', 'P', 'I', 'N' ), - 1, - RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, - &taskid - ); - rtems_test_assert( rstatus == RTEMS_SUCCESSFUL ); - - rstatus = rtems_task_start( taskid, SpinlockThread, 0 ); - rtems_test_assert( rstatus == RTEMS_SUCCESSFUL ); - - sleep(1); - - puts( "pthread_spin_unlock( &Spinlock ) -- OK" ); - status = pthread_spin_unlock( &Spinlock ); - rtems_test_assert( status == 0 ); - - puts( "pthread_spin_destroy( &Spinlock ) -- OK" ); - status = pthread_spin_destroy( &Spinlock ); - rtems_test_assert( status == 0 ); - - /*************** END OF TEST *****************/ - TEST_END(); - exit(0); -} diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c index 1ce22d5c08..b81fbabbac 100644 --- a/testsuites/sptests/spsysinit01/init.c +++ b/testsuites/sptests/spsysinit01/init.c @@ -43,7 +43,6 @@ #include <rtems/posix/pthreadimpl.h> #include <rtems/posix/rwlockimpl.h> #include <rtems/posix/semaphoreimpl.h> -#include <rtems/posix/spinlockimpl.h> #include <rtems/posix/timerimpl.h> #endif /* RTEMS_POSIX_API */ #include <rtems/posix/keyimpl.h> @@ -118,8 +117,6 @@ typedef enum { POSIX_BARRIER_POST, POSIX_RWLOCK_PRE, POSIX_RWLOCK_POST, - POSIX_SPINLOCK_PRE, - POSIX_SPINLOCK_POST, POSIX_CLEANUP_PRE, POSIX_CLEANUP_POST, #endif /* RTEMS_POSIX_API */ @@ -527,18 +524,6 @@ LAST(RTEMS_SYSINIT_POSIX_RWLOCK) next_step(POSIX_RWLOCK_POST); } -FIRST(RTEMS_SYSINIT_POSIX_SPINLOCK) -{ - assert(_POSIX_Spinlock_Information.maximum == 0); - next_step(POSIX_SPINLOCK_PRE); -} - -LAST(RTEMS_SYSINIT_POSIX_SPINLOCK) -{ - assert(_POSIX_Spinlock_Information.maximum != 0); - next_step(POSIX_SPINLOCK_POST); -} - static size_t user_extensions_pre_posix_cleanup; FIRST(RTEMS_SYSINIT_POSIX_CLEANUP) @@ -767,8 +752,6 @@ static void *POSIX_Init(void *arg) #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 1 -#define CONFIGURE_MAXIMUM_POSIX_SPINLOCKS 1 - #define CONFIGURE_MAXIMUM_POSIX_TIMERS 1 #define CONFIGURE_MAXIMUM_POSIX_THREADS 1 |