Android进程创建流程-2

一、java线程创建流程

1. 部分调用逻辑

复制代码
        Runtime::AttachCurrentThread(const char* thread_name, bool as_daemon, jobject thread_group, bool create_peer)
        Runtime::Init(RuntimeArgumentMap&& runtime_options_in) //runtime.cc 备注说"ClassLinker needs an attached thread"
            Thread::Attach(const char* thread_name, bool as_daemon, jobject thread_peer)
            Thread::Attach() //4个参数的
                Thread::Attach(const char* thread_name, bool as_daemon, PeerAction peer_action)
    start() //ava/lang/Thread.java         
        Thread_nativeCreate(JNIEnv* env, jclass, jobject java_thread, jlong stack_size, jboolean daemon) //java_lang_Thread.cc
            Thread::CreateNativeThread(JNIEnv*, jobject, size_t, bool is_daemon) //thread.cc 作为pthread_create()这个函数的参数调用
                Thread::CreateCallback(void* arg) //thread.cc
                    Thread::Init(ThreadList*, JavaVMExt*, JNIEnvExt*= nullptr) //thread.cc 两个参数三个参数都行
jni/com_android_internal_os_Zygote.cpp 中有多处调用
    SpecializeCommon(JNIEnv* env, uid_t uid,...) //com_android_internal_os_Zygote.cpp  JNI调java
        callPostForkChildHooks(int runtimeFlags, boolean isSystemServer, boolean isZygote, String instructionSet) //Zygote.java
            postForkChild(int runtimeFlags, boolean isSystemServer, boolean isZygote, String instructionSet) //ZygoteHooks.java
                ZygoteHooks_nativePostForkChild(env, jclass, ...) //dalvik_system_ZygoteHooks.cc
                    Thread::InitAfterFork() //thread.cc
                        Thread::InitTid() //thread.cc
                            tls32_.tid = ::art::GetTid();
                                syscall(__NR_gettid); //utils.cc
复制代码

TODO

 

posted on   Hello-World3  阅读(20)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示