diff options
Diffstat (limited to 'posix_api/psx_example_1/test1.c')
-rw-r--r-- | posix_api/psx_example_1/test1.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/posix_api/psx_example_1/test1.c b/posix_api/psx_example_1/test1.c new file mode 100644 index 0000000..4c26bbc --- /dev/null +++ b/posix_api/psx_example_1/test1.c @@ -0,0 +1,46 @@ +/* + * $Id$ + */ + +#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> |