Android四大组件之 Activity的启动过程源码解析

news2025/2/25 19:10:55

前言

Activity是Android中一个很重要的概念,堪称四大组件之首,关于Activity有很多内容,比如生命周期和启动Flags,这二者想要说清楚,恐怕又要写两篇长文,更何况分析它们的源码呢。不过本文的侧重点不是它们,我要介绍的是一个Activity典型的启动过程,本文会从源码的角度对其进行分析。我们知道,当startActivity被调用的时候,可以启动一个Activity,但是你知道这个Activity是如何被启动的吗?每个Activity也是一个对象,你知道这个对象是啥时候被创建的吗(也就是说它的构造方法是什么时候被调用的)?为什么onCreate是Activity的执行入口?所有的这一切都被系统封装好了,对我们来说是透明的,我们使用的时候仅仅是传递一个intent然后startActivity就可以达到目的了,不过,阅读了本文以后,你将会了解它的背后到底做了哪些事情。在分析之前,我先介绍几个类:

  1. Activity:这个大家都熟悉,startActivity方法的真正实现在Activity中
  2. Instrumentation:用来辅助Activity完成启动Activity的过程
  3. ActivityThread(包含ApplicationThread + ApplicationThreadNative + IApplicationThread):真正启动Activity的实现都在这里。

源码分析

首先看入口

code:Activity#startActivity

@Override 
public void startActivity(Intent intent) { 
 startActivity(intent, null); 
} 
 
@Override 
public void startActivity(Intent intent, Bundle options) { 
 if (options != null) { 
  startActivityForResult(intent, -1, options); 
 } else { 
  // Note we want to go through this call for compatibility with 
  // applications that may have overridden the method. 
  startActivityForResult(intent, -1); 
 } 
} 
 
public void startActivityForResult(Intent intent, int requestCode) { 
 startActivityForResult(intent, requestCode, null); 
} 

说明:显然,从上往下,最终都是由startActivityForResult来实现的

接着看

code:Activity#startActivityForResult

public void startActivityForResult(Intent intent, int requestCode, Bundle options) { 
 //一般的Activity其mParent为null,mParent常用在ActivityGroup中,ActivityGroup已废弃 
 if (mParent == null) { 
  //这里会启动新的Activity,核心功能都在mMainThread.getApplicationThread()中完成 
  Instrumentation.ActivityResult ar = 
   mInstrumentation.execStartActivity( 
    this, mMainThread.getApplicationThread(), mToken, this, 
    intent, requestCode, options); 
  if (ar != null) { 
   //发送结果,即onActivityResult会被调用 
   mMainThread.sendActivityResult( 
    mToken, mEmbeddedID, requestCode, ar.getResultCode(), 
    ar.getResultData()); 
  } 
  if (requestCode  = 0) { 
   // If this start is requesting a result, we can avoid making 
   // the activity visible until the result is received. Setting 
   // this code during onCreate(Bundle savedInstanceState) or onResume() will keep the 
   // activity hidden during this time, to avoid flickering. 
   // This can only be done when a result is requested because 
   // that guarantees we will get information back when the 
   // activity is finished, no matter what happens to it. 
   mStartedActivity = true; 
  } 
 
  final View decor = mWindow != null ? mWindow.peekDecorView() : null; 
  if (decor != null) { 
   decor.cancelPendingInputEvents(); 
  } 
  // TODO Consider clearing/flushing other event sources and events for child windows. 
 } else { 
  //在ActivityGroup内部的Activity调用startActivity的时候会走到这里,内部处理逻辑和上面是类似的 
  if (options != null) { 
   mParent.startActivityFromChild(this, intent, requestCode, options); 
  } else { 
   // Note we want to go through this method for compatibility with 
   // existing applications that may have overridden it. 
   mParent.startActivityFromChild(this, intent, requestCode); 
  } 
 } 
} 

说明:上述代码关键点都有注释了,可以发现,真正打开activity的实现在Instrumentation的execStartActivity方法中,去看看

