Changeset 381a53a8 in rtems


Ignore:
Timestamp:
Jul 22, 2009, 2:00:09 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
e8d59ca
Parents:
e1ffb64
Message:

2009-07-22 Joel Sherrill <joel.sherrill@…>

  • psxcancel/init.c: Clean up.
Location:
testsuites/psxtests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/ChangeLog

    re1ffb64 r381a53a8  
     12009-07-22      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * psxcancel/init.c: Clean up.
     4
    152009-07-21      Joel Sherrill <joel.sherrill@oarcorp.com>
    26
  • testsuites/psxtests/psxcancel/init.c

    re1ffb64 r381a53a8  
    11/*
    2  * Thread Test Program
    3  *
    4  *  - test of POSIX's pthread_init() function from rtemstask Init()
    5  *
    6  *     ott@linux.thai.net
    7  *
    82 *  The license and distribution terms for this file may be
    93 *  found in the file LICENSE in this distribution or at
     
    1812#include <pthread.h>
    1913#include <sys/time.h>
    20 
    21 #ifdef __rtems__
    22 #include <rtems.h>
    23 /* configuration information */
    24 
    25 #define CONFIGURE_INIT
    26 
    2714#include <unistd.h>
    2815#include <errno.h>
    2916#include <sched.h>
    3017
    31 #include <bsp.h> /* for device driver prototypes */
     18
     19#if defined(__rtems__)
     20#include <rtems.h>
     21#include <bsp.h>
    3222#include <pmacros.h>
     23#endif
    3324
    34 rtems_task Init( rtems_task_argument argument);
    35 
    36 /* configuration information */
    37 
    38 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
    39 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
    40 
    41 #define CONFIGURE_MAXIMUM_TASKS             3
    42 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
    43 #define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)
    44 
    45 #define CONFIGURE_MAXIMUM_POSIX_THREADS 5
    46 #define CONFIGURE_MAXIMUM_POSIX_MUTEXES 5
    47 #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 5
    48 
    49 #include <rtems/console.h>
    50 #include <rtems/confdefs.h>
    51 
    52 #endif /* __rtems__ */
    53 
    54 void countTaskAsync(void);
    55 void countTaskDeferred(void);
    56 
    57 void countTaskDeferred(void)
     25void *countTaskDeferred(void *ignored)
    5826{
    5927  int i=0;
     
    6634    sleep(1);
    6735    pthread_testcancel();
    68     }
     36  }
    6937}
    7038
    71 void countTaskAsync(void)
     39void *countTaskAsync(void *ignored)
    7240{
    7341  int i=0;
     
    7947    printf("countTaskAsync: elapsed time (second): %2d\n", i++ );
    8048    sleep(1);
    81     }
     49  }
    8250}
    8351
    84 #ifdef __linux__
    85 int main(){
     52#if defined(__rtems__)
     53  void *POSIX_Init(void *ignored)
    8654#else
    87   rtems_task Init( rtems_task_argument ignored ) {
     55  int main(int argc, char **argv)
    8856#endif
    89 
    90   pthread_t count;
     57{
     58  pthread_t task;
    9159  int taskparameter = 0;
    9260
     
    9664  {
    9765    int task_ret;
    98     task_ret = pthread_create(&count, NULL, (void *) countTaskDeferred, (void *) &taskparameter);
     66    task_ret = pthread_create(&task, NULL, countTaskDeferred, &taskparameter);
    9967    if (task_ret) {
    10068      perror("pthread_create: countTask");
     
    10371    /* sleep for 5 seconds, then cancel it */
    10472    sleep(5);
    105     pthread_cancel(count);
    106     pthread_join(count,NULL);
     73    pthread_cancel(task);
     74    pthread_join(task, NULL);
    10775  }
    10876
     
    11078  {
    11179    int task_ret;
    112     task_ret = pthread_create(&count, NULL, (void *) countTaskAsync, (void *) &taskparameter);
     80    task_ret = pthread_create(&task, NULL, countTaskAsync, &taskparameter);
    11381    if (task_ret) {
    11482      perror("pthread_create: countTask");
     
    11785    /* sleep for 5 seconds, then cancel it */
    11886    sleep(5);
    119     pthread_cancel(count);
    120     pthread_join(count,NULL);
     87    pthread_cancel(task);
     88    pthread_join(task, NULL);
    12189  }
    12290
     
    12492  puts( "*** END OF POSIX CANCEL TEST ***" );
    12593
    126 #ifdef __linux__
    127   return 0;
    128 #else
    129   rtems_test_exit(EXIT_SUCCESS);
    130 #endif
     94  #if defined(__rtems__)
     95    rtems_test_exit(EXIT_SUCCESS);
     96    return NULL;
     97  #else
     98    return 0;
     99  #endif
    131100}
     101
     102/* configuration information */
     103#if defined(__rtems__)
     104
     105#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     106#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     107
     108#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
     109#define CONFIGURE_POSIX_INIT_THREAD_TABLE
     110
     111#define CONFIGURE_INIT
     112#include <rtems/confdefs.h>
     113
     114#endif /* __rtems__ */
     115
Note: See TracChangeset for help on using the changeset viewer.