source: rtems/testsuites/psxtests/psx16/init.c @ efe2ab6

4.115
Last change on this file since efe2ab6 was efe2ab6, checked in by Joel Sherrill <joel.sherrill@…>, on 08/01/11 at 12:45:14

2011-08-01 Joel Sherrill <joel.sherrilL@…>

  • psx16/.cvsignore, psx16/init.c, psx16/psx16.doc, psx16/psx16.scn: New files. Accidentally missed in previous commit.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#include <tmacros.h>
13#include "test_support.h"
14#include <pthread.h>
15
16int Index;
17
18void *TestThread(
19  void *argument
20)
21{
22  int *index = (int *)argument;
23
24  *index = 7;
25
26  puts( "TestThread exiting" );
27  return argument;
28}
29
30void *POSIX_Init(
31  rtems_task_argument argument
32)
33{
34  int             status;
35  pthread_t       id;
36  pthread_attr_t  attr;
37  void           *join_return;
38
39  puts( "\n\n*** POSIX TEST PSX16 ***" );
40
41  Index = 5;
42
43  /* Initialize and set thread detached attribute */
44  pthread_attr_init(&attr);
45  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
46
47  puts( "Creating TestThread" );
48  status = pthread_create( &id, &attr, TestThread, (void *)&Index );
49  rtems_test_assert( status == 0 );
50
51  /* let test thread run and exit */
52  puts( "Let TestThread run and exit before we attempt to join" );
53  sleep( 2 );
54
55  join_return = NULL;
56  status = pthread_join( id, &join_return );
57  rtems_test_assert( status == 0 );
58  rtems_test_assert( join_return == &Index );
59  rtems_test_assert( *(int *)join_return == 7 );
60  puts( "Successfully joined with TestThread" );
61
62  puts( "*** END OF POSIX TEST PSX16 ***" );
63
64  rtems_test_exit(0);
65}
66
67/* configuration information */
68
69#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
70#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
71
72#define CONFIGURE_MAXIMUM_POSIX_THREADS        2
73
74#define CONFIGURE_POSIX_INIT_THREAD_TABLE
75
76#define CONFIGURE_INIT
77#include <rtems/confdefs.h>
78/* end of file */
Note: See TracBrowser for help on using the repository browser.