hotspot/src/os/solaris/vm/threadCritical_solaris.cpp
changeset 37113 5a33bf5089ac
parent 33105 294e48b4f704
equal deleted inserted replaced
37111:98572401ab0a 37113:5a33bf5089ac
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  *
    22  *
    23  */
    23  */
    24 
    24 
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
       
    26 #include "runtime/os.hpp"
    26 #include "runtime/thread.inline.hpp"
    27 #include "runtime/thread.inline.hpp"
    27 #include "runtime/threadCritical.hpp"
    28 #include "runtime/threadCritical.hpp"
    28 
    29 
    29 // OS-includes here
    30 // OS-includes here
    30 #include <thread.h>
    31 #include <thread.h>
    47   if (initialized) {
    48   if (initialized) {
    48     thread_t owner = thr_self();
    49     thread_t owner = thr_self();
    49     if (global_mut_owner != owner) {
    50     if (global_mut_owner != owner) {
    50       if (os::Solaris::mutex_lock(&global_mut))
    51       if (os::Solaris::mutex_lock(&global_mut))
    51         fatal("ThreadCritical::ThreadCritical: mutex_lock failed (%s)",
    52         fatal("ThreadCritical::ThreadCritical: mutex_lock failed (%s)",
    52               strerror(errno));
    53               os::strerror(errno));
    53       assert(global_mut_count == 0, "must have clean count");
    54       assert(global_mut_count == 0, "must have clean count");
    54       assert(global_mut_owner == -1, "must have clean owner");
    55       assert(global_mut_owner == -1, "must have clean owner");
    55     }
    56     }
    56     global_mut_owner = owner;
    57     global_mut_owner = owner;
    57     ++global_mut_count;
    58     ++global_mut_count;
    66     assert(global_mut_count > 0, "must have correct count");
    67     assert(global_mut_count > 0, "must have correct count");
    67     --global_mut_count;
    68     --global_mut_count;
    68     if (global_mut_count == 0) {
    69     if (global_mut_count == 0) {
    69       global_mut_owner = -1;
    70       global_mut_owner = -1;
    70       if (os::Solaris::mutex_unlock(&global_mut))
    71       if (os::Solaris::mutex_unlock(&global_mut))
    71         fatal("ThreadCritical::~ThreadCritical: mutex_unlock failed (%s)", strerror(errno));
    72         fatal("ThreadCritical::~ThreadCritical: mutex_unlock failed (%s)", os::strerror(errno));
    72     }
    73     }
    73   } else {
    74   } else {
    74     assert (Threads::number_of_threads() == 0, "valid only during initialization");
    75     assert (Threads::number_of_threads() == 0, "valid only during initialization");
    75   }
    76   }
    76 }
    77 }