hotspot/src/share/vm/gc/shared/workerManager.hpp
changeset 39704 157f39705057
parent 38216 250794c6f95f
child 40096 246c62cd9180
equal deleted inserted replaced
39703:66722c5bc87a 39704:157f39705057
    45   // create all the worker at start should considered a problem so exit.
    45   // create all the worker at start should considered a problem so exit.
    46   // If initializing = false, there are already some number of worker
    46   // If initializing = false, there are already some number of worker
    47   // threads and a failure would not be optimal but should not be fatal.
    47   // threads and a failure would not be optimal but should not be fatal.
    48   template <class WorkerType>
    48   template <class WorkerType>
    49   static uint add_workers (WorkerType* holder,
    49   static uint add_workers (WorkerType* holder,
    50                    uint active_workers,
    50                            uint active_workers,
    51                    uint total_workers,
    51                            uint total_workers,
    52                    uint created_workers,
    52                            uint created_workers,
    53                    os::ThreadType worker_type,
    53                            os::ThreadType worker_type,
    54                    bool initializing) {
    54                            bool initializing) {
    55     uint start = created_workers;
    55     uint start = created_workers;
    56     uint end = MIN2(active_workers, total_workers);
    56     uint end = MIN2(active_workers, total_workers);
    57     for (uint worker_id = start; worker_id < end; worker_id += 1) {
    57     for (uint worker_id = start; worker_id < end; worker_id += 1) {
    58       WorkerThread* new_worker = holder->install_worker(worker_id);
    58       WorkerThread* new_worker = holder->install_worker(worker_id);
    59       assert(new_worker != NULL, "Failed to allocate GangWorker");
    59       assert(new_worker != NULL, "Failed to allocate GangWorker");
    60       if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
    60       if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
    61         if(initializing) {
    61         if (initializing) {
    62           vm_exit_out_of_memory(0, OOM_MALLOC_ERROR,
    62           vm_exit_out_of_memory(0, OOM_MALLOC_ERROR,
    63                   "Cannot create worker GC thread. Out of system resources.");
    63                   "Cannot create worker GC thread. Out of system resources.");
    64         }
    64         }
    65       }
    65       }
    66       created_workers++;
    66       created_workers++;
    67       os::start_thread(new_worker);
    67       os::start_thread(new_worker);
    68     }
    68     }
    69 
    69 
    70     log_trace(gc, task)("AdaptiveSizePolicy::add_workers() : "
    70     return created_workers;
    71        "active_workers: %u created_workers: %u",
    71   }
    72        active_workers, created_workers);
       
    73 
    72 
    74     return created_workers;
    73   // Log (at trace level) a change in the number of created workers.
       
    74   template <class WorkerType>
       
    75   static void log_worker_creation(WorkerType* holder,
       
    76                                   uint previous_created_workers,
       
    77                                   uint active_workers,
       
    78                                   uint created_workers,
       
    79                                   bool initializing) {
       
    80     if (previous_created_workers < created_workers) {
       
    81       const char* initializing_msg =  initializing ? "Adding initial" : "Creating additional";
       
    82       log_trace(gc, task)("%s %s(s) previously created workers %u active workers %u total created workers %u",
       
    83                           initializing_msg, holder->group_name(), previous_created_workers, active_workers, created_workers);
       
    84     }
    75   }
    85   }
    76 };
    86 };
    77 #endif // SHARE_VM_GC_SHARED_WORKERMANAGER_HPP
    87 #endif // SHARE_VM_GC_SHARED_WORKERMANAGER_HPP