code:Instrumentation#execStartActivity

public ActivityResult execStartActivity( 
  Context who, IBinder contextThread, IBinder token, Activity target, 
  Intent intent, int requestCode, Bundle options) { 
 //核心功能在这个whoThread中完成,其内部scheduleLaunchActivity方法用于完成activity的打开 
 IApplicationThread whoThread = (IApplicationThread) contextThread; 
 if (mActivityMonitors != null) { 
  synchronized (mSync) { 
   //先查找一遍看是否存在这个activity 
   final int N = mActivityMonitors.size(); 
   for (int i=0; i<N; i++) { 
    final ActivityMonitor am = mActivityMonitors.get(i); 
    if (am.match(who, null, intent)) { 
     //如果找到了就跳出循环 
     am.mHits++; 
     //如果目标activity无法打开,直接return 
     if (am.isBlocking()) { 
      return requestCode  = 0 ? am.getResult() : null; 
     } 
     break; 
    } 
   } 
  } 
 } 
 try { 
  intent.migrateExtraStreamToClipData(); 
  intent.prepareToLeaveProcess(); 
  //这里才是真正打开activity的地方,核心功能在whoThread中完成。 
  int result = ActivityManagerNative.getDefault() 
   .startActivity(whoThread, who.getBasePackageName(), intent, 
     intent.resolveTypeIfNeeded(who.getContentResolver()), 
     token, target != null ? target.mEmbeddedID : null, 
     requestCode, 0, null, null, options); 
  //这个方法是专门抛异常的,它会对结果进行检查,如果无法打开activity, 
  //则抛出诸如ActivityNotFoundException类似的各种异常 
  checkStartActivityResult(result, intent); 
 } catch (RemoteException e) { 
 } 
 return null; 
} 

说明:我想再说一下这个方法checkStartActivityResult,它也专业抛异常的,看代码,相信大家对下面的异常信息不陌生吧,就是它干的,其中最熟悉的非Unable to find explicit activity class莫属了,如果你在xml中没有注册目标activity,此异常将会抛出。

/

*package*/ static void checkStartActivityResult(int res, Object intent) { 
 if (res  = ActivityManager.START_SUCCESS) { 
  return; 
 } 
  
 switch (res) { 
  case ActivityManager.START_INTENT_NOT_RESOLVED: 
  case ActivityManager.START_CLASS_NOT_FOUND: 
   if (intent instanceof Intent && ((Intent)intent).getComponent() != null) 
    throw new ActivityNotFoundException( 
      "Unable to find explicit activity class " 
      + ((Intent)intent).getComponent().toShortString() 
      + "; have you declared this activity in your AndroidManifest.xml?"); 
   throw new ActivityNotFoundException( 
     "No Activity found to handle " + intent); 
  case ActivityManager.START_PERMISSION_DENIED: 
   throw new SecurityException("Not allowed to start activity " 
     + intent); 
  case ActivityManager.START_FORWARD_AND_REQUEST_CONFLICT: 
   throw new AndroidRuntimeException( 
     "FORWARD_RESULT_FLAG used while also requesting a result"); 
  case ActivityManager.START_NOT_ACTIVITY: 
   throw new IllegalArgumentException( 
     "PendingIntent is not an activity"); 
  default: 
   throw new AndroidRuntimeException("Unknown error code " 
     + res + " when starting " + intent); 
 } 
} 

接下来我们要去看看IApplicationThread,因为核心功能由其内部的scheduleLaunchActivity方法来完成,由于IApplicationThread是个接口,所以,我们需要找到它的实现类,我已经帮大家找到了,它就是ActivityThread中的内部类ApplicationThread,看下它的继承关系:

private class ApplicationThread extends ApplicationThreadNative;

public abstract class ApplicationThreadNative extends Binder implements IApplicationThread;

可以发现,ApplicationThread还是间接实现了IApplicationThread接口,先看下这个类的结构
在这里插入图片描述

