系統啓動

ZygoteInit.java

        public static void main(String argv[]) {
               //創建socketServer
800            zygoteServer.registerServerSocketFromEnv(socketName);
801            // In some configurations, we avoid preloading resources and classes eagerly.
802            // In such cases, we will preload things prior to our first fork.
803            if (!enableLazyPreload) {
                   //加載系統class和frameworkResource
807                preload(bootTimingsTraceLog);

811            }
814
              //fork SystemServer進程
833           Runnable r = forkSystemServer(abiList, socketName, zygoteServer);

847            caller = zygoteServer.runSelectLoop(abiList);
848        } catch (Throwable ex) {
849            Log.e(TAG, "System zygote died with exception", ex);
850            throw ex;
851        }
854
855        // We're in the child process and have exited the select loop. Proceed to execute the
856        // command.
857        if (caller != null) {
858            caller.run();
859        }
860    }


123    static void preload(TimingsTraceLog bootTimingsTraceLog) {
129        preloadClasses();
132        preloadResources();
138        preloadOpenGL();
150    }

 Zygote.java

185    public static int forkSystemServer(int uid, int gid, int[] gids, int runtimeFlags,
186            int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) {
187        VM_HOOKS.preFork();
188        // Resets nice priority for zygote process.
189        resetNicePriority();
190        int pid = nativeForkSystemServer(
191                uid, gid, gids, runtimeFlags, rlimits, permittedCapabilities, effectiveCapabilities);
192        // Enable tracing as soon as we enter the system_server.
193        if (pid == 0) {
194            Trace.setTracingEnabled(true, runtimeFlags);
195        }
196        VM_HOOKS.postForkCommon();
197        return pid;
198    }

SystemServer.java

293    public static void main(String[] args) {
294        new SystemServer().run();
295    }


 private void run() {
426        // Start services.
427        try {
429            startBootstrapServices();
430            startCoreServices();
431            startOtherServices();
432            SystemServerInitThreadPool.shutdown();
433        } catch (Throwable ex) {
434            Slog.e("System", "******************************************");
435            Slog.e("System", "************ Failure starting system services", ex);
436            throw ex;
437        } finally {
438            traceEnd();
439        }

452
453        // Loop forever.
454        Looper.loop();
455        throw new RuntimeException("Main thread loop unexpectedly exited");
456    }


537    private void startBootstrapServices() {
557        // Activity manager runs the show.
558        traceBeginAndSlog("StartActivityManager");
559        mActivityManagerService = mSystemServiceManager.startService(
560                ActivityManagerService.Lifecycle.class).getService();
561        mActivityManagerService.setSystemServiceManager(mSystemServiceManager);
562        mActivityManagerService.setInstaller(installer);
563        traceEnd();
        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章