Android SystemServer 启动流程分析

news2024/11/27 20:58:32

56ef2c3074687a2ad50bc5439efd3042.gif

和你一起终身学习,这里是程序员Android

经典好文推荐,通过阅读本文,您将收获以下知识点:

一、SystemServer 启动的服务有哪些
二、SystemServer启动总体流程概述
三、SystemServer 如何启动,是谁启动的?
四、 SystemServer 启动入门 main 方法
五、SystemServer Run 方法初始与启动
六、SystemServer 的引导服务有哪些
七、SystemServer 的核心服务有哪些
八、SystemServer 的其他服务有哪些

一、SystemServer 启动的服务有哪些

SystemServer 主要启动 ActivityManagerServicePackageManagerServiceWindowManagerServiceLightsServiceLightsServiceBatteryServiceTelephonyRegistryRecoverySystemService 等等,主要分三大类,后文会详细列举。

1.SystemServer 启动的服务

8f0e40d74a34242c6e903bda79e747b6.jpeg

SystemServer 启动的服务

82ae9a630d965309141d50845b22b743.jpeg

SystemServer 启动的服务

二、SystemServer启动总体流程概述

1.SystemServer 代码

\alps\frameworks\base\services\java\com\android\server\SystemServer.java

0ca6220abb88ac469f3b31a69bd911cb.jpeg

SystemServer 进程启动导图

三、SystemServer 如何启动,是谁启动的?

SystemServer是通过Zygote 启动的,在ZygoteInit.java类的(frameworks\base\core\java\com\android\internal\os\ZygoteInit.java) main方法中通过forkSystemServer启动。

public static void main(String argv[]) {
        ....
            //设置变量区分是否启动SystemServer
            boolean startSystemServer = false;
            String socketName = "zygote";
            String abiList = null;
            boolean enableLazyPreload = false;
            for (int i = 1; i < argv.length; i++) {
                if ("start-system-server".equals(argv[i])) {
                   // 需要启动时候,将标志位设置为true
                    startSystemServer = true;
                } else if ("--enable-lazy-preload".equals(argv[i])) {
                    enableLazyPreload = true;
                } 
            ... ...

            if (startSystemServer) {
                // 通过 Zygote  fork 出 SystemServer 
                Runnable r = forkSystemServer(abiList, socketName, zygoteServer);

                // {@code r == null} in the parent (zygote) process, and {@code r != null} in the
                // child (system_server) process.
                if (r != null) {
                    r.run();
                    return;
                }
            }

四、 SystemServer 启动入门 main 方法

main 入口 通过 new SystemServer().run();开启SystemServer启动。

main 入口代码如下:

/**
     * The main entry point from zygote.
     */
    public static void main(String[] args) {
        new SystemServer().run();
    }

通过Main入口,调用SystemServer 构造方法。

public SystemServer() {
        // 检查工程模式.
        mFactoryTestMode = FactoryTest.getMode();
        // 判断是否是重启
        mRuntimeRestart = "1".equals(SystemProperties.get("sys.boot_completed"));

        mRuntimeStartElapsedTime = SystemClock.elapsedRealtime();
        mRuntimeStartUptime = SystemClock.uptimeMillis();
    }

    private void run() {
       ... ...
    }

五、SystemServer Run 方法初始与启动

1.SystemServer Run 方法

private void run() {
        try {
            traceBeginAndSlog("InitBeforeStartServices");
            //初始化时间
            if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {
                Slog.w(TAG, "System clock is before 1970; setting to 1970.");
                SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);
            }

            //设置默认时区
            String timezoneProperty =  SystemProperties.get("persist.sys.timezone");
            if (timezoneProperty == null || timezoneProperty.isEmpty()) {
                Slog.w(TAG, "Timezone not set; setting to GMT.");
                SystemProperties.set("persist.sys.timezone", "GMT");
            }
            ... ... 

            // 开始进入Android SystemServer
            Slog.i(TAG, "Entered the Android system server!");
            int uptimeMillis = (int) SystemClock.elapsedRealtime();
            EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN, uptimeMillis);
            if (!mRuntimeRestart) {
                MetricsLogger.histogram(null, "boot_system_server_init", uptimeMillis);
            }
            ... ...

            //如果支持指纹,需初始化指纹ro.build.fingerprint
            Build.ensureFingerprintProperty();

            ... ...
                
            // 初始化 native services.
            System.loadLibrary("android_servers");

            // 检查最近一次关机是否失败
            performPendingShutdown();

            // 初始化 the system context.
            createSystemContext();

            // 创建 system service manager.
            mSystemServiceManager = new SystemServiceManager(mSystemContext);
            mSystemServiceManager.setStartInfo(mRuntimeRestart,
                    mRuntimeStartElapsedTime, mRuntimeStartUptime);
            LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);
            // 初始化SystemServer 线程池
            SystemServerInitThreadPool.get();
        } finally {
            traceEnd();  // InitBeforeStartServices
        }
         ... ...
         
        // 开始启动 services.
        try {
            traceBeginAndSlog("StartServices");
        // 1. 启动引导服务  详见分析六
            startBootstrapServices();
            // 2. 启动核心服务  详见分析七
            startCoreServices();
            // 3.启动其他服务  详见分析八
            startOtherServices();
            SystemServerInitThreadPool.shutdown();
        } catch (Throwable ex) {
            Slog.e("System", "******************************************");
            Slog.e("System", "************ Failure starting system services", ex);
            throw ex;
        } finally {
            traceEnd();
        }

        StrictMode.initVmDefaults(null);


    }

