【Android12】Monkey压力测试源码执行流程分析

Monkey压力测试源码执行流程分析

Monkey是Android提供的用于应用程序自动化测试、压力测试的测试工具。
其源码路径(Android12)位于

/development/cmds/monkey/

部署形式为Java Binary

# development/cmds/monkey/Android.bp
// Copyright 2008 The Android Open Source Project
//package {default_applicable_licenses: ["development_cmds_monkey_license"],
}// See: http://go/android-license-faq
license {name: "development_cmds_monkey_license",visibility: [":__subpackages__"],license_kinds: ["SPDX-license-identifier-Apache-2.0",],license_text: ["NOTICE",],
}//###############################################################
java_binary {name: "monkey",srcs: ["**/*.java"],wrapper: "monkey",
}

通过Monkey,可以模拟用户的Touch(单指、多指、手势)、按键(key)事件等,检测应用程序发生的ANR、Crash事件,并收集相关Debug信息等。
例如测试应用com.package.linduo,

adb shell monkey -p com.package.linduo --pct-touch 10 --pct-motion 20 10000
# 该命令表示,执行1万次测试事件,其中Touch事件占10%,Motion事件占20%# 或者adb shell进入android终端,直接使用monkey命令

Monkey支持的命令

    private void showUsage() {StringBuffer usage = new StringBuffer();usage.append("usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]\n");usage.append("              [-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]\n");usage.append("              [--ignore-crashes] [--ignore-timeouts]\n");usage.append("              [--ignore-security-exceptions]\n");usage.append("              [--monitor-native-crashes] [--ignore-native-crashes]\n");usage.append("              [--kill-process-after-error] [--hprof]\n");usage.append("              [--match-description TEXT]\n");usage.append("              [--pct-touch PERCENT] [--pct-motion PERCENT]\n");usage.append("              [--pct-trackball PERCENT] [--pct-syskeys PERCENT]\n");usage.append("              [--pct-nav PERCENT] [--pct-majornav PERCENT]\n");usage.append("              [--pct-appswitch PERCENT] [--pct-flip PERCENT]\n");usage.append("              [--pct-anyevent PERCENT] [--pct-pinchzoom PERCENT]\n");usage.append("              [--pct-permission PERCENT]\n");usage.append("              [--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]\n");usage.append("              [--pkg-whitelist-file PACKAGE_WHITELIST_FILE]\n");usage.append("              [--wait-dbg] [--dbg-no-events]\n");usage.append("              [--setup scriptfile] [-f scriptfile [-f scriptfile] ...]\n");usage.append("              [--port port]\n");usage.append("              [-s SEED] [-v [-v] ...]\n");usage.append("              [--throttle MILLISEC] [--randomize-throttle]\n");usage.append("              [--profile-wait MILLISEC]\n");usage.append("              [--device-sleep-time MILLISEC]\n");usage.append("              [--randomize-script]\n");usage.append("              [--script-log]\n");usage.append("              [--bugreport]\n");usage.append("              [--periodic-bugreport]\n");usage.append("              [--permission-target-system]\n");usage.append("              COUNT\n");Logger.err.println(usage.toString());}

Monkey执行测试的源码分析

这里主要关注模式事件的执行流程

  • Monkey启动
  • Monkey生成模拟事件
  • Monkey向系统发送模拟事件
    在这里插入图片描述
Monkey启动

Monkey.java中定义了程序入口函数main,该函数中启动了Monkey程序。

