Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: createthr.c | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | #include <sys/types.h> | |
24 | #include <sys/socket.h> | |
25 | #include <errno.h> | |
26 | #include <pthread.h> | |
27 | #include <stdlib.h> | |
28 | ||
29 | #include "basics.h" | |
30 | #include "fatal.h" | |
31 | #include "createthr.h" | |
32 | ||
33 | void create_thread(void *(*start_funcp)(void *), void * argp, pthread_t * idp) | |
34 | { | |
35 | int res; | |
36 | /* create the execution thread */ | |
37 | ||
38 | do { | |
39 | pthread_attr_t attr; | |
40 | pthread_attr_init(&attr); /* initialize attr with default attributes */ | |
41 | pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); /* schedule like a process */ | |
42 | res = pthread_create( idp, &attr, start_funcp, argp ); | |
43 | pthread_attr_destroy(&attr); | |
44 | } while (res == -1 && errno == EAGAIN); | |
45 | if (res == -1) fatal("failed to create thread"); | |
46 | } | |
47 |