六、SystemServer 的引导服务有哪些

SystemServer启动的常用引导服务有installed 、DeviceIdentifiersPolicyService、 ActivityManagerService.、PowerManagerService 、 RecoverySystemService 、 LightsService 、 PackageManagerService、UserManagerService、OverlayManagerService等。

275c125847cd7c472fa45ce94cb57cdf.jpeg

启动的引导服务的大致流程

1.startBootstrapServices代码

/**
     * Starts the small tangle of critical services that are needed to get
     * the system off the ground.  These services have complex mutual dependencies
     * which is why we initialize them all in one place here.  Unless your service
     * is also entwined in these dependencies, it should be initialized in one of
     * the other functions.
     */
    private void startBootstrapServices() {
        Slog.i(TAG, "Reading configuration...");
        final String TAG_SYSTEM_CONFIG = "ReadingSystemConfig";
        traceBeginAndSlog(TAG_SYSTEM_CONFIG);
        SystemServerInitThreadPool.get().submit(SystemConfig::getInstance, TAG_SYSTEM_CONFIG);
        traceEnd();

        // 启动 installed
        traceBeginAndSlog("StartInstaller");
        Installer installer = mSystemServiceManager.startService(Installer.class);
        traceEnd();

        //启动 设备标识符 服务
        traceBeginAndSlog("DeviceIdentifiersPolicyService");
        mSystemServiceManager.startService(DeviceIdentifiersPolicyService.class);
        traceEnd();

        // 启动 AMS.
        traceBeginAndSlog("StartActivityManager");
        mActivityManagerService = mSystemServiceManager.startService(
                ActivityManagerService.Lifecycle.class).getService();
        mActivityManagerService.setSystemServiceManager(mSystemServiceManager);
        mActivityManagerService.setInstaller(installer);
        traceEnd();

        //启动 PMS 
        traceBeginAndSlog("StartPowerManager");
        mPowerManagerService = mSystemServiceManager.startService(PowerManagerService.class);
        traceEnd();

        //初始化电源管理功能
        traceBeginAndSlog("InitPowerManagement");
        mActivityManagerService.initPowerManagement();
        traceEnd();

        // 启动 RecoverySystemService 
        traceBeginAndSlog("StartRecoverySystemService");
        mSystemServiceManager.startService(RecoverySystemService.class);
        traceEnd();

        // 为启动事件添加记录
        RescueParty.noteBoot(mSystemContext);

        // 启动 LightsService 管理LEDs 和背光显示
        traceBeginAndSlog("StartLightsService");
        mSystemServiceManager.startService(LightsService.class);
        traceEnd();

        traceBeginAndSlog("StartSidekickService");
        // Package manager isn't started yet; need to use SysProp not hardware feature
        if (SystemProperties.getBoolean("config.enable_sidekick_graphics", false)) {
            mSystemServiceManager.startService(WEAR_SIDEKICK_SERVICE_CLASS);
        }
        traceEnd();

        // Display manager is needed to provide display metrics before package manager
        // starts up.
        traceBeginAndSlog("StartDisplayManager");
        mDisplayManagerService = mSystemServiceManager.startService(LightsService.class);
        traceEnd();

        // We need the default display before we can initialize the package manager.
        traceBeginAndSlog("WaitForDisplay");
        mSystemServiceManager.startBootPhase(SystemService.PHASE_WAIT_FOR_DEFAULT_DISPLAY);
        traceEnd();

        // Only run "core" apps if we're encrypting the device.
        String cryptState = SystemProperties.get("vold.decrypt");
        if (ENCRYPTING_STATE.equals(cryptState)) {
            Slog.w(TAG, "Detected encryption in progress - only parsing core apps");
            mOnlyCore = true;
        } else if (ENCRYPTED_STATE.equals(cryptState)) {
            Slog.w(TAG, "Device encrypted - only parsing core apps");
            mOnlyCore = true;
        }

        // 启动 PackageManagerService
        if (!mRuntimeRestart) {
            MetricsLogger.histogram(null, "boot_package_manager_init_start",
                    (int) SystemClock.elapsedRealtime());
        }
        traceBeginAndSlog("StartPackageManagerService");
        mPackageManagerService = PackageManagerService.main(mSystemContext, installer,
                mFactoryTestMode != FactoryTest.FACTORY_TEST_OFF, mOnlyCore);
        mFirstBoot = mPackageManagerService.isFirstBoot();
        mPackageManager = mSystemContext.getPackageManager();
        traceEnd();
        if (!mRuntimeRestart && !isFirstBootOrUpgrade()) {
            MetricsLogger.histogram(null, "boot_package_manager_init_ready",
                    (int) SystemClock.elapsedRealtime());
        }
        // Manages A/B OTA dexopting. This is a bootstrap service as we need it to rename
        // A/B artifacts after boot, before anything else might touch/need them.
        // Note: this isn't needed during decryption (we don't have /data anyways).
        if (!mOnlyCore) {
            boolean disableOtaDexopt = SystemProperties.getBoolean("config.disable_otadexopt",
                    false);
            if (!disableOtaDexopt) {
                traceBeginAndSlog("StartOtaDexOptService");
                try {
                    OtaDexoptService.main(mSystemContext, mPackageManagerService);
                } catch (Throwable e) {
                    reportWtf("starting OtaDexOptService", e);
                } finally {
                    traceEnd();
                }
            }
        }
        //启动多用户    UserManagerService
        traceBeginAndSlog("StartUserManagerService");
        mSystemServiceManager.startService(UserManagerService.LifeCycle.class);
        traceEnd();

        // 初始化属性缓存
        traceBeginAndSlog("InitAttributerCache");
        AttributeCache.init(mSystemContext);
        traceEnd();

        // Set up the Application instance for the system process and get started.
        traceBeginAndSlog("SetSystemProcess");
        mActivityManagerService.setSystemProcess();
        traceEnd();

        // DisplayManagerService needs to setup android.display scheduling related policies
        // since setSystemProcess() would have overridden policies due to setProcessGroup
        mDisplayManagerService.setupSchedulerPolicies();

        /// M: CTA requirement - permission control  @{
        /*
         * M: MOTA for CTA permissions handling
         * This function is used for granting CTA permissions after OTA upgrade.
         * This should be placed after AMS is added to ServiceManager and before
         * starting other services since granting permissions needs AMS instance
         * to do permission checking.
         */
        mPackageManagerService.onAmsAddedtoServiceMgr();
        /// @}

        //  启动 OverlayManagerService
        traceBeginAndSlog("StartOverlayManagerService");
        mSystemServiceManager.startService(new OverlayManagerService(mSystemContext, installer));
        traceEnd();

        // The sensor service needs access to package manager service, app ops
        // service, and permissions service, therefore we start it after them.
        // Start sensor service in a separate thread. Completion should be checked
        // before using it.
        mSensorServiceStart = SystemServerInitThreadPool.get().submit(() -> {
            TimingsTraceLog traceLog = new TimingsTraceLog(
                    SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
            traceLog.traceBegin(START_SENSOR_SERVICE);
            startSensorService();
            traceLog.traceEnd();
        }, START_SENSOR_SERVICE);
    }

七、SystemServer 的核心服务有哪些

1.SystemServer 核心服务

有 BatteryService 、UsageStatsService、WebViewUpdateService、BinderCallsStatsService4种核心服务。

d6c43282bcf73fe4777c544b55f9237c.jpeg

SystemServer 4种核心服务

2.startCoreServices 代码

/**
     * Starts some essential services that are not tangled up in the bootstrap process.
     */
    private void startCoreServices() {
        // 启动 BatteryService 管理电池服务(电压、电量、温度)
        traceBeginAndSlog("StartBatteryService");
        // Tracks the battery level.  Requires LightService.
        mSystemServiceManager.startService(BatteryService.class);
        traceEnd();

        // 启动 UsageStatsService 收集应用持久化数据的服务
        traceBeginAndSlog("StartUsageService");
        mSystemServiceManager.startService(UsageStatsService.class);
        mActivityManagerService.setUsageStatsManager(
                LocalServices.getService(UsageStatsManagerInternal.class));
        traceEnd();

        // 启动 WebViewUpdateService 监视 WebView 是否更新
        if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_WEBVIEW)) {
            traceBeginAndSlog("StartWebViewUpdateService");
            mWebViewUpdateService = mSystemServiceManager.startService(WebViewUpdateService.class);
            traceEnd();
        }

        //启动 CPU Binder 调度服务
        traceBeginAndSlog("StartBinderCallsStatsService");
        BinderCallsStatsService.start();
        traceEnd();
    }

