-
Notifications
You must be signed in to change notification settings - Fork 865
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9395 from devreal/opal-thread-create-pthread-v5.0.x
Make sure opal_start_thread always spawns pthreads [v5.0.x]
- Loading branch information
Showing
9 changed files
with
98 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,6 @@ headers += \ | |
base/base.h | ||
|
||
libmca_threads_la_SOURCES += \ | ||
base/create_join.c \ | ||
base/threads_base.c \ | ||
base/tsd.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ | ||
/* | ||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana | ||
* University Research and Technology | ||
* Corporation. All rights reserved. | ||
* Copyright (c) 2004-2021 The University of Tennessee and The University | ||
* of Tennessee Research Foundation. All rights | ||
* reserved. | ||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, | ||
* University of Stuttgart. All rights reserved. | ||
* Copyright (c) 2004-2005 The Regents of the University of California. | ||
* All rights reserved. | ||
* Copyright (c) 2007-2018 Los Alamos National Security, LLC. All rights | ||
* reserved. | ||
* Copyright (c) 2015-2016 Research Organization for Information Science | ||
* and Technology (RIST). All rights reserved. | ||
* Copyright (c) 2019 Sandia National Laboratories. All rights reserved. | ||
* | ||
* $COPYRIGHT$ | ||
* | ||
* Additional copyrights may follow | ||
* | ||
* $HEADER$ | ||
*/ | ||
|
||
#include <unistd.h> | ||
#include <pthread.h> | ||
|
||
#include "opal/constants.h" | ||
#include "opal/mca/threads/threads.h" | ||
#include "opal/mca/threads/tsd.h" | ||
#include "opal/prefetch.h" | ||
#include "opal/util/output.h" | ||
#include "opal/util/sys_limits.h" | ||
|
||
/* | ||
* Constructor | ||
*/ | ||
static void opal_thread_construct(opal_thread_t *t) | ||
{ | ||
t->t_run = 0; | ||
t->t_handle = (pthread_t) -1; | ||
} | ||
|
||
OBJ_CLASS_INSTANCE(opal_thread_t, opal_object_t, opal_thread_construct, NULL); | ||
|
||
int opal_thread_start(opal_thread_t *t) | ||
{ | ||
int rc; | ||
|
||
if (OPAL_ENABLE_DEBUG) { | ||
if (NULL == t->t_run || (pthread_t) -1 != t->t_handle) { | ||
return OPAL_ERR_BAD_PARAM; | ||
} | ||
} | ||
|
||
rc = pthread_create(&t->t_handle, NULL, (void *(*) (void *) ) t->t_run, t); | ||
|
||
return 0 == rc ? OPAL_SUCCESS : OPAL_ERR_IN_ERRNO; | ||
} | ||
|
||
int opal_thread_join(opal_thread_t *t, void **thr_return) | ||
{ | ||
int rc = pthread_join(t->t_handle, thr_return); | ||
t->t_handle = (pthread_t) -1; | ||
return 0 == rc ? OPAL_SUCCESS : OPAL_ERR_IN_ERRNO; | ||
} | ||
|
||
bool opal_thread_self_compare(opal_thread_t *t) | ||
{ | ||
return pthread_self() == t->t_handle; | ||
} | ||
|
||
opal_thread_t *opal_thread_get_self(void) | ||
{ | ||
opal_thread_t *t = OBJ_NEW(opal_thread_t); | ||
t->t_handle = pthread_self(); | ||
return t; | ||
} | ||
|
||
void opal_thread_set_main(void) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.