Lines Matching defs:thread

158 /* Signal number used to suspend/resume a thread */
302 // Returns the kernel thread id of the currently running thread. Kernel
303 // thread id is used to access /proc.
305 // (Note that getpid() on LinuxThreads returns kernel thread id too; but
545 // BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all
550 // interference with shutdown hooks and BREAK_SIGNAL thread dumping.
576 // Fill in signals that are blocked by all but the VM thread.
584 // These are signals that are unblocked while a thread is running Java.
591 // These are the signals that are blocked while a (non-VM) thread is
592 // running Java. Only the VM thread handles these signals.
604 void os::Linux::hotspot_sigmask(Thread* thread) {
610 OSThread* osthread = thread->osthread();
616 if (thread->is_VM_thread()) {
617 // Only the VM thread handles BREAK_SIGNAL ...
691 // thread stack
693 // Force Linux kernel to expand current thread stack. If "bottom" is close
697 // A special mmap() flag that is used to implement thread stacks. It tells
700 // when creating a new thread. Linux kernel will automatically expand thread
711 // This Linux feature can cause SIGSEGV when VM bangs thread stack for
715 // not use this flag. However, the stack of initial thread is not created
717 // unlikely) that user code can create a thread with MAP_GROWSDOWN stack
718 // and then attach the thread to JVM.
721 // manually expand thread stack after receiving the SIGSEGV.
723 // There are two ways to expand thread stack to address "bottom", we used
791 // create new thread
795 // check if it's safe to start a new thread
796 static bool _thread_safety_check(Thread* thread) {
800 // allocated (MAP_FIXED) from high address space. Every thread stack
806 // many threads and/or very large heap, eventually thread stack will
825 // Unlike fixed stack LinuxThreads, thread stacks are not MAP_FIXED. When
833 static void *java_start(Thread *thread) {
843 ThreadLocalStorage::set_thread(thread);
845 OSThread* osthread = thread->osthread();
849 if (!_thread_safety_check(thread)) {
850 // notify parent thread
857 // thread_id is kernel thread id (similar to Solaris LWP id)
863 thread->set_lgrp_id(lgrp_id);
866 // initialize signal mask for this thread
867 os::Linux::hotspot_sigmask(thread);
872 // handshaking with parent thread
876 // notify parent thread
887 thread->run();
892 bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) {
893 assert(thread->osthread() == NULL, "caller responsible");
901 // set the correct thread state
907 thread->set_osthread(osthread);
909 // init thread attributes
954 // Serialize thread creation if we are running with fixed stack LinuxThreads
961 int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread);
970 thread->set_osthread(NULL);
979 // Wait until child thread is either initialized or aborted
993 // Aborted due to thread limit being reached
995 thread->set_osthread(NULL);
1000 // The thread is returned suspended (in state INITIALIZED),
1007 // attach existing thread
1009 // bootstrap the main thread
1010 bool os::create_main_thread(JavaThread* thread) {
1011 assert(os::Linux::_main_thread == pthread_self(), "should be called inside main thread");
1012 return create_attached_thread(thread);
1015 bool os::create_attached_thread(JavaThread* thread) {
1017 thread->verify_not_published();
1034 // Initial thread state is RUNNABLE
1037 thread->set_osthread(osthread);
1042 thread->set_lgrp_id(lgrp_id);
1047 // If current thread is initial thread, its stack is mapped on demand,
1056 JavaThread *jt = (JavaThread *)thread;
1066 // initialize signal mask for this thread
1068 os::Linux::hotspot_sigmask(thread);
1073 void os::pd_start_thread(Thread* thread) {
1074 OSThread * osthread = thread->osthread();
1095 // thread local storage
1100 assert(rslt == 0, "cannot allocate thread local storage");
1117 return ThreadLocalStorage::thread();
1121 // initial thread
1123 // Check if current thread is the initial thread, similar to Solaris thr_main.
1126 // If called before init complete, thread stack bottom will be null.
1131 "os::init did not locate initial thread's stack region");
1162 // Locate initial thread stack. This special handling of initial thread stack
1164 // bogus value for initial thread.
1181 // for initial thread if its stack size exceeds 6M. Cap it at 2M,
1246 // Figure what the primordial thread stack base is. Code is inspired
1310 // product mode - assume we are the initial thread, good luck in the
1312 warning("Can't detect initial thread stack location - bad conversion");
1319 warning("Can't detect initial thread stack location - no /proc/self/stat");
1335 // thread stack grows on demand, its real bottom is high - RLIMIT_STACK.)
1339 warning("Can't detect initial thread stack location - find_vma failed");
1461 // Switch to using fast clocks for thread cpu time if
1463 // Note, that some kernels may support the current thread
1583 out.print_raw("Current thread is ");
1597 // _exit() on LinuxThreads only kills current thread
1625 // Under the old linux thread library, linux gives each thread
1626 // its own process id. Because of this each thread will return
1629 // of the launcher thread for the vm. This implementation
1630 // returns a unique pid, the pid of the launcher thread
1634 // launcher thread rather than a unique pid per thread.
1638 // returns a unique pid for the calling thread, then look at the
1882 assert(Thread::current()->is_Java_thread(), "must be Java thread");
1885 // This happens when a compiler thread tries to load a hsdis-<arch>.so file
2422 // 4511530 - sem_post is serialized and handled by the manager thread. When
2423 // the program is interrupted by Ctrl-C, SIGINT is sent to every thread. We
2424 // don't want to flood the manager thread with sem_post requests.
2558 JavaThread *thread = JavaThread::current();
2559 ThreadBlockInVM tbivm(thread);
2563 thread->set_suspend_equivalent();
2568 threadIsSuspended = thread->handle_special_suspend_equivalent_condition();
2572 // another thread suspended us. We don't want to continue running
2573 // while suspended because that would surprise the thread that
2578 thread->java_suspend_self();
2985 // the stack guard pages is not removed when we detach a thread the
3001 // writing thread stacks don't use growable mappings (i.e. those
3003 // only applies to the main thread.
3041 // mapping. This only affects the main/initial thread, but guard
3048 "growable stack in non-initial thread");
3058 // affects the main/initial thread, but guard against future OS changes
3064 "growable stack in non-initial thread");
3522 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
3523 assert(thread == Thread::current(), "thread consistency check");
3525 ParkEvent * const slp = thread->_SleepEvent ;
3533 if (os::is_interrupted(thread, true)) {
3554 assert(thread->is_Java_thread(), "sanity check");
3555 JavaThread *jt = (JavaThread *) thread;
3570 OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
3631 // thread priority support
3640 // The following code actually changes the niceness of kernel-thread/LWP. It
3641 // has an assumption that setpriority() only modifies one kernel-thread/LWP,
3669 // Only root can raise thread priority. Don't allow ThreadPriorityPolicy=1
3685 OSReturn os::set_native_priority(Thread* thread, int newpri) {
3688 int ret = setpriority(PRIO_PROCESS, thread->osthread()->thread_id(), newpri);
3692 OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) {
3699 *priority_ptr = getpriority(PRIO_PROCESS, thread->osthread()->thread_id());
3714 // that runs in the watcher thread.
3720 // - sends a signal to the target thread
3722 // - target thread signal handler (SR_handler) sets suspend state
3742 // Handler function invoked when a thread's execution is suspended or
3760 Thread* thread = Thread::current();
3761 OSThread* osthread = thread->osthread();
3762 assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread");
3856 // before bailing out on suspending a thread, also how often
3857 // we send a signal to a thread we want to resume
3864 assert(osthread->sr.is_running(), "thread should be running");
3903 assert(osthread->sr.is_suspended(), "thread should be suspended");
3930 void os::interrupt(Thread* thread) {
3931 assert(Thread::current() == thread || Threads_lock->owned_by_self(),
3934 OSThread* osthread = thread->osthread();
3938 // More than one thread can get here with the same value of osthread,
3942 ParkEvent * const slp = thread->_SleepEvent ;
3947 if (thread->is_Java_thread())
3948 ((JavaThread*)thread)->parker()->unpark();
3950 ParkEvent * ev = thread->_ParkEvent ;
3955 bool os::is_interrupted(Thread* thread, bool clear_interrupted) {
3956 assert(Thread::current() == thread || Threads_lock->owned_by_self(),
3959 OSThread* osthread = thread->osthread();
3965 // consider thread->_SleepEvent->reset() ... optional optimization
4223 // This is the fastest way to get thread cpu time on Linux.
4224 // Returns cpu time (user+sys) for any thread, not only for current.
4448 // With LinuxThreads the JavaMain thread pid (primordial thread)
4449 // is different than the pid of the java launcher thread.
4450 // So, on Linux, the launcher thread pid is passed to the VM
4473 // main_thread points to the aboriginal thread
4535 // Check minimum allowable stack size for thread creation and to initialize
4537 // size. Add a page for compiler2 recursion in main thread.
4616 // Initialize lock used to serialize thread creation (see os::create_thread)
4638 // initialize thread priority policy
4704 PcFetcher(Thread* thread) : os::SuspendedThreadTask(thread) {}
4718 Thread* thread = context.thread();
4719 OSThread* osthread = thread->osthread();
4724 guarantee(thread->is_VM_thread(), "can only be called for VMThread");
4730 ExtendedPC os::get_thread_pc(Thread* thread) {
4733 assert(thread->is_VM_thread(), "Can only be called for VMThread");
4735 PcFetcher fetcher(thread);
4815 // able to use structured exception handling (thread-local exception filters)
4819 JavaCallArguments* args, Thread* thread) {
4820 f(value, method, args, thread);
5069 static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time);
5071 static clockid_t thread_cpu_clockid(Thread* thread) {
5072 pthread_t tid = thread->osthread()->pthread_id();
5075 // Get thread clockid
5083 // of a thread.
5097 jlong os::thread_cpu_time(Thread* thread) {
5100 return os::Linux::fast_thread_cpu_time(thread_cpu_clockid(thread));
5102 return slow_thread_cpu_time(thread, true /* user + sys */);
5114 jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
5116 return os::Linux::fast_thread_cpu_time(thread_cpu_clockid(thread));
5118 return slow_thread_cpu_time(thread, user_sys_cpu_time);
5126 static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
5130 pid_t tid = thread->osthread()->thread_id();
5166 // The /proc/self/task/<tid>/stat still has the per-thread usage.
5276 // This is palliative and probabilistic, however. If the thread is preempted
5282 // 2. Modify park-unpark to use per-thread (per ParkEvent) pipe-pairs instead
5286 // thread.
5288 // 3. Embargo pthread_cond_timedwait() and implement a native "chron" thread
5290 // a timeout request to the chron thread and then blocking via pthread_cond_wait().
5355 // Invariant: Only the thread associated with the Event/PlatformEvent
5400 // We do this the hard way, by blocking the thread.
5414 // (c) thread.interrupt
5417 // That is, we treat thread.interrupt as a special case of notification.
5457 // -1 :=> either 0 or 1; must signal target thread
5465 // thread to block. This has the benefit of forcing a spurious return
5471 // Wait for the thread associated with the event to vacate
5489 // circumstances this can cause a thread to return prematurely from
5503 * sets count to 1 and signals condvar. Only one thread ever waits
5579 Thread* thread = Thread::current();
5580 assert(thread->is_Java_thread(), "Must be JavaThread");
5581 JavaThread *jt = (JavaThread *)thread;
5585 if (Thread::is_interrupted(thread, false)) {
5601 // The per-thread Parker:: mutex is a classic leaf-lock.
5602 // In particular a thread must never block on the Threads_lock while
5609 if (Thread::is_interrupted(thread, false) || pthread_mutex_trylock(_mutex) != 0) {
5626 // (This allows a debugger to break into the running thread.)
5632 OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
5724 // first to kill every thread on the thread list. Because this list is
5726 // every thread in the parent process. We know this is the only thread
5826 // A thread to watch the '/dev/mem_notify' device, which will tell us when the OS is running low on memory.
5884 // See if the /dev/mem_notify device exists, and if so, start a thread to monitor it.