equal
deleted
inserted
replaced
775 |
775 |
776 ////////////////////////////////////////////////////////////////////////////// |
776 ////////////////////////////////////////////////////////////////////////////// |
777 // create new thread |
777 // create new thread |
778 |
778 |
779 // Thread start routine for all newly created threads |
779 // Thread start routine for all newly created threads |
780 static void *java_start(Thread *thread) { |
780 static void *thread_native_entry(Thread *thread) { |
781 |
781 |
782 // find out my own stack dimensions |
782 // find out my own stack dimensions |
783 { |
783 { |
784 // actually, this should do exactly the same as thread->record_stack_base_and_size... |
784 // actually, this should do exactly the same as thread->record_stack_base_and_size... |
785 address base = 0; |
785 address base = 0; |
835 // Call one more level start routine. |
835 // Call one more level start routine. |
836 thread->run(); |
836 thread->run(); |
837 |
837 |
838 log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", kernel thread id: " UINTX_FORMAT ").", |
838 log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", kernel thread id: " UINTX_FORMAT ").", |
839 os::current_thread_id(), (uintx) kernel_thread_id); |
839 os::current_thread_id(), (uintx) kernel_thread_id); |
|
840 |
|
841 // If a thread has not deleted itself ("delete this") as part of its |
|
842 // termination sequence, we have to ensure thread-local-storage is |
|
843 // cleared before we actually terminate. No threads should ever be |
|
844 // deleted asynchronously with respect to their termination. |
|
845 if (Thread::current_or_null_safe() != NULL) { |
|
846 assert(Thread::current_or_null_safe() == thread, "current thread is wrong"); |
|
847 thread->clear_thread_current(); |
|
848 } |
840 |
849 |
841 return 0; |
850 return 0; |
842 } |
851 } |
843 |
852 |
844 bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { |
853 bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { |
900 |
909 |
901 stack_size = MAX2(stack_size, os::Aix::min_stack_allowed); |
910 stack_size = MAX2(stack_size, os::Aix::min_stack_allowed); |
902 pthread_attr_setstacksize(&attr, stack_size); |
911 pthread_attr_setstacksize(&attr, stack_size); |
903 |
912 |
904 pthread_t tid; |
913 pthread_t tid; |
905 int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread); |
914 int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); |
906 |
915 |
907 |
916 |
908 char buf[64]; |
917 char buf[64]; |
909 if (ret == 0) { |
918 if (ret == 0) { |
910 log_info(os, thread)("Thread started (pthread id: " UINTX_FORMAT ", attributes: %s). ", |
919 log_info(os, thread)("Thread started (pthread id: " UINTX_FORMAT ", attributes: %s). ", |
991 |
1000 |
992 // Free OS resources related to the OSThread |
1001 // Free OS resources related to the OSThread |
993 void os::free_thread(OSThread* osthread) { |
1002 void os::free_thread(OSThread* osthread) { |
994 assert(osthread != NULL, "osthread not set"); |
1003 assert(osthread != NULL, "osthread not set"); |
995 |
1004 |
996 if (Thread::current()->osthread() == osthread) { |
1005 // We are told to free resources of the argument thread, |
997 // Restore caller's signal mask |
1006 // but we can only really operate on the current thread. |
998 sigset_t sigmask = osthread->caller_sigmask(); |
1007 assert(Thread::current()->osthread() == osthread, |
999 pthread_sigmask(SIG_SETMASK, &sigmask, NULL); |
1008 "os::free_thread but not current thread"); |
1000 } |
1009 |
|
1010 // Restore caller's signal mask |
|
1011 sigset_t sigmask = osthread->caller_sigmask(); |
|
1012 pthread_sigmask(SIG_SETMASK, &sigmask, NULL); |
1001 |
1013 |
1002 delete osthread; |
1014 delete osthread; |
1003 } |
1015 } |
1004 |
1016 |
1005 //////////////////////////////////////////////////////////////////////////////// |
1017 //////////////////////////////////////////////////////////////////////////////// |