八、SystemServer 的其他服务有哪些

1.startOtherServices 启动的服务主要有:

KeyChainSystemService、TelecomLoaderService、AccountManagerService、ContentService、DropBoxManagerService、VibratorService、AlarmManagerService、Watchdog、 InputManagerService、WindowManagerService、IpConnectivityMetrics、NetworkWatchlistService、PinnerService等服务。

4cda35975dbcdfdbf81347f6904ba775.jpeg

SystemServer 的其他服务

2.startOtherServices 代码

/**
     * Starts a miscellaneous grab bag of stuff that has yet to be refactored
     * and organized.
     */
    private void startOtherServices() {
            ... ...

            
            traceBeginAndSlog("StartKeyAttestationApplicationIdProviderService");
            ServiceManager.addService("sec_key_att_app_id_provider",
                    new KeyAttestationApplicationIdProviderService(context));
            traceEnd();
            // 启动 KeyChainSystemService 
            traceBeginAndSlog("StartKeyChainSystemService");
            mSystemServiceManager.startService(KeyChainSystemService.class);
            traceEnd();

            traceBeginAndSlog("StartSchedulingPolicyService");
            ServiceManager.addService("scheduling_policy", new SchedulingPolicyService());
            traceEnd();
            // 启动 TelecomLoaderService  
            traceBeginAndSlog("StartTelecomLoaderService");
            mSystemServiceManager.startService(TelecomLoaderService.class);
            traceEnd();

            traceBeginAndSlog("StartTelephonyRegistry");
            telephonyRegistry = new TelephonyRegistry(context);
            ServiceManager.addService("telephony.registry", telephonyRegistry);
            traceEnd();

            traceBeginAndSlog("StartEntropyMixer");
            mEntropyMixer = new EntropyMixer(context);
            traceEnd();

            mContentResolver = context.getContentResolver();

            // 启动 用户管理服务 ,必现在StartContentService 之前
            traceBeginAndSlog("StartAccountManagerService");
            mSystemServiceManager.startService(ACCOUNT_SERVICE_CLASS);
            traceEnd();
            // 启动 ContentService
            traceBeginAndSlog("StartContentService");
            mSystemServiceManager.startService(CONTENT_SERVICE_CLASS);
            traceEnd();
            // 安装系统Provider 例如 SettingProvider CantacttProvider
            traceBeginAndSlog("InstallSystemProviders");
            mActivityManagerService.installSystemProviders();
            // Now that SettingsProvider is ready, reactivate SQLiteCompatibilityWalFlags
            SQLiteCompatibilityWalFlags.reset();
            traceEnd();

            // 启动 DropBoxManagerService  
            // 由于 依赖SettingsProvider,必须在InstallSystemProviders之后启动
            traceBeginAndSlog("StartDropBoxManager");
            mSystemServiceManager.startService(DropBoxManagerService.class);
            traceEnd();
            //启动 VibratorService 震动服务
            traceBeginAndSlog("StartVibratorService");
            vibrator = new VibratorService(context);
            ServiceManager.addService("vibrator", vibrator);
            traceEnd();

            if (!isWatch) {
                traceBeginAndSlog("StartConsumerIrService");
                consumerIr = new ConsumerIrService(context);
                ServiceManager.addService(Context.CONSUMER_IR_SERVICE, consumerIr);
                traceEnd();
            }
            // 启动 AlarmManagerService
            traceBeginAndSlog("StartAlarmManagerService");
            if(!sMtkSystemServerIns.startMtkAlarmManagerService()){
                mSystemServiceManager.startService(AlarmManagerService.class);
            }
            traceEnd();
            // 初始化 看门狗
            traceBeginAndSlog("InitWatchdog");
            final Watchdog watchdog = Watchdog.getInstance();
            watchdog.init(context, mActivityManagerService);
            traceEnd();
            //启动 InputManagerService
            traceBeginAndSlog("StartInputManagerService");
            inputManager = new InputManagerService(context);
            traceEnd();
            //启动 WindowManagerService
            traceBeginAndSlog("StartWindowManagerService");
            // WMS needs sensor service ready
            ConcurrentUtils.waitForFutureNoInterrupt(mSensorServiceStart, START_SENSOR_SERVICE);
            mSensorServiceStart = null;
            wm = WindowManagerService.main(context, inputManager,
                    mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL,
                    !mFirstBoot, mOnlyCore, new PhoneWindowManager());
            ServiceManager.addService(Context.WINDOW_SERVICE, wm, /* allowIsolated= */ false,
                    DUMP_FLAG_PRIORITY_CRITICAL | DUMP_FLAG_PROTO);
            ServiceManager.addService(Context.INPUT_SERVICE, inputManager,
                    /* allowIsolated= */ false, DUMP_FLAG_PRIORITY_CRITICAL);
            traceEnd();

            traceBeginAndSlog("SetWindowManagerService");
            mActivityManagerService.setWindowManager(wm);
            traceEnd();

            traceBeginAndSlog("WindowManagerServiceOnInitReady");
            wm.onInitReady();
            traceEnd();

            // Start receiving calls from HIDL services. Start in in a separate thread
            // because it need to connect to SensorManager. This have to start
            // after START_SENSOR_SERVICE is done.
            SystemServerInitThreadPool.get().submit(() -> {
                TimingsTraceLog traceLog = new TimingsTraceLog(
                        SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
                traceLog.traceBegin(START_HIDL_SERVICES);
                startHidlServices();
                traceLog.traceEnd();
            }, START_HIDL_SERVICES);

            if (!isWatch) {
                traceBeginAndSlog("StartVrManagerService");
                mSystemServiceManager.startService(VrManagerService.class);
                traceEnd();
            }

            traceBeginAndSlog("StartInputManager");
            inputManager.setWindowManagerCallbacks(wm.getInputMonitor());
            inputManager.start();
            traceEnd();

            // TODO: Use service dependencies instead.
            traceBeginAndSlog("DisplayManagerWindowManagerAndInputReady");
            mDisplayManagerService.windowManagerAndInputReady();
            traceEnd();

            // Skip Bluetooth if we have an emulator kernel
            // TODO: Use a more reliable check to see if this product should
            // support Bluetooth - see bug 988521
            if (isEmulator) {
                Slog.i(TAG, "No Bluetooth Service (emulator)");
            } else if (mFactoryTestMode == FactoryTest.FACTORY_TEST_LOW_LEVEL) {
                Slog.i(TAG, "No Bluetooth Service (factory test)");
            } else if (!context.getPackageManager().hasSystemFeature
                       (PackageManager.FEATURE_BLUETOOTH)) {
                Slog.i(TAG, "No Bluetooth Service (Bluetooth Hardware Not Present)");
            } else {
                traceBeginAndSlog("StartBluetoothService");
                mSystemServiceManager.startService(BluetoothService.class);
                traceEnd();
            }
            // 启动 IpConnectivityMetrics
            traceBeginAndSlog("IpConnectivityMetrics");
            mSystemServiceManager.startService(IpConnectivityMetrics.class);
            traceEnd();
            // 启动 NetworkWatchlistService
            traceBeginAndSlog("NetworkWatchlistService");
            mSystemServiceManager.startService(NetworkWatchlistService.Lifecycle.class);
            traceEnd();
            // 启动 PinnerService 
            traceBeginAndSlog("PinnerService");
            mSystemServiceManager.startService(PinnerService.class);
            traceEnd();
        } catch (RuntimeException e) {

参考文献:

【腾讯文档】Android Framework 知识库
https://docs.qq.com/doc/DSXBmSG9VbEROUXF5

友情推荐:

Android 开发干货集锦

至此,本篇已结束。转载网络的文章,小编觉得很优秀,欢迎点击阅读原文,支持原创作者,如有侵权,恳请联系小编删除,欢迎您的建议与指正。同时期待您的关注,感谢您的阅读,谢谢!

5543571b9006a08effc8777e257dd682.jpeg

点击阅读原文,为大佬点赞!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/742201.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

解决哈希冲突

1、HashMap引入了链式寻址法来解决hash冲突&#xff0c;冲突的key&#xff0c;HashMap把这些key组成一个单向链表&#xff0c;然后采用尾插法把key保存到链表的尾部。 使用二次扰动函数&#xff08;hash函数&#xff09;来降低哈希冲突的概率&#xff0c;使数据平均分布。 pu…

【VUE】Unterminated template literal:拼接字符串包括<script></script>时报错误

vue拼接字符串包括时报错误提示Unterminated template literal vue拼接字符串包括script标签时报错误提示Unterminated template literal解决方法加反斜杠就可以&#xff0c;在script结束标签里边加反斜杠<\/script> 代码 htmlData: <div id"b0e5c00cc51e4a4…

svg图标颜色随父元素变换

给svg加上一下样式 fill: currentColor;注&#xff1a;为什么有的svg设置了fill: currentColor;还是一样不生效&#xff1f; 用电脑自带的txt或者代码开发工具&#xff08;如&#xff1a;HbuilderX&#xff09;打开svg文件 全局搜索 fill 把fill指定颜色去掉 保存就OK了

存储函数,存储过程的应用

查看触发器 mysql> show triggers \G *************************** 1. row ***************************Trigger: student_insert_triggerEvent: INSERTTable: studentStatement: BEGINupdate student_total set totaltotal1;ENDTiming: AFTERCreated: 2023-07-11 16:13:51…

msvcp71.dll丢失怎样修复,msvcp71.dll丢失的三个解决方法

在运行游戏&#xff0c;软件程序的时候&#xff0c;电脑提示msvcp71.dll丢失怎样修复&#xff1f;下面小编就开始介绍msvcp71.dll在电脑系统中的的目录&#xff0c;作用&#xff0c;以及丢失后三个解决方法。 目录 msvcp71.dll通常位于系统目录里&#xff1a; msvcp71.dll丢失…

本地git 提交代码时 报错 [session-4d40e187] Access denied

1、首先执行以下命令查看本地是否绑定仓库 git remote -v2、如果没有执行以下命令添加 git remote add name(仓库名) git地址 // 添加成功后执行git remote -v 检查3、提交代码到新仓库&#xff0c;执行以下代码即可 git add . git commit -m fix:init git push name(于第二…

有趣的命令——————用shell脚本实现(石头剪刀布)小游戏

vim games。sh 输入以下内容&#xff1a;#!/bin/bash echo "这是一个小游戏(石头0 剪刀1 布2)&#xff0c;放松一下:" pc$(expr $RANDOM % 3) read -p "请输入你的选择:" user if [ $pc -eq 0 -a $user -eq 2 ] || [ $pc -eq 1 -a $user -eq 0 ] || [ $pc …

单个电源模块带电感的直流压降仿真(三)

单个电源模块带电感的直流压降仿真(三) 接单个电源模块带电感的直流压降仿真(二) 设置负载Sink,按照向导逐步设置

C++好难(9):C++的多态

目录 1.多态的概念 2.多态的定义及实现&#xff1a; &#x1f349;多态的构成条件 &#x1f349;虚函数 &#x1f349;虚函数的重写 &#x1f349;虚函数重写的三个例外 &#x1f352;子类虚函数可以不加vector &#x1f352;析构函数的重写 &#x1f352;协变&#xf…

开源铸剑,五载匠心!Zilliz Cloud云服务盛装登场,引领向量数据库云时代!

2023 年注定是属于大模型和向量数据库的巅峰时刻。国内大模型的发展也迎来前所未有之机遇&#xff0c;“百模”激战正酣。在刚闭幕的世界人工智能大会上&#xff0c;国内外科技公司全线加入&#xff0c;三十余款大模型集中亮相&#xff0c;“国家队”尘埃落定&#xff0c;并正式…

接口测试(二) 优化项目分层及cookies值带入

整个项目分层如图 然后上代码 #data_test.py from openpyxl import load_workbook import json import osclass Date_test():filepath os.path.dirname(os.path.dirname(__file__))def __init__(self):self.case_id Noneself.url Noneself.data Noneself.Method Noneself…

模拟实现C++的string库的改进

之前写过&#xff0c;(8条消息) 模拟实现C的string库_Qianxueban的博客-CSDN博客 比较简单&#xff0c;我就直接截图的。我要改进一下。 1.改进string类中可以在字符串中存储\0 但我写的没有这项功能&#xff0c;究其根本就是代码我用的都是strcpy等等函数&#xff0c;应该用…

5G理论概述

文章目录 SA组网架构及协议栈4-5G核心网侧融合交互5G与4G用户标识5G网络网元和设备类型&#xff0c;接口1、AMF(Access and Mobility Management Function)&#xff0c;接入和移动管理功能2、SMF&#xff08;Session Management function&#xff09;&#xff0c;会话管理功能3…

MQTT快速入门

官网文档 前言&#xff1a; MQTT 是用于物联网连接的 OASIS 标准&#xff0c;它是一种基于发布订阅模式的、轻量级的消息传输协议&#xff0c;专为受限设备和低带宽、高延迟和不可靠的网络设计&#xff0c;并且能够提供一定的消息可靠性保证。得益于这些特性&#xff0c;MQTT…

在vite创建的vue3项目中使用Cesium标记地点(基于加载建筑样式,划分区域)

在vite创建的vue3项目中使用Cesium标记地点&#xff08;基于加载建筑样式&#xff0c;划分区域&#xff09; 使用vite创建vue3项目 npm create vitelatestcd到创建的项目文件夹中 npm install安装Cesium npm i cesium vite-plugin-cesium vite -D配置 vite.config.js文件&#…

通过平均列比较两组迭代次数

( A, B )---3*30*2---( 1, 0 )( 0, 1 ) 让网络的输入只有3个节点&#xff0c;AB训练集各由6张二值化的图片组成&#xff0c;让差值结构中有6个1, 行分布是0&#xff0c;1&#xff0c;1&#xff0c;1&#xff0c;1&#xff0c;2列分布是2&#xff0c;2&#xff0c;2.统计迭代次…

Java-多线程编程——基础篇及相关面试题

这里写目录标题 一、前言二、进程与线程的基本概念三、为什么Java中引入多线程&#xff1f;3.1 并行处理3.2 提高性能3.3 提高响应能力3.4 资源共享3.5 异步编程 四、Java多线程-创建多线程的类和接口4.1 Thread类4.2 Runnable接口 五、示例代码5.1 使用Thread类创建多线程六、…

【Django学习】(十二)GenericAPIView_过滤_排序_分页

上篇文章初步接触了GenericAPIView&#xff0c;这次来更加深入的学习它&#xff0c;了解里面的一些使用和方法 get_object&#xff1a;源码中&#xff1a;处理查询集&#xff0c;并含有所需要得pk值,lookup_fieldget_queryset&#xff1a;源码中&#xff1a;先判断queryset是否…

全志F1C200S嵌入式驱动开发(linux移植)

【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】 前面完成了uboot移植,下面就要进行linux移植。当然,理论上uboot只是为后续的os准备好了一个基础运行环境,实际运行的操作系统是不是选择linux,也不一定。如果为了实际生产的需要…

Golang环境搭建指南(Windows和linux)

前言&#xff1a; go语言和Java&#xff0c;Python&#xff0c;C语言等等基本一样&#xff0c;也是需要在系统内集成语言环境的。语言基本都一样&#xff0c;支持各种系统架构&#xff0c;比如&#xff0c;mac&#xff0c;Windows&#xff0c;linux系统支持。本文仅以最为常用…