src/os/linux/vm/os_linux.hpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2009, 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 



  25 // Linux_OS defines the interface to Linux operating systems
  26 
  27 /* pthread_getattr_np comes with LinuxThreads-0.9-7 on RedHat 7.1 */
  28 typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *);
  29 
  30 class Linux {
  31   friend class os;
  32 
  33   // For signal-chaining
  34 #define MAXSIGNUM 32
  35   static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
  36   static unsigned int sigs;             // mask of signals that have
  37                                         // preinstalled signal handlers
  38   static bool libjsig_is_loaded;        // libjsig that interposes sigaction(),
  39                                         // __sigaction(), signal() is loaded
  40   static struct sigaction *(*get_signal_action)(int);
  41   static struct sigaction *get_preinstalled_handler(int);
  42   static void save_preinstalled_handler(int, struct sigaction&);
  43 
  44   static void check_signal_handler(int sig);


 311     void SetAssociation (Thread * a) { _Assoc = a ; }
 312 } ;
 313 
 314 class PlatformParker : public CHeapObj {
 315   protected:
 316     pthread_mutex_t _mutex [1] ;
 317     pthread_cond_t  _cond  [1] ;
 318 
 319   public:       // TODO-FIXME: make dtor private
 320     ~PlatformParker() { guarantee (0, "invariant") ; }
 321 
 322   public:
 323     PlatformParker() {
 324       int status;
 325       status = pthread_cond_init (_cond, NULL);
 326       assert_status(status == 0, status, "cond_init");
 327       status = pthread_mutex_init (_mutex, NULL);
 328       assert_status(status == 0, status, "mutex_init");
 329     }
 330 } ;


   1 /*
   2  * Copyright (c) 1999, 2010, 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef OS_LINUX_VM_OS_LINUX_HPP
  26 #define OS_LINUX_VM_OS_LINUX_HPP
  27 
  28 // Linux_OS defines the interface to Linux operating systems
  29 
  30 /* pthread_getattr_np comes with LinuxThreads-0.9-7 on RedHat 7.1 */
  31 typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *);
  32 
  33 class Linux {
  34   friend class os;
  35 
  36   // For signal-chaining
  37 #define MAXSIGNUM 32
  38   static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
  39   static unsigned int sigs;             // mask of signals that have
  40                                         // preinstalled signal handlers
  41   static bool libjsig_is_loaded;        // libjsig that interposes sigaction(),
  42                                         // __sigaction(), signal() is loaded
  43   static struct sigaction *(*get_signal_action)(int);
  44   static struct sigaction *get_preinstalled_handler(int);
  45   static void save_preinstalled_handler(int, struct sigaction&);
  46 
  47   static void check_signal_handler(int sig);


 314     void SetAssociation (Thread * a) { _Assoc = a ; }
 315 } ;
 316 
 317 class PlatformParker : public CHeapObj {
 318   protected:
 319     pthread_mutex_t _mutex [1] ;
 320     pthread_cond_t  _cond  [1] ;
 321 
 322   public:       // TODO-FIXME: make dtor private
 323     ~PlatformParker() { guarantee (0, "invariant") ; }
 324 
 325   public:
 326     PlatformParker() {
 327       int status;
 328       status = pthread_cond_init (_cond, NULL);
 329       assert_status(status == 0, status, "cond_init");
 330       status = pthread_mutex_init (_mutex, NULL);
 331       assert_status(status == 0, status, "mutex_init");
 332     }
 333 } ;
 334 
 335 #endif // OS_LINUX_VM_OS_LINUX_HPP