summaryrefslogtreecommitdiff
path: root/posix_api/psx_example_1/test1.c
blob: a7f6fffaf75adace9202dd86cf1cac8a70be446e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <sched.h>
#include <bsp.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>

void * print_hello(void * arg)
{
  sleep(1);
  printf("<child>: Hello World!\n");
  return NULL;
}

void *POSIX_Init()
{
  pthread_t child1;
  pthread_t child2;
  int status;

  status = pthread_create( &child1, NULL, print_hello, NULL );
  if ( status ) perror("Error on create child 1");

  status = pthread_create( &child2, NULL, print_hello, NULL );
  if ( status ) perror("Error on create child 1");

  printf("<main>: Wait for child2 thread...\n");

  status = pthread_join( child1, NULL );
  if ( status ) perror ("Error on join");
  printf("<main>: Successfully joined with child1\n" );
  exit(0);
}

#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER

#define CONFIGURE_MAXIMUM_POSIX_THREADS              10
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES  10
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES              10
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>