forked from Imagelibrary/rtems
2009-07-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* psxcancel/init.c: Clean up.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2009-07-22 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
|
* psxcancel/init.c: Clean up.
|
||||||
|
|
||||||
2009-07-21 Joel Sherrill <joel.sherrill@oarcorp.com>
|
2009-07-21 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
* psxmutexattr01/init.c: Make test optional if tools do not support
|
* psxmutexattr01/init.c: Make test optional if tools do not support
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Thread Test Program
|
|
||||||
*
|
|
||||||
* - test of POSIX's pthread_init() function from rtemstask Init()
|
|
||||||
*
|
|
||||||
* ott@linux.thai.net
|
|
||||||
*
|
|
||||||
* The license and distribution terms for this file may be
|
* The license and distribution terms for this file may be
|
||||||
* found in the file LICENSE in this distribution or at
|
* found in the file LICENSE in this distribution or at
|
||||||
* http://www.rtems.com/license/LICENSE.
|
* http://www.rtems.com/license/LICENSE.
|
||||||
@@ -17,44 +11,18 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#ifdef __rtems__
|
|
||||||
#include <rtems.h>
|
|
||||||
/* configuration information */
|
|
||||||
|
|
||||||
#define CONFIGURE_INIT
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
|
||||||
#include <bsp.h> /* for device driver prototypes */
|
|
||||||
|
#if defined(__rtems__)
|
||||||
|
#include <rtems.h>
|
||||||
|
#include <bsp.h>
|
||||||
#include <pmacros.h>
|
#include <pmacros.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
rtems_task Init( rtems_task_argument argument);
|
void *countTaskDeferred(void *ignored)
|
||||||
|
|
||||||
/* configuration information */
|
|
||||||
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
|
||||||
|
|
||||||
#define CONFIGURE_MAXIMUM_TASKS 3
|
|
||||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
|
||||||
#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
|
|
||||||
|
|
||||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 5
|
|
||||||
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 5
|
|
||||||
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 5
|
|
||||||
|
|
||||||
#include <rtems/console.h>
|
|
||||||
#include <rtems/confdefs.h>
|
|
||||||
|
|
||||||
#endif /* __rtems__ */
|
|
||||||
|
|
||||||
void countTaskAsync(void);
|
|
||||||
void countTaskDeferred(void);
|
|
||||||
|
|
||||||
void countTaskDeferred(void)
|
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
int type,state;
|
int type,state;
|
||||||
@@ -68,7 +36,7 @@ void countTaskDeferred(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void countTaskAsync(void)
|
void *countTaskAsync(void *ignored)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
int type,state;
|
int type,state;
|
||||||
@@ -81,13 +49,13 @@ void countTaskAsync(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#if defined(__rtems__)
|
||||||
int main(){
|
void *POSIX_Init(void *ignored)
|
||||||
#else
|
#else
|
||||||
rtems_task Init( rtems_task_argument ignored ) {
|
int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
pthread_t count;
|
pthread_t task;
|
||||||
int taskparameter = 0;
|
int taskparameter = 0;
|
||||||
|
|
||||||
puts( "\n\n*** POSIX CANCEL TEST ***" );
|
puts( "\n\n*** POSIX CANCEL TEST ***" );
|
||||||
@@ -95,37 +63,53 @@ int main(){
|
|||||||
/* Start countTask deferred */
|
/* Start countTask deferred */
|
||||||
{
|
{
|
||||||
int task_ret;
|
int task_ret;
|
||||||
task_ret = pthread_create(&count, NULL, (void *) countTaskDeferred, (void *) &taskparameter);
|
task_ret = pthread_create(&task, NULL, countTaskDeferred, &taskparameter);
|
||||||
if (task_ret) {
|
if (task_ret) {
|
||||||
perror("pthread_create: countTask");
|
perror("pthread_create: countTask");
|
||||||
rtems_test_exit(EXIT_FAILURE);
|
rtems_test_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
/* sleep for 5 seconds, then cancel it */
|
/* sleep for 5 seconds, then cancel it */
|
||||||
sleep(5);
|
sleep(5);
|
||||||
pthread_cancel(count);
|
pthread_cancel(task);
|
||||||
pthread_join(count,NULL);
|
pthread_join(task, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start countTask asynchronous */
|
/* Start countTask asynchronous */
|
||||||
{
|
{
|
||||||
int task_ret;
|
int task_ret;
|
||||||
task_ret = pthread_create(&count, NULL, (void *) countTaskAsync, (void *) &taskparameter);
|
task_ret = pthread_create(&task, NULL, countTaskAsync, &taskparameter);
|
||||||
if (task_ret) {
|
if (task_ret) {
|
||||||
perror("pthread_create: countTask");
|
perror("pthread_create: countTask");
|
||||||
rtems_test_exit(EXIT_FAILURE);
|
rtems_test_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
/* sleep for 5 seconds, then cancel it */
|
/* sleep for 5 seconds, then cancel it */
|
||||||
sleep(5);
|
sleep(5);
|
||||||
pthread_cancel(count);
|
pthread_cancel(task);
|
||||||
pthread_join(count,NULL);
|
pthread_join(task, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
puts( "*** END OF POSIX CANCEL TEST ***" );
|
puts( "*** END OF POSIX CANCEL TEST ***" );
|
||||||
|
|
||||||
#ifdef __linux__
|
#if defined(__rtems__)
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
rtems_test_exit(EXIT_SUCCESS);
|
rtems_test_exit(EXIT_SUCCESS);
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* configuration information */
|
||||||
|
#if defined(__rtems__)
|
||||||
|
|
||||||
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||||
|
|
||||||
|
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
|
||||||
|
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
||||||
|
|
||||||
|
#define CONFIGURE_INIT
|
||||||
|
#include <rtems/confdefs.h>
|
||||||
|
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user