// development/cmds/monkey/src/com/android/commands/monkey/Monkey.javapublic static void main(String[] args) {// Set the process name showing in "ps" or "top"Process.setArgV0("com.android.commands.monkey");Logger.err.println("args: " + Arrays.toString(args));int resultCode = (new Monkey()).run(args);System.exit(resultCode);
}
// development/cmds/monkey/src/com/android/commands/monkey/Monkey.java/*** Run the command!** @param args The command-line arguments* @return Returns a posix-style result code. 0 for no error.*/
private int run(String[] args) {// Default values for some command-line optionsmVerbose = 0;// 默认的测试次数mCount = 1000;// 生成radom的seedmSeed = 0;// 记录事件之间的延迟,就是每个事件执行的间隔mThrottle = 0;// prepare for command-line processingmArgs = args;// 解析参数if (!processOptions()) {return -1;}// 确定待测试的Packageif (!loadPackageLists()) {return -1;}// now set up additional data in preparation for launchif (mMainCategories.size() == 0) {mMainCategories.add(Intent.CATEGORY_LAUNCHER);mMainCategories.add(Intent.CATEGORY_MONKEY);}if (mSeed == 0) {mSeed = System.currentTimeMillis() + System.identityHashCode(this);}// 获取系统服务接口(AMS、PMS、WMS)if (!getSystemInterfaces()) {return -3;}// 获取用于启动应用的Activityif (!getMainApps()) {return -4;}if (mScriptFileNames != null && mScriptFileNames.size() == 1) {// script mode, ignore other options} else if (mScriptFileNames != null && mScriptFileNames.size() > 1) {} else if (mServerPort != -1) {} else {// 创建用于产生模拟器事件的Source对象mEventSource = new MonkeySourceRandom(mRandom, mMainApps,mThrottle, mRandomizeThrottle, mPermissionTargetSystem);mEventSource.setVerbose(mVerbose);// 设置各测试类型的测试比例// set any of the factors that has been setfor (int i = 0; i < MonkeySourceRandom.FACTORZ_COUNT; i++) {if (mFactors[i] <= 0.0f) {((MonkeySourceRandom) mEventSource).setFactors(i, mFactors[i]);}}// 产生activity事件,该事件用来启动应用// in random mode, we start with a random activity((MonkeySourceRandom) mEventSource).generateActivity();}try {// 执行模拟测试事件crashedAtCycle = runMonkeyCycles();} finally {// Release the rotation lock if it's still held and restore the// original orientation.new MonkeyRotationEvent(Surface.ROTATION_0, false).injectEvent(mWm, mAm, mVerbose);}}
Monkey解析输入参数

processOptions函数解析输入参数(就是monkey命令后跟着的参数信息),根据入参设置Monkey类中相关成员变量。

// development/cmds/monkey/src/com/android/commands/monkey/Monkey.java
private boolean processOptions() {// quick (throwaway) check for unadorned commandif (mArgs.length < 1) {showUsage();return false;}try {String opt;Set<String> validPackages = new HashSet<>();while ((opt = nextOption()) != null) {if (opt.equals("-s")) {mSeed = nextOptionLong("Seed");} else if (opt.equals("-p")) {validPackages.add(nextOptionData());} else if (opt.equals("-c")) {// 省略} else {Logger.err.println("** Error: Unknown option: " + opt);showUsage();return false;}}// 根据输入参数,设置待测试的应用MonkeyUtils.getPackageFilter().addValidPackages(validPackages);} catch (RuntimeException ex) {Logger.err.println("** Error: " + ex.toString());showUsage();return false;}// If a server port hasn't been specified, we need to specify// a countif (mServerPort == -1) {// 省略}return true;
}
Monkey获取系统服务

getSystemInterfaces函数用于获取Android系统服务,包括AMS、PMS、WMS服务。调用AMS服务的setActivityController接口,通过该接口向AMS设置IActivityController.Stub对象,通过该对象监听应用(Activity)的ANR和Crash事件。

/*** Attach to the required system interfaces.** @return Returns true if all system interfaces were available.*/
private boolean getSystemInterfaces() {mAm = ActivityManager.getService();if (mAm == null) {Logger.err.println("** Error: Unable to connect to activity manager; is the system "+ "running?");return false;}mWm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));if (mWm == null) {Logger.err.println("** Error: Unable to connect to window manager; is the system "+ "running?");return false;}mPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));if (mPm == null) {Logger.err.println("** Error: Unable to connect to package manager; is the system "+ "running?");return false;}try {mAm.setActivityController(new ActivityController(), true);mNetworkMonitor.register(mAm);} catch (RemoteException e) {Logger.err.println("** Failed talking with activity manager!");return false;}return true;
}/*** Monitor operations happening in the system.*/
private class ActivityController extends IActivityController.Stub {public boolean activityStarting(Intent intent, String pkg) {// 省略}private boolean isActivityStartingAllowed(Intent intent, String pkg) {// 省略}public boolean activityResuming(String pkg) {// 省略}public boolean appCrashed(String processName, int pid,String shortMsg, String longMsg,long timeMillis, String stackTrace) {// 省略}public int appEarlyNotResponding(String processName, int pid, String annotation) {return 0;}public int appNotResponding(String processName, int pid, String processStats) {// 省略}public int systemNotResponding(String message) {// 省略}
}
Monkey获取待测试应用的Activity

monkey通过PackageManager的queryIntentActivities接口,查询带有 Intent.CATEGORY_LAUNCHERIntent.CATEGORY_MONKEY信息的Activity,并判断Activity是否属于待测试应用。将待测试应用的Activity添加到mMainApps变量中。

// development/cmds/monkey/src/com/android/commands/monkey/Monkey.java
/*** Using the restrictions provided (categories & packages), generate a list* of activities that we can actually switch to.** @return Returns true if it could successfully build a list of target*         activities*/
private boolean getMainApps() {try {final int N = mMainCategories.size();for (int i = 0; i < N; i++) {Intent intent = new Intent(Intent.ACTION_MAIN);String category = mMainCategories.get(i);if (category.length() > 0) {intent.addCategory(category);}// 查找带有 Intent.CATEGORY_LAUNCHER、Intent.CATEGORY_MONKEY的ActivityList<ResolveInfo> mainApps = mPm.queryIntentActivities(intent, null, 0,ActivityManager.getCurrentUser()).getList();final int NA = mainApps.size();for (int a = 0; a < NA; a++) {ResolveInfo r = mainApps.get(a);String packageName = r.activityInfo.applicationInfo.packageName;if (MonkeyUtils.getPackageFilter().checkEnteringPackage(packageName)) {// 如果Activity属于待测试Package,将其添加到mMainApps中。mMainApps.add(new ComponentName(packageName, r.activityInfo.name));} else {}}}} catch (RemoteException e) {Logger.err.println("** Failed talking with package manager!");return false;}if (mMainApps.size() == 0) {Logger.out.println("** No activities found to run, monkey aborted.");return false;}return true;
}
Monkey生成模拟测试事件,并执行
// development/cmds/monkey/src/com/android/commands/monkey/Monkey.java
private int run(String[] args) {// 创建该对象,用于产生测试事件mEventSource = new MonkeySourceRandom(mRandom, mMainApps,mThrottle, mRandomizeThrottle, mPermissionTargetSystem);for (int i = 0; i < MonkeySourceRandom.FACTORZ_COUNT; i++) {if (mFactors[i] <= 0.0f) {((MonkeySourceRandom) mEventSource).setFactors(i, mFactors[i]);}}try {// 执行Monkey测试crashedAtCycle = runMonkeyCycles();} finally {// Release the rotation lock if it's still held and restore the// original orientation.new MonkeyRotationEvent(Surface.ROTATION_0, false).injectEvent(mWm, mAm, mVerbose);}
}

runMonkeyCycles函数中调用MonkeySourceRandom的getNextEvent函数生成模拟测试事件(MonkeyEvent),调用MonkeyEventinjectEvent执行模拟测试。

private int runMonkeyCycles() {int eventCounter = 0;int cycleCounter = 0;boolean shouldReportAnrTraces = false;boolean shouldReportDumpsysMemInfo = false;boolean shouldAbort = false;boolean systemCrashed = false;try {// TO DO : The count should apply to each of the script file.while (!systemCrashed && cycleCounter < mCount) {synchronized (this) {// 注意:因为先执行过generateActivity,所以第一次调用会,会获得启动Activity的模拟测试事件MonkeyEvent ev = mEventSource.getNextEvent();if (ev != null) {int injectCode = ev.injectEvent(mWm, mAm, mVerbose);} else {}}} catch (RuntimeException e) {Logger.error("** Error: A RuntimeException occurred:", e);}Logger.out.println("Events injected: " + eventCounter);return eventCounter;
}

MonkeySourceRandom的getNextEvent,会在事件队列(存储模拟测试事件)为空时,产生测试对象。生成测试事件时,先生成一个随机数,然后根据测试类型所占比例(比例越大,生成该测试类型的概率越大),生成不同测试类型。

// development/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
/*** generate an activity event*/
public void generateActivity() {MonkeyActivityEvent e = new MonkeyActivityEvent(mMainApps.get(mRandom.nextInt(mMainApps.size())));mQ.addLast(e);
}/*** if the queue is empty, we generate events first* @return the first event in the queue*/
public MonkeyEvent getNextEvent() {if (mQ.isEmpty()) {generateEvents();}mEventCount++;MonkeyEvent e = mQ.getFirst();mQ.removeFirst();return e;
}/*** generate a random event based on mFactor*/
private void generateEvents() {// 生成随机数float cls = mRandom.nextFloat();int lastKey = 0;// 根据Factor,即不同测试类型所占的比例,生成测试事件if (cls < mFactors[FACTOR_TOUCH]) {generatePointerEvent(mRandom, GESTURE_TAP);return;} else if (cls < mFactors[FACTOR_MOTION]) {generatePointerEvent(mRandom, GESTURE_DRAG);return;} else if (cls < mFactors[FACTOR_PINCHZOOM]) {generatePointerEvent(mRandom, GESTURE_PINCH_OR_ZOOM);return;} else if (cls < mFactors[FACTOR_TRACKBALL]) {generateTrackballEvent(mRandom);return;} else if (cls < mFactors[FACTOR_ROTATION]) {generateRotationEvent(mRandom);return;} else if (cls < mFactors[FACTOR_PERMISSION]) {mQ.add(mPermissionUtil.generateRandomPermissionEvent(mRandom));return;}// The remaining event categories are injected as key eventsfor (;;) {if (cls < mFactors[FACTOR_NAV]) {lastKey = NAV_KEYS[mRandom.nextInt(NAV_KEYS.length)];} else if (cls < mFactors[FACTOR_MAJORNAV]) {lastKey = MAJOR_NAV_KEYS[mRandom.nextInt(MAJOR_NAV_KEYS.length)];} else if (cls < mFactors[FACTOR_SYSOPS]) {lastKey = SYS_KEYS[mRandom.nextInt(SYS_KEYS.length)];} else if (cls < mFactors[FACTOR_APPSWITCH]) {MonkeyActivityEvent e = new MonkeyActivityEvent(mMainApps.get(mRandom.nextInt(mMainApps.size())));mQ.addLast(e);return;} else if (cls < mFactors[FACTOR_FLIP]) {MonkeyFlipEvent e = new MonkeyFlipEvent(mKeyboardOpen);mKeyboardOpen = !mKeyboardOpen;mQ.addLast(e);return;} else {lastKey = 1 + mRandom.nextInt(KeyEvent.getMaxKeyCode() - 1);}if (lastKey != KeyEvent.KEYCODE_POWER&& lastKey != KeyEvent.KEYCODE_ENDCALL&& lastKey != KeyEvent.KEYCODE_SLEEP&& lastKey != KeyEvent.KEYCODE_SOFT_SLEEP&& PHYSICAL_KEY_EXISTS[lastKey]) {break;}}MonkeyKeyEvent e = new MonkeyKeyEvent(KeyEvent.ACTION_DOWN, lastKey);mQ.addLast(e);e = new MonkeyKeyEvent(KeyEvent.ACTION_UP, lastKey);mQ.addLast(e);
}

以Ttouch事件为例子,调用generatePointerEvent函数。通过DMS获取Display对象(用于得知屏幕大小),生成MonkeyTouchEvent对象。

// development/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
private void generatePointerEvent(Random random, int gesture) {Display display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);PointF p1 = randomPoint(random, display);PointF v1 = randomVector(random);long downAt = SystemClock.uptimeMillis();mQ.addLast(new MonkeyTouchEvent(MotionEvent.ACTION_DOWN).setDownTime(downAt).addPointer(0, p1.x, p1.y).setIntermediateNote(false));// 省略randomWalk(random, display, p1, v1);mQ.addLast(new MonkeyTouchEvent(MotionEvent.ACTION_UP).setDownTime(downAt).addPointer(0, p1.x, p1.y).setIntermediateNote(false));
}

调用MonkeyTouchEvent的injectEvent函数,使用InputManager向系统派发TouchEvent。

// development/cmds/monkey/src/com/android/commands/monkey/MonkeyMotionEvent.java
@Override
public int injectEvent(IWindowManager iwm, IActivityManager iam, int verbose) {MotionEvent me = getEvent();if ((verbose > 0 && !mIntermediateNote) || verbose > 1) {StringBuilder msg = new StringBuilder(":Sending ");msg.append(getTypeLabel()).append(" (");switch (me.getActionMasked()) {case MotionEvent.ACTION_DOWN:msg.append("ACTION_DOWN");break;case MotionEvent.ACTION_MOVE:msg.append("ACTION_MOVE");break;case MotionEvent.ACTION_UP:msg.append("ACTION_UP");break;case MotionEvent.ACTION_CANCEL:msg.append("ACTION_CANCEL");break;case MotionEvent.ACTION_POINTER_DOWN:msg.append("ACTION_POINTER_DOWN ").append(me.getPointerId(me.getActionIndex()));break;case MotionEvent.ACTION_POINTER_UP:msg.append("ACTION_POINTER_UP ").append(me.getPointerId(me.getActionIndex()));break;default:msg.append(me.getAction());break;}msg.append("):");int pointerCount = me.getPointerCount();for (int i = 0; i < pointerCount; i++) {msg.append(" ").append(me.getPointerId(i));msg.append(":(").append(me.getX(i)).append(",").append(me.getY(i)).append(")");}Logger.out.println(msg.toString());}try {// 派发TouchEventif (!InputManager.getInstance().injectInputEvent(me,InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT)) {return MonkeyEvent.INJECT_FAIL;}} finally {me.recycle();}return MonkeyEvent.INJECT_SUCCESS;
}
Monkey主要相关类图

在这里插入图片描述

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

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

相关文章

Leetcoder Day21| 回溯理论基础+组合

语言&#xff1a;Java/Go 回溯理论基础 回溯函数也就是递归函数&#xff1b; 所有回溯法的问题都可以抽象为树形结构&#xff1b; 回溯法解决的都是在集合中递归查找子集&#xff0c;集合的大小就构成了树的宽度&#xff0c;递归的深度&#xff0c;都构成的树的深度。 适用的题…

深度学习基础(一)神经网络基本原理

之前的章节我们初步介绍了机器学习相关基础知识&#xff0c;目录如下&#xff1a; 机器学习基础&#xff08;一&#xff09;理解机器学习的本质-CSDN博客 机器学习基础&#xff08;二&#xff09;监督与非监督学习-CSDN博客 机器学习基础&#xff08;四&#xff09;非监督学…

深入理解计算机系统学习笔记

2.3整数运算 有时候会发现两个正数相加会得出一个负数&#xff0c;而比较表达式x<y和比较表达式x-y<0会产生不同的结果。这些属性是由于计算机运算的有限性造成的。理解计算机运算的细微之处能够帮助程序员编写更可靠的代码。 2 .3. 1 无符号加法 原理&#xff1a; 在正…

前端学习---- 前端HTML基本元素的介绍

一&#xff1a;显示相关的HTML基础知识 1. 推荐的前端编写工具 2. VScode的html速写规则&#xff08;从a标签开始再用&#xff09; ①、&#xff01;&#xff1a;代表生成html的基本框架元素 ②、html元素&#xff1a;直接书写html,不需要加<>,按回车会自动生成 ③、{}…

Java之线程池:线程池常用类、接口;线程池执行流程,配置参数,分类

线程池 什么是线程池&#xff1f; 线程池&#xff1a;一种基于池化思想管理和使用线程的机制 线程池常用类和接口 ExecutorService接口&#xff1a;进行线程池的操作访问Executors类&#xff1a;创建线程池的工具类ThreadPoolExecutor及其子类&#xff1a;封装线程池的核心参…

蓝桥杯备战刷题(自用)

1.被污染的支票 #include <iostream> #include <vector> #include <map> #include <algorithm> using namespace std; int main() {int n;cin>>n;vector<int>L;map<int,int>mp;bool ok0;int num;for(int i1;i<n;i){cin>>nu…

【技术分享】使用nginx完成动静分离➕集成SpringSession➕集成sentinel➕集成seata

&#x1f973;&#x1f973;Welcome 的Huihuis Code World ! !&#x1f973;&#x1f973; 接下来看看由辉辉所写的关于技术点的相关分享吧 目录 &#x1f973;&#x1f973;Welcome 的Huihuis Code World ! !&#x1f973;&#x1f973; 一、 使用nginx完成动静分离 1.下载…

JAVA毕业设计129—基于Java+Springboot+thymeleaf的物业管理系统(源代码+数据库)

毕设所有选题&#xff1a; https://blog.csdn.net/2303_76227485/article/details/131104075 基于JavaSpringbootthymeleaf的物业管理系统(源代码数据库)129 一、系统介绍 本项目前后端分离&#xff0c;本系统分为管理员、小区管理员、用户三种角色 1、用户&#xff1a; 登…

一种简易的多进程文件读写器

目录 1. 前言2. 初步实现3. ParallelFileProcessor 1. 前言 在数据清洗场景下&#xff0c;我们可能需要对一个 .jsonl 文件清洗以得到另一个 .jsonl 文件。一种直观的做法就是逐行读取&#xff0c;逐行清洗&#xff0c;然后逐行写入&#xff0c;这一流程的示意图如下&#xff…

【wails】(6):使用wails做桌面应用开发,使用gin+go-chatglm.cpp进行本地模型运行,在windows上运行成功

1&#xff0c;整体架构说明 主要使用&#xff0c;参考的开源项目是&#xff1a; https://github.com/wailsapp/wails 前端项目&#xff1a; https://github.com/Chanzhaoyu/chatgpt-web 运行模型&#xff1a; https://github.com/Weaxs/go-chatglm.cpp 参考代码&#xff1a; h…

深度神经网络中的计算和内存带宽

深度神经网络中的计算和内存带宽 文章目录 深度神经网络中的计算和内存带宽来源原理介绍分析1&#xff1a;线性层分析2&#xff1a;卷积层分析3&#xff1a;循环层总结 来源 相关知识来源于这里。 原理介绍 Memory bandwidth and data re-use in deep neural network computat…

五.AV Foundation 视频播放 - 标题和字幕

引言 本篇博客主要介绍使用AV Foundation加载视频资源的时候&#xff0c;如何获取视频标题&#xff0c;获取字幕并让其显示到播放界面。 设置标题 资源标题的元数据内容&#xff0c;我们需要从资源的commonMetadata中获取&#xff0c;在加载AVPlayerItem的时候我们已经指定了…

Sentinel微服务流量治理组件实战上

目录 分布式系统遇到的问题 解决方案 Sentinel 是什么&#xff1f; Sentinel 工作原理 Sentinel 功能和设计理念 流量控制 熔断降级 Sentinel工作主流程 Sentinel快速开始 Sentinel资源保护的方式 基于API实现 SentinelResource注解实现 Spring Cloud Alibaba整合…

介绍 PIL+IPython.display+mtcnn for 音视频读取、标注

1. nn.NLLLoss是如何计算误差的? nn.NLLLoss是负对数似然损失函数&#xff0c;用于多分类问题中。它的计算方式如下&#xff1a;首先&#xff0c;对于每个样本&#xff0c;我们需要将其预测结果通过softmax函数转换为概率分布。softmax函数可以将一个向量映射为一个概率分布&…

第四节:Vben Admin登录对接后端getUserInfo接口

系列文章目录 第一节&#xff1a;Vben Admin介绍和初次运行 第二节&#xff1a;Vben Admin 登录逻辑梳理和对接后端准备 第三节&#xff1a;Vben Admin登录对接后端login接口 第四节&#xff1a;Vben Admin登录对接后端getUserInfo接口 文章目录 系列文章目录前言一、回顾Vben…

RK3568平台 阻塞IO和非阻塞IO

一.IO 模型的分类 IO 模型根据实现的功能可以划分为为阻塞 IO、非阻塞 IO、信号驱动IO&#xff0c;IO多路复用和异步 IO。根据等待 IO 的执行结果进行划分&#xff0c;前四个 IO 模型又被称为同步IO. 同步IO与异步IO&#xff1a; 以现实生活去餐馆吃饭为例&#xff0c;根据菜…

Linux——缓冲区封装系统文件操作

&#x1f4d8;北尘_&#xff1a;个人主页 &#x1f30e;个人专栏:《Linux操作系统》《经典算法试题 》《C》 《数据结构与算法》 ☀️走在路上&#xff0c;不忘来时的初心 文章目录 一、FILE二、封装系统接口实现文件操作1、text.c2、mystdio.c3、mystdio.h 一、FILE 因为IO相…

Typora结合PicGo + 使用Github搭建个人免费图床

文章目录 一、国内图床比较二、使用Github搭建图床三、PicGo整合Github图床1、下载并安装PicGo2、设置图床3、整合jsDelivr具体配置介绍 4、测试5、附录 四、Typora整合PicGo实现自动上传 每次写博客时&#xff0c;我都会习惯在Typora写好&#xff0c;然后再复制粘贴到对应的网…

基于springboot+vue的校园社团信息管理系统(前后端分离)

博主主页&#xff1a;猫头鹰源码 博主简介&#xff1a;Java领域优质创作者、CSDN博客专家、阿里云专家博主、公司架构师、全网粉丝5万、专注Java技术领域和毕业设计项目实战&#xff0c;欢迎高校老师\讲师\同行交流合作 ​主要内容&#xff1a;毕业设计(Javaweb项目|小程序|Pyt…

自定义搭建管理系统

最近使用自己搭建的脚手架写了一个简易管理系统&#xff0c;使用webpackreactantd&#xff0c;搭建脚手架参考&#xff1a; 使用Webpack5搭建项目&#xff08;react篇&#xff09;_babel-preset-react-app-CSDN博客 搭建的思路&#xff1a; 1. 基建布局&#xff0c;使用antd的…