看完ApplicationThread的大致结构,我们应该能够猜测到,Activity的生命周期中的resume、newIntent、pause、stop等事件都是由它触发的,事实上,的确是这样的。这里,我们为了说明问题,仅仅看scheduleLaunchActivity方法

code:ApplicationThread#scheduleLaunchActivity

public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident, 
  ActivityInfo info, Configuration curConfig, CompatibilityInfo compatInfo, 
  int procState, Bundle state, List<ResultInfo  pendingResults, 
  List<Intent  pendingNewIntents, boolean notResumed, boolean isForward, 
  String profileName, ParcelFileDescriptor profileFd, boolean autoStopProfiler) { 
 
 updateProcessState(procState, false); 
 
 ActivityClientRecord r = new ActivityClientRecord(); 
 
 r.token = token; 
 r.ident = ident; 
 r.intent = intent; 
 r.activityInfo = info; 
 r.compatInfo = compatInfo; 
 r.state = state; 
 
 r.pendingResults = pendingResults; 
 r.pendingIntents = pendingNewIntents; 
 
 r.startsNotResumed = notResumed; 
 r.isForward = isForward; 
 
 r.profileFile = profileName; 
 r.profileFd = profileFd; 
 r.autoStopProfiler = autoStopProfiler; 
 
 updatePendingConfiguration(curConfig); 
 
 queueOrSendMessage(H.LAUNCH_ACTIVITY, r); 
} 

说明:上述代码很好理解,构造一个activity记录,然后发送一个消息,所以,我们要看看Handler是如何处理这个消息的,现在转到这个Handler,它有个很短的名字叫做H

code:ActivityThread#H

/

/这个类太长,我只帖出了我们用到的部分 
private class H extends Handler { 
 
 public void handleMessage(Message msg) { 
  if (DEBUG_MESSAGES) Slog.v(TAG, "    handling: " + codeToString(msg.what)); 
  switch (msg.what) { 
   //这里处理LAUNCH_ACTIVITY消息类型 
   case LAUNCH_ACTIVITY: { 
    Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityStart"); 
    ActivityClientRecord r = (ActivityClientRecord)msg.obj; 
 
    r.packageInfo = getPackageInfoNoCheck( 
      r.activityInfo.applicationInfo, r.compatInfo); 
    //这里处理startActivity消息 
    handleLaunchActivity(r, null); 
    Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); 
   } break; 
   case RELAUNCH_ACTIVITY: { 
    Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityRestart"); 
    ActivityClientRecord r = (ActivityClientRecord)msg.obj; 
    handleRelaunchActivity(r); 
    Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); 
   } break; 
   case PAUSE_ACTIVITY: 
    Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityPause"); 
    handlePauseActivity((IBinder)msg.obj, false, msg.arg1 != 0, msg.arg2); 
    maybeSnapshot(); 
    Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); 
    break; 
   ... 
  } 
} 

说明:看来还要看handleLaunchActivity

code:ActivityThread#handleLaunchActivity

