1 /*
2  * Copyright (c) 2002, Intel Corporation. All rights reserved.
3  * Created by:  rolla.n.selbak REMOVE-THIS AT intel DOT com
4  * This file is licensed under the GPL license.  For the full content
5  * of this license, see the COPYING file at the top level of this
6  * source tree.
7 
8  * A single attributes object can be used in multiple simultaneous calls to
9  * pthread_create().
10  * NOTE: Results are undefined if pthread_attr_init() is called specifying an
11  * already initialized 'attr' attributes object.
12  *
13  * Steps:
14  * 1.  Initialize a pthread_attr_t object using pthread_attr_init()
15  * 2.  Create many threads using the same attribute object.
16  *
17  */
18 
19 #include <pthread.h>
20 #include <stdio.h>
21 #include <errno.h>
22 #include "posixtest.h"
23 
24 #define NUM_THREADS	5
25 
a_thread_func(void * attr)26 void *a_thread_func(void *attr)
27 {
28 	pthread_exit(NULL);
29 	return NULL;
30 }
31 
main()32 int main()
33 {
34 	pthread_t new_threads[NUM_THREADS];
35 	pthread_attr_t new_attr;
36 	int i, ret;
37 
38 	/* Initialize attribute */
39 	if(pthread_attr_init(&new_attr) != 0)
40 	{
41 		perror("Cannot initialize attribute object\n");
42 		return PTS_UNRESOLVED;
43 	}
44 
45 	/* Create [NUM_THREADS] number of threads with the same attribute
46 	 * object. */
47 	for(i=0;i<NUM_THREADS;i++)
48 	{
49 		ret=pthread_create(&new_threads[i], &new_attr, a_thread_func, NULL);
50 		if((ret != 0) && (ret == EINVAL))
51 		{
52 			printf("Test FAILED\n");
53 			return PTS_FAIL;
54 		}
55 		else if(ret !=0)
56 		{
57 			perror("Error creating thread\n");
58 			return PTS_UNRESOLVED;
59 		}
60 	}
61 
62 	printf("Test PASSED\n");
63 	return PTS_PASS;
64 
65 }
66 
67 
68