forked from Imagelibrary/rtems
2002-07-05 Joel Sherrill <joel@OARcorp.com>
* psxcancel/Makefile.am, psxcancel/init.c, psxcancel/psxcancel.scn: Updated as part of PR164 which reported problems with the RTEMS implementation of pthread_cancel.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2002-07-05 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
|
* psxcancel/Makefile.am, psxcancel/init.c, psxcancel/psxcancel.scn:
|
||||||
|
Updated as part of PR164 which reported problems with the RTEMS
|
||||||
|
implementation of pthread_cancel.
|
||||||
|
|
||||||
2001-04-26 Joel Sherrill <joel@OARcorp.com>
|
2001-04-26 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
* psxmsgq01/init.c: Reflect changes made to address PR81 that
|
* psxmsgq01/init.c: Reflect changes made to address PR81 that
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ MANAGERS = all
|
|||||||
C_FILES = init.c
|
C_FILES = init.c
|
||||||
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
|
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
|
||||||
|
|
||||||
H_FILES = system.h
|
H_FILES =
|
||||||
noinst_HEADERS = $(H_FILES)
|
noinst_HEADERS = $(H_FILES)
|
||||||
|
|
||||||
DOCTYPES = scn
|
DOCTYPES = scn
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* COPYRIGHT (c) 1989-1999.
|
* Thread Test Program
|
||||||
* On-Line Applications Research Corporation (OAR).
|
*
|
||||||
|
* - 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
|
||||||
@@ -9,19 +12,115 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#include <rtems.h>
|
||||||
|
/* configuration information */
|
||||||
|
|
||||||
#define CONFIGURE_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
|
||||||
void *POSIX_Init(
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
void *argument
|
|
||||||
)
|
rtems_task Init( rtems_task_argument argument);
|
||||||
{
|
|
||||||
|
/* 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 <console.h>
|
||||||
|
#include <confdefs.h>
|
||||||
|
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
|
void countTaskDeferred() {
|
||||||
|
int i=0;
|
||||||
|
int type,state;
|
||||||
|
|
||||||
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
|
||||||
|
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &state);
|
||||||
|
while (1) {
|
||||||
|
printf("countTaskDeferred: elapsed time (second): %2d\n", i++ );
|
||||||
|
sleep(1);
|
||||||
|
pthread_testcancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void countTaskAsync() {
|
||||||
|
int i=0;
|
||||||
|
int type,state;
|
||||||
|
|
||||||
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
|
||||||
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &state);
|
||||||
|
while (1) {
|
||||||
|
printf("countTaskAsync: elapsed time (second): %2d\n", i++ );
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
int main(){
|
||||||
|
#else
|
||||||
|
rtems_task Init( rtems_task_argument ignored ) {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pthread_t count;
|
||||||
|
int taskparameter = 0;
|
||||||
|
|
||||||
puts( "\n\n*** POSIX CANCEL TEST ***" );
|
puts( "\n\n*** POSIX CANCEL TEST ***" );
|
||||||
|
|
||||||
puts( "*** END OF POSIX CANCEL TEST ***" );
|
/* Start countTask deferred */
|
||||||
exit( 0 );
|
{
|
||||||
|
int task_ret;
|
||||||
|
task_ret = pthread_create(&count, NULL, (void *) countTaskDeferred, (void *) &taskparameter);
|
||||||
|
if (task_ret) {
|
||||||
|
perror("pthread_create: countTask");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
/* sleep for 5 seconds, then cancel it */
|
||||||
|
sleep(5);
|
||||||
|
pthread_cancel(count);
|
||||||
|
pthread_join(count,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL; /* just so the compiler thinks we returned something */
|
/* Start countTask asynchronous */
|
||||||
|
{
|
||||||
|
int task_ret;
|
||||||
|
task_ret = pthread_create(&count, NULL, (void *) countTaskAsync, (void *) &taskparameter);
|
||||||
|
if (task_ret) {
|
||||||
|
perror("pthread_create: countTask");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
/* sleep for 5 seconds, then cancel it */
|
||||||
|
sleep(5);
|
||||||
|
pthread_cancel(count);
|
||||||
|
pthread_join(count,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
puts( "*** END OF POSIX CANCEL TEST ***" );
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
*** POSIX CANCEL TEST ***
|
|
||||||
|
|
||||||
|
|
||||||
|
*** POSIX CANCEL TEST ***
|
||||||
|
countTaskDeferred: elapsed time (second): 0
|
||||||
|
countTaskDeferred: elapsed time (second): 1
|
||||||
|
countTaskDeferred: elapsed time (second): 2
|
||||||
|
countTaskDeferred: elapsed time (second): 3
|
||||||
|
countTaskDeferred: elapsed time (second): 4
|
||||||
|
countTaskAsync: elapsed time (second): 0
|
||||||
|
countTaskAsync: elapsed time (second): 1
|
||||||
|
countTaskAsync: elapsed time (second): 2
|
||||||
|
countTaskAsync: elapsed time (second): 3
|
||||||
|
countTaskAsync: elapsed time (second): 4
|
||||||
*** END OF POSIX CANCEL TEST ***
|
*** END OF POSIX CANCEL TEST ***
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
/* 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$
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* functions */
|
|
||||||
|
|
||||||
#include <pmacros.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sched.h>
|
|
||||||
|
|
||||||
void *POSIX_Init(
|
|
||||||
void *argument
|
|
||||||
);
|
|
||||||
|
|
||||||
void *Task_1_through_3(
|
|
||||||
void *argument
|
|
||||||
);
|
|
||||||
|
|
||||||
/* configuration information */
|
|
||||||
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
|
||||||
|
|
||||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
|
|
||||||
|
|
||||||
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
|
||||||
|
|
||||||
#include <confdefs.h>
|
|
||||||
|
|
||||||
/* global variables */
|
|
||||||
|
|
||||||
#ifdef CONFIGURE_INIT
|
|
||||||
#define TEST_EXTERN
|
|
||||||
#else
|
|
||||||
#define TEST_EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TEST_EXTERN pthread_t Init_id;
|
|
||||||
TEST_EXTERN pthread_t Task_id;
|
|
||||||
|
|
||||||
/* end of include file */
|
|
||||||
@@ -1,3 +1,9 @@
|
|||||||
|
2002-07-05 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
|
* psxcancel/Makefile.am, psxcancel/init.c, psxcancel/psxcancel.scn:
|
||||||
|
Updated as part of PR164 which reported problems with the RTEMS
|
||||||
|
implementation of pthread_cancel.
|
||||||
|
|
||||||
2001-04-26 Joel Sherrill <joel@OARcorp.com>
|
2001-04-26 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
* psxmsgq01/init.c: Reflect changes made to address PR81 that
|
* psxmsgq01/init.c: Reflect changes made to address PR81 that
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ MANAGERS = all
|
|||||||
C_FILES = init.c
|
C_FILES = init.c
|
||||||
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
|
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
|
||||||
|
|
||||||
H_FILES = system.h
|
H_FILES =
|
||||||
noinst_HEADERS = $(H_FILES)
|
noinst_HEADERS = $(H_FILES)
|
||||||
|
|
||||||
DOCTYPES = scn
|
DOCTYPES = scn
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* COPYRIGHT (c) 1989-1999.
|
* Thread Test Program
|
||||||
* On-Line Applications Research Corporation (OAR).
|
*
|
||||||
|
* - 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
|
||||||
@@ -9,19 +12,115 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#include <rtems.h>
|
||||||
|
/* configuration information */
|
||||||
|
|
||||||
#define CONFIGURE_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
|
||||||
void *POSIX_Init(
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
void *argument
|
|
||||||
)
|
rtems_task Init( rtems_task_argument argument);
|
||||||
{
|
|
||||||
|
/* 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 <console.h>
|
||||||
|
#include <confdefs.h>
|
||||||
|
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
|
void countTaskDeferred() {
|
||||||
|
int i=0;
|
||||||
|
int type,state;
|
||||||
|
|
||||||
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
|
||||||
|
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &state);
|
||||||
|
while (1) {
|
||||||
|
printf("countTaskDeferred: elapsed time (second): %2d\n", i++ );
|
||||||
|
sleep(1);
|
||||||
|
pthread_testcancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void countTaskAsync() {
|
||||||
|
int i=0;
|
||||||
|
int type,state;
|
||||||
|
|
||||||
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
|
||||||
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &state);
|
||||||
|
while (1) {
|
||||||
|
printf("countTaskAsync: elapsed time (second): %2d\n", i++ );
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
int main(){
|
||||||
|
#else
|
||||||
|
rtems_task Init( rtems_task_argument ignored ) {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pthread_t count;
|
||||||
|
int taskparameter = 0;
|
||||||
|
|
||||||
puts( "\n\n*** POSIX CANCEL TEST ***" );
|
puts( "\n\n*** POSIX CANCEL TEST ***" );
|
||||||
|
|
||||||
puts( "*** END OF POSIX CANCEL TEST ***" );
|
/* Start countTask deferred */
|
||||||
exit( 0 );
|
{
|
||||||
|
int task_ret;
|
||||||
|
task_ret = pthread_create(&count, NULL, (void *) countTaskDeferred, (void *) &taskparameter);
|
||||||
|
if (task_ret) {
|
||||||
|
perror("pthread_create: countTask");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
/* sleep for 5 seconds, then cancel it */
|
||||||
|
sleep(5);
|
||||||
|
pthread_cancel(count);
|
||||||
|
pthread_join(count,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL; /* just so the compiler thinks we returned something */
|
/* Start countTask asynchronous */
|
||||||
|
{
|
||||||
|
int task_ret;
|
||||||
|
task_ret = pthread_create(&count, NULL, (void *) countTaskAsync, (void *) &taskparameter);
|
||||||
|
if (task_ret) {
|
||||||
|
perror("pthread_create: countTask");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
/* sleep for 5 seconds, then cancel it */
|
||||||
|
sleep(5);
|
||||||
|
pthread_cancel(count);
|
||||||
|
pthread_join(count,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
puts( "*** END OF POSIX CANCEL TEST ***" );
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
*** POSIX CANCEL TEST ***
|
|
||||||
|
|
||||||
|
|
||||||
|
*** POSIX CANCEL TEST ***
|
||||||
|
countTaskDeferred: elapsed time (second): 0
|
||||||
|
countTaskDeferred: elapsed time (second): 1
|
||||||
|
countTaskDeferred: elapsed time (second): 2
|
||||||
|
countTaskDeferred: elapsed time (second): 3
|
||||||
|
countTaskDeferred: elapsed time (second): 4
|
||||||
|
countTaskAsync: elapsed time (second): 0
|
||||||
|
countTaskAsync: elapsed time (second): 1
|
||||||
|
countTaskAsync: elapsed time (second): 2
|
||||||
|
countTaskAsync: elapsed time (second): 3
|
||||||
|
countTaskAsync: elapsed time (second): 4
|
||||||
*** END OF POSIX CANCEL TEST ***
|
*** END OF POSIX CANCEL TEST ***
|
||||||
|
|||||||
Reference in New Issue
Block a user