private void handleLaunchActivity(ActivityClientRecord r, Intent customIntent) { 
// If we are getting ready to gc after going to the background, well 
// we are back active so skip it. 
unscheduleGcIdler(); 
if (r.profileFd != null) { 
mProfiler.setProfiler(r.profileFile, r.profileFd); 
mProfiler.startProfiling(); 
mProfiler.autoStopProfiler = r.autoStopProfiler; 
} 
// Make sure we are running with the most recent config. 
handleConfigurationChanged(null, null); 
if (localLOGV) Slog.v( 
TAG, "Handling launch of " + r); 
//终于到底了,大家都有点不耐烦了吧,从方法名可以看出, 
//performLaunchActivity真正完成了activity的调起, 
//同时activity会被实例化,并且onCreate会被调用 
Activity a = performLaunchActivity(r, customIntent); 
if (a != null) { 
r.createdConfig = new Configuration(mConfiguration); 
Bundle oldState = r.state; 
//看到没,目标activity的onResume会被调用 
handleResumeActivity(r.token, false, r.isForward, 
!r.activity.mFinished && !r.startsNotResumed); 
if (!r.activity.mFinished && r.startsNotResumed) { 
// The activity manager actually wants this one to start out 
// paused, because it needs to be visible but isn't in the 
// foreground. We accomplish this by going through the 
// normal startup (because activities expect to go through 
// onResume() the first time they run, before their window 
// is displayed), and then pausing it. However, in this case 
// we do -not- need to do the full pause cycle (of freezing 
// and such) because the activity manager assumes it can just 
// retain the current state it has. 
try { 
r.activity.mCalled = false; 
//同时,由于新activity被调起了,原activity的onPause会被调用 
mInstrumentation.callActivityOnPause(r.activity); 
// We need to keep around the original state, in case 
// we need to be created again. But we only do this 
// for pre-Honeycomb apps, which always save their state 
// when pausing, so we can not have them save their state 
// when restarting from a paused state. For HC and later, 
// we want to (and can) let the state be saved as the normal 
// part of stopping the activity. 
if (r.isPreHoneycomb()) { 
r.state = oldState; 
} 
if (!r.activity.mCalled) { 
throw new SuperNotCalledException( 
"Activity " + r.intent.getComponent().toShortString() + 
" did not call through to super.onPause()"); 
} 
} catch (SuperNotCalledException e) { 
throw e; 
} catch (Exception e) { 
if (!mInstrumentation.onException(r.activity, e)) { 
throw new RuntimeException( 
"Unable to pause activity " 
+ r.intent.getComponent().toShortString() 
+ ": " + e.toString(), e); 
} 
} 
r.paused = true; 
} 
} else { 
// If there was an error, for any reason, tell the activity 
// manager to stop us. 
try { 
ActivityManagerNative.getDefault() 
.finishActivity(r.token, Activity.RESULT_CANCELED, null); 
} catch (RemoteException ex) { 
// Ignore 
} 
} 
} 

说明:关于原activity和新activity之间的状态同步,如果大家感兴趣可以自己研究下,因为逻辑太复杂,我没法把所有问题都说清楚,否则就太深入细节而淹没了整体逻辑,研究源码要的就是清楚整体逻辑。下面看最后一个方法,这个方法是activity的启动过程的真正实现。

code:ActivityThread#performLaunchActivity

private Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) { 
// System.out.println("##### [" + System.currentTimeMillis() + "] ActivityThread.performLaunchActivity(" + r + ")"); 
ActivityInfo aInfo = r.activityInfo; 
if (r.packageInfo == null) { 
r.packageInfo = getPackageInfo(aInfo.applicationInfo, r.compatInfo, 
Context.CONTEXT_INCLUDE_CODE); 
} 
//首先从intent中解析出目标activity的启动参数 
ComponentName component = r.intent.getComponent(); 
if (component == null) { 
component = r.intent.resolveActivity( 
mInitialApplication.getPackageManager()); 
r.intent.setComponent(component); 
} 
if (r.activityInfo.targetActivity != null) { 
component = new ComponentName(r.activityInfo.packageName, 
r.activityInfo.targetActivity); 
} 
Activity activity = null; 
try { 
java.lang.ClassLoader cl = r.packageInfo.getClassLoader(); 
//用ClassLoader(类加载器)将目标activity的类通过类名加载进来并调用newInstance来实例化一个对象 
//其实就是通过Activity的无参构造方法来new一个对象,对象就是在这里new出来的。 
activity = mInstrumentation.newActivity( 
cl, component.getClassName(), r.intent); 
StrictMode.incrementExpectedActivityCount(activity.getClass()); 
r.intent.setExtrasClassLoader(cl); 
if (r.state != null) { 
r.state.setClassLoader(cl); 
} 
} catch (Exception e) { 
if (!mInstrumentation.onException(activity, e)) { 
throw new RuntimeException( 
"Unable to instantiate activity " + component 
+ ": " + e.toString(), e); 
} 
} 
try { 
Application app = r.packageInfo.makeApplication(false, mInstrumentation); 
if (localLOGV) Slog.v(TAG, "Performing launch of " + r); 
if (localLOGV) Slog.v( 
TAG, r + ": app=" + app 
+ ", appName=" + app.getPackageName() 
+ ", pkg=" + r.packageInfo.getPackageName() 
+ ", comp=" + r.intent.getComponent().toShortString() 
+ ", dir=" + r.packageInfo.getAppDir()); 
if (activity != null) { 
Context appContext = createBaseContextForActivity(r, activity); 
CharSequence title = r.activityInfo.loadLabel(appContext.getPackageManager()); 
Configuration config = new Configuration(mCompatConfiguration); 
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Launching activity " 
+ r.activityInfo.name + " with config " + config); 
activity.attach(appContext, this, getInstrumentation(), r.token, 
r.ident, app, r.intent, r.activityInfo, title, r.parent, 
r.embeddedID, r.lastNonConfigurationInstances, config); 
if (customIntent != null) { 
activity.mIntent = customIntent; 
} 
r.lastNonConfigurationInstances = null; 
activity.mStartedActivity = false; 
int theme = r.activityInfo.getThemeResource() 
if (theme != 0) { 
activity.setTheme(theme); 
} 
activity.mCalled = false; 
//目标activity的onCreate被调用了,到此为止,Activity被启动了,接下来的流程就是Activity的生命周期了, 
//本文之前已经提到,其生命周期的各种状态的切换由ApplicationThread内部来完成 
mInstrumentation.callActivityOnCreate(activity, r.state); 
if (!activity.mCalled) { 
throw new SuperNotCalledException( 
"Activity " + r.intent.getComponent().toShortString() + 
" did not call through to super.onCreate()"); 
} 
r.activity = activity; 
r.stopped = true; 
if (!r.activity.mFinished) { 
activity.performStart(); 
r.stopped = false; 
} 
if (!r.activity.mFinished) { 
if (r.state != null) { 
mInstrumentation.callActivityOnRestoreInstanceState(activity, r.state); 
} 
} 
if (!r.activity.mFinished) { 
activity.mCalled = false; 
mInstrumentation.callActivityOnPostCreate(activity, r.state); 
if (!activity.mCalled) { 
throw new SuperNotCalledException( 
"Activity " + r.intent.getComponent().toShortString() + 
" did not call through to super.onPostCreate()"); 
} 
} 
} 
r.paused = true; 
mActivities.put(r.token, r); 
} catch (SuperNotCalledException e) { 
throw e; 
} catch (Exception e) { 
if (!mInstrumentation.onException(activity, e)) { 
throw new RuntimeException( 
"Unable to start activity " + component 
+ ": " + e.toString(), e); 
} 
} 
return activity; 
} 

总结

相信当你看到这里的时候,你对Activity的启动过程应该有了一个感性的认识。Activity很复杂,特性很多,本文没法对各个细节进行深入分析,而且就算真的对各个细节都进行了深入分析,那文章要有多长啊,还有人有耐心看下去吗?希望本文能够给大家带来一些帮助,谢谢大家阅读。

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

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

相关文章

小黑向携程进攻啦1:跟紧沛奇老师的携程步伐

为什么要学 异步非阻塞、asynciotornado、fastapi、django 3.x asgi、aiohttp都在异步->提升功能 如何讲解&#xff1f; 协程asyncio模块进行异步编程实战案例 1.协程 协程不是计算机提供&#xff0c;程序员人为创造出来的。协程&#xff0c;又称微线程&#xff0c;是一…

共聚焦显微镜——光伏产业制造智能化测量新技术

我国智能光伏应用持续升级&#xff0c;产业各环节产量又创新高。根据光伏行业规范公告企业信息和行业协会预测的数据来看&#xff0c;全国多晶硅、组件产量同比增长均超过60%&#xff0c;晶硅电池产品出口同比增长超过156%。 以共聚焦显微测量技术为原理、应用于材料生产领域的…

