Path: blob/master/src/hotspot/os/bsd/osThread_bsd.cpp
40949 views
/*1* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324// no precompiled headers25#include "memory/allocation.inline.hpp"26#include "runtime/mutexLocker.hpp"27#include "runtime/osThread.hpp"2829#include <signal.h>3031void OSThread::pd_initialize() {32assert(this != NULL, "check");33#ifdef __APPLE__34_thread_id = 0;35#else36_thread_id = NULL;37#endif38_unique_thread_id = 0;39_pthread_id = NULL;40_siginfo = NULL;41_ucontext = NULL;42_expanding_stack = 0;43_alt_sig_stack = NULL;4445sigemptyset(&_caller_sigmask);4647_startThread_lock = new Monitor(Mutex::event, "startThread_lock", true,48Monitor::_safepoint_check_never);49assert(_startThread_lock !=NULL, "check");50}5152// Additional thread_id used to correlate threads in SA53void OSThread::set_unique_thread_id() {54#ifdef __APPLE__55thread_identifier_info_data_t m_ident_info;56mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;5758mach_port_t mach_thread_port = mach_thread_self();59guarantee(mach_thread_port != 0, "just checking");60thread_info(mach_thread_port, THREAD_IDENTIFIER_INFO,61(thread_info_t) &m_ident_info, &count);62mach_port_deallocate(mach_task_self(), mach_thread_port);6364_unique_thread_id = m_ident_info.thread_id;65#endif66}6768void OSThread::pd_destroy() {69delete _startThread_lock;70}717273