Changeset 4f234da in rtems


Ignore:
Timestamp:
Jul 5, 2002, 6:07:49 PM (19 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
2540208
Parents:
02ccf4a
Message:

2002-07-05 Joel Sherrill <joel@…>

  • psxcancel/Makefile.am, psxcancel/init.c, psxcancel/psxcancel.scn: Updated as part of PR164 which reported problems with the RTEMS implementation of pthread_cancel.
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • c/src/tests/psxtests/ChangeLog

    r02ccf4a r4f234da  
     12002-07-05      Joel Sherrill <joel@OARcorp.com>
     2
     3        * psxcancel/Makefile.am, psxcancel/init.c, psxcancel/psxcancel.scn:
     4        Updated as part of PR164 which reported problems with the RTEMS
     5        implementation of pthread_cancel.
     6       
    172001-04-26      Joel Sherrill <joel@OARcorp.com>
    28
  • c/src/tests/psxtests/psxcancel/Makefile.am

    r02ccf4a r4f234da  
    1111C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
    1212
    13 H_FILES = system.h
     13H_FILES =
    1414noinst_HEADERS = $(H_FILES)
    1515
  • c/src/tests/psxtests/psxcancel/init.c

    r02ccf4a r4f234da  
    1 /*
    2  *  COPYRIGHT (c) 1989-1999.
    3  *  On-Line Applications Research Corporation (OAR).
     1/*
     2 * Thread Test Program
     3 *
     4 *  - test of POSIX's pthread_init() function from rtemstask Init()
     5 *
     6 *     ott@linux.thai.net
    47 *
    58 *  The license and distribution terms for this file may be
     
    1013 */
    1114
     15
     16#include <stdio.h>
     17#include <stdlib.h>
     18#include <pthread.h>
     19#include <sys/time.h>
     20
     21#ifdef __rtems__
     22#include <rtems.h>
     23/* configuration information */
     24
    1225#define CONFIGURE_INIT
    13 #include "system.h"
     26
     27#include <unistd.h>
     28#include <errno.h>
    1429#include <sched.h>
    1530
    16 void *POSIX_Init(
    17   void *argument
    18 )
    19 {
     31#include <bsp.h> /* for device driver prototypes */
     32
     33rtems_task Init( rtems_task_argument argument);
     34
     35/* configuration information */
     36
     37#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     38#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     39
     40#define CONFIGURE_MAXIMUM_TASKS             3
     41#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
     42#define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)
     43
     44#define CONFIGURE_MAXIMUM_POSIX_THREADS 5
     45#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 5
     46#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 5
     47
     48#include <console.h>
     49#include <confdefs.h>
     50
     51#endif /* __rtems__ */
     52
     53void countTaskDeferred() {
     54  int i=0;
     55  int type,state;
     56
     57  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
     58  pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &state);
     59  while (1) {
     60    printf("countTaskDeferred: elapsed time (second): %2d\n", i++ );
     61    sleep(1);
     62    pthread_testcancel();
     63    }
     64}
     65
     66void countTaskAsync() {
     67  int i=0;
     68  int type,state;
     69
     70  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
     71  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &state);
     72  while (1) {
     73    printf("countTaskAsync: elapsed time (second): %2d\n", i++ );
     74    sleep(1);
     75    }
     76}
     77
     78#ifdef __linux__
     79int main(){
     80#else
     81  rtems_task Init( rtems_task_argument ignored ) {
     82#endif
     83
     84  pthread_t count;
     85  int taskparameter = 0;
    2086
    2187  puts( "\n\n*** POSIX CANCEL TEST ***" );
    2288
     89  /* Start countTask deferred */
     90  {
     91    int task_ret;
     92    task_ret = pthread_create(&count, NULL, (void *) countTaskDeferred, (void *) &taskparameter);
     93    if (task_ret) {
     94      perror("pthread_create: countTask");
     95      exit(EXIT_FAILURE);
     96    }
     97    /* sleep for 5 seconds, then cancel it */
     98    sleep(5);
     99    pthread_cancel(count);
     100    pthread_join(count,NULL);
     101  }
     102
     103  /* Start countTask asynchronous */
     104  {
     105    int task_ret;
     106    task_ret = pthread_create(&count, NULL, (void *) countTaskAsync, (void *) &taskparameter);
     107    if (task_ret) {
     108      perror("pthread_create: countTask");
     109      exit(EXIT_FAILURE);
     110    }
     111    /* sleep for 5 seconds, then cancel it */
     112    sleep(5);
     113    pthread_cancel(count);
     114    pthread_join(count,NULL);
     115  }
     116
     117
    23118  puts( "*** END OF POSIX CANCEL TEST ***" );
    24   exit( 0 );
    25119
    26   return NULL; /* just so the compiler thinks we returned something */
     120#ifdef __linux__
     121  return 0;
     122#else
     123  exit(EXIT_SUCCESS);
     124#endif
    27125}
     126
  • c/src/tests/psxtests/psxcancel/psxcancel.scn

    r02ccf4a r4f234da  
     1
     2
    13*** POSIX CANCEL TEST ***
    2 
     4countTaskDeferred: elapsed time (second):  0
     5countTaskDeferred: elapsed time (second):  1
     6countTaskDeferred: elapsed time (second):  2
     7countTaskDeferred: elapsed time (second):  3
     8countTaskDeferred: elapsed time (second):  4
     9countTaskAsync: elapsed time (second):  0
     10countTaskAsync: elapsed time (second):  1
     11countTaskAsync: elapsed time (second):  2
     12countTaskAsync: elapsed time (second):  3
     13countTaskAsync: elapsed time (second):  4
    314*** END OF POSIX CANCEL TEST ***
  • testsuites/psxtests/ChangeLog

    r02ccf4a r4f234da  
     12002-07-05      Joel Sherrill <joel@OARcorp.com>
     2
     3        * psxcancel/Makefile.am, psxcancel/init.c, psxcancel/psxcancel.scn:
     4        Updated as part of PR164 which reported problems with the RTEMS
     5        implementation of pthread_cancel.
     6       
    172001-04-26      Joel Sherrill <joel@OARcorp.com>
    28
  • testsuites/psxtests/psxcancel/Makefile.am

    r02ccf4a r4f234da  
    1111C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
    1212
    13 H_FILES = system.h
     13H_FILES =
    1414noinst_HEADERS = $(H_FILES)
    1515
  • testsuites/psxtests/psxcancel/init.c

    r02ccf4a r4f234da  
    1 /*
    2  *  COPYRIGHT (c) 1989-1999.
    3  *  On-Line Applications Research Corporation (OAR).
     1/*
     2 * Thread Test Program
     3 *
     4 *  - test of POSIX's pthread_init() function from rtemstask Init()
     5 *
     6 *     ott@linux.thai.net
    47 *
    58 *  The license and distribution terms for this file may be
     
    1013 */
    1114
     15
     16#include <stdio.h>
     17#include <stdlib.h>
     18#include <pthread.h>
     19#include <sys/time.h>
     20
     21#ifdef __rtems__
     22#include <rtems.h>
     23/* configuration information */
     24
    1225#define CONFIGURE_INIT
    13 #include "system.h"
     26
     27#include <unistd.h>
     28#include <errno.h>
    1429#include <sched.h>
    1530
    16 void *POSIX_Init(
    17   void *argument
    18 )
    19 {
     31#include <bsp.h> /* for device driver prototypes */
     32
     33rtems_task Init( rtems_task_argument argument);
     34
     35/* configuration information */
     36
     37#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     38#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     39
     40#define CONFIGURE_MAXIMUM_TASKS             3
     41#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
     42#define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)
     43
     44#define CONFIGURE_MAXIMUM_POSIX_THREADS 5
     45#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 5
     46#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 5
     47
     48#include <console.h>
     49#include <confdefs.h>
     50
     51#endif /* __rtems__ */
     52
     53void countTaskDeferred() {
     54  int i=0;
     55  int type,state;
     56
     57  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
     58  pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &state);
     59  while (1) {
     60    printf("countTaskDeferred: elapsed time (second): %2d\n", i++ );
     61    sleep(1);
     62    pthread_testcancel();
     63    }
     64}
     65
     66void countTaskAsync() {
     67  int i=0;
     68  int type,state;
     69
     70  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
     71  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &state);
     72  while (1) {
     73    printf("countTaskAsync: elapsed time (second): %2d\n", i++ );
     74    sleep(1);
     75    }
     76}
     77
     78#ifdef __linux__
     79int main(){
     80#else
     81  rtems_task Init( rtems_task_argument ignored ) {
     82#endif
     83
     84  pthread_t count;
     85  int taskparameter = 0;
    2086
    2187  puts( "\n\n*** POSIX CANCEL TEST ***" );
    2288
     89  /* Start countTask deferred */
     90  {
     91    int task_ret;
     92    task_ret = pthread_create(&count, NULL, (void *) countTaskDeferred, (void *) &taskparameter);
     93    if (task_ret) {
     94      perror("pthread_create: countTask");
     95      exit(EXIT_FAILURE);
     96    }
     97    /* sleep for 5 seconds, then cancel it */
     98    sleep(5);
     99    pthread_cancel(count);
     100    pthread_join(count,NULL);
     101  }
     102
     103  /* Start countTask asynchronous */
     104  {
     105    int task_ret;
     106    task_ret = pthread_create(&count, NULL, (void *) countTaskAsync, (void *) &taskparameter);
     107    if (task_ret) {
     108      perror("pthread_create: countTask");
     109      exit(EXIT_FAILURE);
     110    }
     111    /* sleep for 5 seconds, then cancel it */
     112    sleep(5);
     113    pthread_cancel(count);
     114    pthread_join(count,NULL);
     115  }
     116
     117
    23118  puts( "*** END OF POSIX CANCEL TEST ***" );
    24   exit( 0 );
    25119
    26   return NULL; /* just so the compiler thinks we returned something */
     120#ifdef __linux__
     121  return 0;
     122#else
     123  exit(EXIT_SUCCESS);
     124#endif
    27125}
     126
  • testsuites/psxtests/psxcancel/psxcancel.scn

    r02ccf4a r4f234da  
     1
     2
    13*** POSIX CANCEL TEST ***
    2 
     4countTaskDeferred: elapsed time (second):  0
     5countTaskDeferred: elapsed time (second):  1
     6countTaskDeferred: elapsed time (second):  2
     7countTaskDeferred: elapsed time (second):  3
     8countTaskDeferred: elapsed time (second):  4
     9countTaskAsync: elapsed time (second):  0
     10countTaskAsync: elapsed time (second):  1
     11countTaskAsync: elapsed time (second):  2
     12countTaskAsync: elapsed time (second):  3
     13countTaskAsync: elapsed time (second):  4
    314*** END OF POSIX CANCEL TEST ***
Note: See TracChangeset for help on using the changeset viewer.