STM32的SRAM

文章目录SRAM的概念XM8A51216介绍特点连接线原理框图硬件连接图SRAM的配置使能 FSMC 时钟&#xff0c;并配置 FSMC 相关的 IO 及其时钟使能初始化FSMC&#xff0c;设置FSMC BANK1区域3使能 BANK1 区域 3FSMC读写代码SRAM的概念 SRAM的介绍 STM32F407ZGT6自带了 192K字节的 SRA…

[助人为乐]层次分析法

朋友论文需要用到层次分析法。于是回顾了一下。 相关资料推荐 层次分析法(AHP) 层次分析法&#xff08;AHP&#xff09;详细版本 用人话讲明白AHP层次分析法&#xff08;非常详细原理简单工具实现&#xff09; 层次分析法的流程图 构建层次结构模型(目标-准则-方案层) 深入…

认证服务---OAuth2.0基本介绍,微博登录整合到实际项目中【下篇】

前言 上一篇简单介绍了它的基本使用&#xff0c;这一篇就粗略说明一下如何在项目中实际应用 1、核心代码 1.1 认证微服务 当你进行了授权之后&#xff0c;跳转到一个新的地址。这个地址应该是你访问接口的地址。在这个接口中完成相应的access_token获取&#xff0c;以及调用…

docker-compose容器编排使用详解+示例

文章目录一、docker-compose概述1、产生的背景2、核心概念3、使用的三个步骤4、常用命令二、下载安装1、官方文档2、下载3、卸载三、使用compose1、前置知识&#xff0c;将一个springboot项目打包为镜像2、编写docker-compose.yml文件3、启动docker-compose4、停止一、docker-c…

[Linux]进程控制精讲,简单实现一个shell

目录 前言 进程创建 fork函数初识 写时拷贝 fork常见用法 fork调用失败的原因 进程终止 进程退出场景 进程退出码 查看进程退出码 退出码的含义 进程常见退出方法 exit VS _exit exit函数 _exit函数 二者的区别 return退出 进程等待 进程等待必要性 进程等待…

【Java文件操作】手把手教你拿捏IO 流

哈喽&#xff0c;大家好~我是保护小周ღ&#xff0c;本期为大家带来的是 Java 文件操作&#xff0c;理解文件的概念以及&#xff0c;常用的操作文件的类和方法&#xff0c;FileInputStream 类 和 FileOutputStream , PrintWriter and Scnner, Reader and Wirter 确定不来看看…

Python机器学习:集成学习

前两天看了SVM、逻辑回归、KNN、决策树、贝叶斯分类这几个很成熟的机器学习方法&#xff0c;但是&#xff0c;今天不看方法了&#xff0c;来看一种思想&#xff1a;集成学习&#xff1a; 先来看一下集成学习的基本原理&#xff1a;通过融合多个模型&#xff0c;从不同的角度降…

3.4 随机变量的相互独立性

学习目标&#xff1a; 要学习二维随机变量的相互独立性&#xff0c;我会按照以下步骤进行&#xff1a; 学习独立性的概念&#xff1a;在概率论中&#xff0c;两个事件A和B是相互独立的&#xff0c;当且仅当它们的概率乘积等于它们的联合概率&#xff0c;即P(A∩B)P(A)P(B)。将…

【Java EE】-网络编程(二) Socket(套接字) + Udp版本客户端服务器 +Tcp版本客户端服务器

作者&#xff1a;学Java的冬瓜 博客主页&#xff1a;☀冬瓜的主页&#x1f319; 专栏&#xff1a;【JavaEE】 主要内容&#xff1a;传输层协议对应Socket编程&#xff0c;DatagramSocket&#xff0c;DatagramPacket&#xff0c;Udp版本的客户端和服务器&#xff0c;UdpEchoSeve…

大力出奇迹——GPT系列论文学习(GPT,GPT2,GPT3,InstructGPT)

