1 /*
2 * Copyright (c) 1999, 2012, 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 *
193 static bool supports_fast_thread_cpu_time() {
194 return _supports_fast_thread_cpu_time;
195 }
196
197 static jlong fast_thread_cpu_time(clockid_t clockid);
198
199 // Stack repair handling
200
201 // none present
202
203 // LinuxThreads work-around for 6292965
204 static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
205
206
207 // Linux suspend/resume support - this helper is a shadow of its former
208 // self now that low-level suspension is barely used, and old workarounds
209 // for LinuxThreads are no longer needed.
210 class SuspendResume {
211 private:
212 volatile int _suspend_action;
213 // values for suspend_action:
214 #define SR_NONE (0x00)
215 #define SR_SUSPEND (0x01) // suspend request
216 #define SR_CONTINUE (0x02) // resume request
217
218 volatile jint _state;
219 // values for _state: + SR_NONE
220 #define SR_SUSPENDED (0x20)
221 public:
222 SuspendResume() { _suspend_action = SR_NONE; _state = SR_NONE; }
223
224 int suspend_action() const { return _suspend_action; }
225 void set_suspend_action(int x) { _suspend_action = x; }
226
227 // atomic updates for _state
228 void set_suspended() {
229 jint temp, temp2;
230 do {
231 temp = _state;
232 temp2 = Atomic::cmpxchg(temp | SR_SUSPENDED, &_state, temp);
233 } while (temp2 != temp);
234 }
235 void clear_suspended() {
236 jint temp, temp2;
237 do {
238 temp = _state;
239 temp2 = Atomic::cmpxchg(temp & ~SR_SUSPENDED, &_state, temp);
240 } while (temp2 != temp);
241 }
242 bool is_suspended() { return _state & SR_SUSPENDED; }
243
244 #undef SR_SUSPENDED
245 };
246
247 private:
248 typedef int (*sched_getcpu_func_t)(void);
249 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
250 typedef int (*numa_max_node_func_t)(void);
251 typedef int (*numa_available_func_t)(void);
252 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
253 typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
254
255 static sched_getcpu_func_t _sched_getcpu;
256 static numa_node_to_cpus_func_t _numa_node_to_cpus;
257 static numa_max_node_func_t _numa_max_node;
258 static numa_available_func_t _numa_available;
259 static numa_tonode_memory_func_t _numa_tonode_memory;
260 static numa_interleave_memory_func_t _numa_interleave_memory;
261 static unsigned long* _numa_all_nodes;
262
263 static void set_sched_getcpu(sched_getcpu_func_t func) { _sched_getcpu = func; }
264 static void set_numa_node_to_cpus(numa_node_to_cpus_func_t func) { _numa_node_to_cpus = func; }
|
1 /*
2 * Copyright (c) 1999, 2013, 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 *
193 static bool supports_fast_thread_cpu_time() {
194 return _supports_fast_thread_cpu_time;
195 }
196
197 static jlong fast_thread_cpu_time(clockid_t clockid);
198
199 // Stack repair handling
200
201 // none present
202
203 // LinuxThreads work-around for 6292965
204 static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
205
206
207 // Linux suspend/resume support - this helper is a shadow of its former
208 // self now that low-level suspension is barely used, and old workarounds
209 // for LinuxThreads are no longer needed.
210 class SuspendResume {
211 private:
212 volatile int _suspend_action;
213 volatile jint _state;
214 public:
215 // values for suspend_action:
216 enum {
217 SR_NONE = 0x00,
218 SR_SUSPEND = 0x01, // suspend request
219 SR_CONTINUE = 0x02, // resume request
220 SR_SUSPENDED = 0x20 // values for _state: + SR_NONE
221 };
222
223 SuspendResume() { _suspend_action = SR_NONE; _state = SR_NONE; }
224
225 int suspend_action() const { return _suspend_action; }
226 void set_suspend_action(int x) { _suspend_action = x; }
227
228 // atomic updates for _state
229 inline void set_suspended();
230 inline void clear_suspended();
231 bool is_suspended() { return _state & SR_SUSPENDED; }
232
233 };
234
235 private:
236 typedef int (*sched_getcpu_func_t)(void);
237 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
238 typedef int (*numa_max_node_func_t)(void);
239 typedef int (*numa_available_func_t)(void);
240 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
241 typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
242
243 static sched_getcpu_func_t _sched_getcpu;
244 static numa_node_to_cpus_func_t _numa_node_to_cpus;
245 static numa_max_node_func_t _numa_max_node;
246 static numa_available_func_t _numa_available;
247 static numa_tonode_memory_func_t _numa_tonode_memory;
248 static numa_interleave_memory_func_t _numa_interleave_memory;
249 static unsigned long* _numa_all_nodes;
250
251 static void set_sched_getcpu(sched_getcpu_func_t func) { _sched_getcpu = func; }
252 static void set_numa_node_to_cpus(numa_node_to_cpus_func_t func) { _numa_node_to_cpus = func; }
|