< prev index next >

src/java.base/unix/native/libjli/java_md_solinux.c

Print this page


   1 /*
   2  * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 881     if (hSplashLib) {
 882         dlclose(hSplashLib);
 883         hSplashLib = NULL;
 884     }
 885 }
 886 
 887 /*
 888  * Block current thread and continue execution in a new thread
 889  */
 890 int
 891 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 892     int rslt;
 893 #ifndef __solaris__
 894     pthread_t tid;
 895     pthread_attr_t attr;
 896     pthread_attr_init(&attr);
 897     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 898 
 899     if (stack_size > 0) {
 900       pthread_attr_setstacksize(&attr, stack_size);

 901     }
 902 
 903     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
 904       void * tmp;
 905       pthread_join(tid, &tmp);
 906       rslt = (int)(intptr_t)tmp;
 907     } else {
 908      /*
 909       * Continue execution in current thread if for some reason (e.g. out of
 910       * memory/LWP)  a new thread can't be created. This will likely fail
 911       * later in continuation as JNI_CreateJavaVM needs to create quite a
 912       * few new threads, anyway, just give it a try..
 913       */
 914       rslt = continuation(args);
 915     }
 916 
 917     pthread_attr_destroy(&attr);
 918 #else /* __solaris__ */
 919     thread_t tid;
 920     long flags = 0;


   1 /*
   2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 881     if (hSplashLib) {
 882         dlclose(hSplashLib);
 883         hSplashLib = NULL;
 884     }
 885 }
 886 
 887 /*
 888  * Block current thread and continue execution in a new thread
 889  */
 890 int
 891 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 892     int rslt;
 893 #ifndef __solaris__
 894     pthread_t tid;
 895     pthread_attr_t attr;
 896     pthread_attr_init(&attr);
 897     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 898 
 899     if (stack_size > 0) {
 900       pthread_attr_setstacksize(&attr, stack_size);
 901       pthread_attr_setguardsize(&attr, 0); // no pthread guard page on java threads
 902     }
 903 
 904     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
 905       void * tmp;
 906       pthread_join(tid, &tmp);
 907       rslt = (int)(intptr_t)tmp;
 908     } else {
 909      /*
 910       * Continue execution in current thread if for some reason (e.g. out of
 911       * memory/LWP)  a new thread can't be created. This will likely fail
 912       * later in continuation as JNI_CreateJavaVM needs to create quite a
 913       * few new threads, anyway, just give it a try..
 914       */
 915       rslt = continuation(args);
 916     }
 917 
 918     pthread_attr_destroy(&attr);
 919 #else /* __solaris__ */
 920     thread_t tid;
 921     long flags = 0;


< prev index next >