目录说在前面1.GPT1.1 引言1.2 训练范式1.2.1 无监督预训练1.2.2 有监督微调1.3 实验2. GPT22.1 引言2.2 模型结构2.3 训练范式2.4 实验3.GPT33.1引言3.2 模型结构3.3 训练范式3.4 实验3.4.1数据集3.5 局限性4. InstructGPT4.1 引言4.2 方法4.2.1 数据收集4.2.2 各部分模型4.3 …

【轻NAS】Windows搭建可道云私有云盘,并内网穿透公网访问

文章目录1.前言2. Kodcloud网站搭建2.1. Kodcloud下载和安装2.2 Kodcloud网页测试3. cpolar内网穿透的安装和注册4. 本地网页发布4.1 Cpolar云端设置4.2 Cpolar本地设置5. 公网访问测试6.结语1.前言 云存储作为近些年兴起的概念&#xff0c;成功吸引了各大互联网厂商下场&…

thingsboard ARM网关

G5501边缘计算网关 G5501是采用中高端的通用型 SOC&#xff0c;一款4 核 arm 架构 A55 处理器的 网关设备。标配处理器为 Cortex-A55 四核&#xff0c;最高主频 2GHz 的处理器&#xff0c; 内置 4GB DDR4 内存&#xff0c;32GB eMMC 存储。 集成Mali G52 2EE 图形处理器GPU&am…

matplotlib设置中文字体为微软雅黑

matplotlib无法设置任何中文字体怎么办&#xff1f; 如何在linux系统下让matplotlib显示中文&#xff1f; 下载微软雅黑字体&#xff0c;把它放在某个目录下。 链接&#xff1a; https://pan.baidu.com/s/1SCLYpH_MzY7vn0HA0wxxAw?pwdft2j 提取码&#xff1a;ft2j 在代码中加…

Learning C++ No.18【STL No.8】

引言&#xff1a; 北京时间&#xff1a;2023/3/18/21:47&#xff0c;周末&#xff0c;不摆烂&#xff0c;但是欠钱终于还是遭报应了&#xff0c;导致坐牢7小时&#xff08;上午3.5&#xff0c;下午3.5&#xff09;&#xff0c;难受&#xff0c;充分意识到行哥是那么的和蔼可亲…

DLRover: 云上自动扩缩容 DeepRec 分布式训练作业

背景 如今&#xff0c;深度学习已广泛应用在搜索、广告、推荐等业务中&#xff0c;这类业务场景普遍有两个特点&#xff1a; 1&#xff09;训练样本量大&#xff0c;需要分布式训练提升训练速度&#xff1b; 2&#xff09;模型稀疏&#xff0c;即模型结构中离散特征计算逻辑占…

强训之【走方格的方案数和另类加法】

目录1.走方格的方案数1.1题目1.2思路讲解1.3代码展示2.另类加法2.1题目2.2思路讲解2.3代码展示3.选择题1.走方格的方案数 1.1题目 链接: link 描述 请计算n*m的棋盘格子&#xff08;n为横向的格子数&#xff0c;m为竖向的格子数&#xff09;从棋盘左上角出发沿着边缘线从左上…

第⑦讲:Ceph集群RGW对象存储核心概念及部署使用

文章目录1.RadosGW对象存储核心概念1.1.什么是RadosGW对象存储1.2.RGW对象存储架构1.3.RGW对象存储的特点1.4.对象存储中Bucket的特性1.4.不同接口类型的对象存储访问对比2.在集群中部署RadosGW对象存储组件2.1.部署RGW组件2.2.集群中部署完RGW组件后观察集群的信息状态2.3.修改…

【2023】Kubernetes之Pod与容器状态关系

目录简单创建一个podPod运行阶段&#xff1a;容器运行阶段简单创建一个pod apiVersion: v1 kind: pod metadata: name: nginx-pod spec:containers:- name: nginximages: nginx:1.20以上代码表示创建一个名为nginx-pod的pod资源对象。 Pod运行阶段&#xff1a; Pod创建后&am…