MIT XV6 - 1.5 Lab: Xv6 and Unix utilities - xargs
接上文 MIT XV6 - 1.4 Lab: Xv6 and Unix utilities - find
xargs
继续实验,实验介绍和要求如下 (原文链接 译文链接) :
Write a simple version of the UNIX xargs program for xv6: its arguments describe a command to run, it reads lines from the standard input, and it runs the command for each line, appending the line to the command’s arguments. Your solution should be in the file user/xargs.c.
The following example illustrates xarg’s behavior:
$ echo hello too | xargs echo bye bye hello too $
Note that the command here is “echo bye” and the additional arguments are “hello too”, making the command “echo bye hello too”, which outputs “bye hello too”.
Please note that xargs on UNIX makes an optimization where it will feed more than argument to the command at a time. We don’t expect you to make this optimization. To make xargs on UNIX behave the way we want it to for this lab, please run it with the -n option set to 1. For instance
$ (echo 1 ; echo 2) | xargs -n 1 echo 1 2 $
Some hints:
- Use fork and exec to invoke the command on each line of input. Use wait in the parent to wait for the child to complete the command.
- To read individual lines of input, read a character at a time until a newline (‘\n’) appears.
- kernel/param.h declares MAXARG, which may be useful if you need to declare an argv array.
- Add the program to UPROGS in Makefile.
- Changes to the file system persist across runs of qemu; to get a clean file system run make clean and then make qemu.
xargs, find, and grep combine well:
$ find . b | xargs grep hello
will run “grep hello” on each file named b in the directories below “.”.
To test your solution for xargs, run the shell script xargstest.sh. Your solution is correct if it produces the following output:$ make qemu...init: starting sh$ sh < xargstest.sh$ $ $ $ $ $ hellohellohello$ $
You may have to go back and fix bugs in your find program. The output has many $ because the xv6 shell doesn’t realize it is processing commands from a file instead of from the console, and prints a $ for each command in the file.
上面这句话👆,竟然还留了个坑
这个实验就是让我们实现一个简单版的xargs,利用管道和多进程来实现命令的组合以打破对参数数量的限制,比如当我们处理日志文件,将所有包含某个字符串的一条记录输出到一个新的文件,或者处理find的输出等等,彻底贯彻"工具集"这个思想。
实验前的准备
想要做好这个实验,不得不重温一下教材了,重点看一下 1.2 I/O and File descriptors 和 1.3 Pipes,要用到的重要的知识点总结如下:
- A file descriptor is a small integer representing a kernel-managed object that a process may read from or write to.
- Internally, the xv6 kernel uses the file descriptor as an index into a per-process table, so that
every process has a private space of file descriptors starting at zero. - By convention, a process reads from file descriptor 0 (standard input), writes output to file descriptor 1 (standard output), and writes error messages to file descriptor 2 (standard error).
- The close system call releases a file descriptor, making it free for reuse by a future open, pipe, or dup system call (see below).
A newly allocated file descriptor is always the lowestnumbered unused descriptor of the current process
.
有一个 shell 中关于 cat 有趣(tricky)的实现, 对应这上面第一段红色的描述:
char *argv[2];
argv[0] = "cat";
argv[1] = 0;
if(fork() == 0) {close(0);open("input.txt", O_RDONLY);exec("cat", argv);
}
After the child closes file descriptor 0, open is guaranteed to use that file descriptor for the newly opened input.txt: 0 will be the smallest available file descriptor. cat then executes with file descriptor 0 (standard input) referring to input.txt. The parent process’s file descriptors are not changed by this sequence, since it modifies only the child’s descriptors.
什么意思呢,当我们在 shell 中执行 cat < input.txt
的时候,shell 会在创建的子进程中把 标准输入文件描述符 0
给释放掉,这样我们下一个 open
的调用返回的文件描述符必然是 0
,这样当 cat
真正执行的时候,可以不用管是要从哪里读取内容,不管是文件也好,管道也罢,而且这个操作对父进程完全没影响,让我们先看一下 cat.c
的实现
void cat(int fd)
{int n;while((n = read(fd, buf, sizeof(buf))) > 0) {if (write(1, buf, n) != n) {fprintf(2, "cat: write error\n");exit(1);}}if(n < 0){fprintf(2, "cat: read error\n");exit(1);}
}int main(int argc, char *argv[])
{int fd, i;if(argc <= 1){cat(0);exit(0);}for(i = 1; i < argc; i++){if((fd = open(argv[i], O_RDONLY)) < 0){fprintf(2, "cat: cannot open %s\n", argv[i]);exit(1);}cat(fd);close(fd);}exit(0);
}
可以看到,当参数数量 <=1
时,直接调用 cat
函数,而 cat
函数就是从给的文件描述符里面不停的读,一边读一边往标准输出中写,做一个规规矩矩的复读机;而参数 >1
的时候才会去把每个参数挨个打开,不管你是设备是文件,然后分别调用 cat
。
先决条件有了,让我们去追一下xv6 中 shell
的真正实现,代码在 user/sh.c, 我们就假设现在在 shell 中输入了cat < input.txt
,一步一步看看是怎么调用到 cat
的:
-
获取当前命令
int main(void) {...// Read and run input commands.while(getcmd(buf, sizeof(buf)) >= 0){if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){// Chdir must be called by the parent, not the child.buf[strlen(buf)-1] = 0; // chop \nif(chdir(buf+3) < 0)fprintf(2, "cannot cd %s\n", buf+3);continue;}if(fork1() == 0)runcmd(parsecmd(buf));wait(0);}exit(0); }
如果不是 cd 则直接 fork ,在子进程中解析和运行命令
-
parsecmd
->parseline
->parsepipe
->parseexec
->parseredirs
,好了我已经吐了这么深的调用路径,让我们看看parseredirs
的实现:struct cmd* redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd) {struct redircmd *cmd;cmd = malloc(sizeof(*cmd));memset(cmd, 0, sizeof(*cmd));cmd->type = REDIR;cmd->cmd = subcmd;cmd->file = file;cmd->efile = efile;cmd->mode = mode;cmd->fd = fd;return (struct cmd*)cmd; }struct cmd* parseredirs(struct cmd *cmd, char **ps, char *es) {int tok;char *q, *eq;while(peek(ps, es, "<>")){tok = gettoken(ps, es, 0, 0);if(gettoken(ps, es, &q, &eq) != 'a')panic("missing file for redirection");switch(tok){case '<':cmd = redircmd(cmd, q, eq, O_RDONLY, 0);break;case '>':cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE|O_TRUNC, 1);break;case '+': // >>cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);break;}}return cmd; }
你看啊,当
tok
是>
和<
的时候,构建cmd
的时候,传入的参数fd
刚好一个是stdin: 0
和stdout: 1
-
然后就是
runcmd
函数对REDIR
类型命令的处理void runcmd(struct cmd *cmd) {...switch(cmd->type){...case EXEC:ecmd = (struct execcmd*)cmd;if(ecmd->argv[0] == 0)exit(1);exec(ecmd->argv[0], ecmd->argv);fprintf(2, "exec %s failed\n", ecmd->argv[0]);break;case REDIR:rcmd = (struct redircmd*)cmd;close(rcmd->fd);if(open(rcmd->file, rcmd->mode) < 0){fprintf(2, "open %s failed\n", rcmd->file);exit(1);}runcmd(rcmd->cmd);break;}exit(0); }
这里干了什么,先
close(rcmd->fd)
,也就是刚刚传入的stdin: 0
, 然后呢调用open
去打开cat < input.txt
传入的input.txt
,然后再调用runcmd(rcmd->cmd)
, 这时候就是一个EXEC
类型的命令了,直接一条exec(ecmd->argv[0], ecmd->argv)
走你,而且紧跟着一条错误输出,这是因为如果exec
调用成功的话,根本不会继续走下去了.
实验正文
我们的 xargs 走的是 PIPE
类型的 cmd
:
void runcmd(struct cmd *cmd)
{...switch(cmd->type){case EXEC:ecmd = (struct execcmd*)cmd;if(ecmd->argv[0] == 0)exit(1);exec(ecmd->argv[0], ecmd->argv);fprintf(2, "exec %s failed\n", ecmd->argv[0]);break;case PIPE:pcmd = (struct pipecmd*)cmd;if(pipe(p) < 0)panic("pipe");if(fork1() == 0){close(1);dup(p[1]);close(p[0]);close(p[1]);runcmd(pcmd->left);}if(fork1() == 0){close(0);dup(p[0]);close(p[0]);close(p[1]);runcmd(pcmd->right);}close(p[0]);close(p[1]);wait(0);wait(0);break;}exit(0);
}
假设我们测试用命令 find . b | xargs grep hello
,那么 pcmd->left
就是 find . b
,pcmd->right
就是 xargs grep hello
,你看啊,他直接把管道左侧的子进程的 stdout: 1
利用 dup(p[1])
给重定向到管道的写端口,把右侧子进程的 stdin: 0
利用 dup(p[0])
给重定向到管道的读端口,然后两个子进程分别把管道读写端口描述符都关了一遍。。。但管道依然在,这帮子人最早是如何想到这种写法的?
那么我们要做的就是循环读 stdin: 0
呗,读到换行符 \n
,就把这一行内容当成一个参数附加到参数列表中传给子进程,然后就等子进程执行完,不管错误与否,直接下一轮。
/*** xargs.c - A simplified implementation of the Unix xargs command** This module implements a basic version of the xargs command, which reads* items from standard input, delimited by newlines, and executes a command for* each item.** Algorithm Description:* 1. Read command-line arguments (the command to execute)* 2. Read input lines from stdin* 3. For each input line:* - Construct argument list by combining command args and input line* - Fork a child process* - Execute the command in child process* - Parent waits for child to complete** Sequence Diagram:** Parent Process Child Process* | |* |-- fork() --------------------> |* | |* |<-- exec(command, args) ------- |* | |* |-- wait() --------------------> |* | |* |<-- exit() -------------------- |* | |** @author: xv6-labs* @version: 1.0*/#include "kernel/types.h"
#include "kernel/param.h"
#include "user/user.h"
#include "kernel/fcntl.h"/*** Reads a single line from standard input into the provided buffer** @param buf: Buffer to store the read line* @param max: Maximum number of characters to read* @return: Number of characters read (excluding null terminator)** This function reads characters one by one from stdin until either:* - A newline character is encountered* - The maximum buffer size is reached* - End of input is reached*/
int readline_from_stdin(char* buf, int max) {int n = 0;while (n < max && read(0, buf + n, 1) > 0) {if (buf[n] == '\n') {break;}n++;}buf[n] = '\0';return n;
}/*** Main function implementing the xargs command** Usage: xargs command [arg1 arg2 ...]** The program:* 1. Validates command-line arguments* 2. Reads input lines from stdin* 3. For each line:* - Constructs argument list* - Executes command with arguments** @param argc: Number of command-line arguments* @param argv: Array of command-line argument strings* @return: 0 on success, 1 on error*/
int main(int argc, char* argv[]) {// Validate minimum number of argumentsif (argc < 2) {fprintf(2, "usage: xargs command\n");exit(1);}// Check if number of arguments exceeds system limit// MAXARG - 1 because we need space for the command and input lineif (argc > MAXARG - 1) {fprintf(2, "xargs: too many arguments\n");exit(1);}char buf[1024]; // Buffer for reading input lineschar* args[MAXARG]; // Array to hold command argumentsargs[0] = argv[1]; // First argument is the command to execute// Process each line from stdinwhile (readline_from_stdin(buf, sizeof(buf) / sizeof(buf[0])) > 0) {// Copy command-line arguments to args arrayfor (int i = 2; i < argc; i++) {args[i - 1] = argv[i];}args[argc - 1] = buf; // Add the input line as the last argumentargs[argc] = 0; // Null terminate the argument list// Create child process to execute commandif (fork() == 0) {exec(argv[1], args); // Execute command with constructed argumentsfprintf(2, "xargs: exec %s failed\n", argv[1]);}wait(0); // Parent waits for child to complete}exit(0);
}
开始我跑偏了,写着写着忘了题目要求是把读到的一行内容当参数传给子进程,我又搞了一遍管道重定向的操作,结果总是不行,看了 grep 的源码才发现有问题。实验结果如下:
make qemu
qemu-system-riscv64 -machine virt -bios none -kernel kernel/kernel -m 128M -smp 3 -nographic -global virtio-mmio.force-legacy=false -drive file=fs.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0xv6 kernel is bootinghart 1 starting
hart 2 starting
init: starting sh
$ sh < xargstest.sh
$ $ $ $ $ $ hello
hello
hello
$ $
另外实验末尾的这句话,我没看懂,我理解,这明明是 shell user/sh.c
的问题啊?怎么让我去改 find
呢?
You may have to go back and fix bugs in your find program. The output has many $ because the xv6 shell doesn’t realize it is processing commands from a file instead of from the console, and prints a $ for each command in the file.
我直接执行 find . b | xargs grep hello
就没有这么多 $
了啊,所以为什么让我去改 find
??
$ find . b | xargs grep hello
hello
hello
hello
$
相关文章:
MIT XV6 - 1.5 Lab: Xv6 and Unix utilities - xargs
接上文 MIT XV6 - 1.4 Lab: Xv6 and Unix utilities - find xargs 继续实验,实验介绍和要求如下 (原文链接 译文链接) : Write a simple version of the UNIX xargs program for xv6: its arguments describe a command to run, it reads lines from the standard …...
Springboot整合Swagger3
Springboot整合Swagger3、常用注解解释、访问Swagger地址出现404、403、拒绝访问等问题_swagger3注解-CSDN博客...
经典音乐播放器——完美歌词 Poweramp Music Player 3 build
—————【下 载 地 址】——————— 【本章单下载】:https://drive.uc.cn/s/d6c480bc47604 【百款黑科技】:https://ucnygalh6wle.feishu.cn/wiki/HPQywvPc7iLZu1k0ODFcWMt2n0d?fromfrom_copylink —————【下 载 地 址】——————— 本…...
锚定基础与拥抱融合:C 语言在编程教育与技术社区的破圈之路
引言 在 Python 占据 TIOBE 指数榜首的 2025 年,C 语言以 23.4% 的稳定份额(2025 年 5 月数据)持续稳居前三,这一现象在编程教育领域尤为显著:全球 92% 的计算机科学本科课程仍将 C 语言作为必修基础课,而…...
深度学习入门:从神经网络基础到前向传播全面解析
深度学习入门:从神经网络基础到前向传播全面解析 🔥 重磅干货! 本文是《深度学习基础与核心技术详解》专栏的开篇之作,将系统性地带你走进深度学习的世界!建议收藏+关注,错过可能要找很久哦~ 目录 深度学习概述神经网络基础 2.1 生物神经元与人工神经元2.2 感知机模型2.…...
Lambda表达式能用在哪些场景?
Lambda表达式是Java 8引入的一种强大特性,它允许以简洁的方式表示匿名函数(即没有名字的函数)。Lambda表达式可以用于许多场景,尤其是在与函数式接口、Stream API、并发编程等结合时,能够显著简化代码并提高开发效率。…...
英语听力口语词汇--2.宣传类
1.approach uk /əˈprəʊtʃ/ n.(思考问题的)方式,方法,态度 2.foreign uk /ˈfɒr.ən/ adj.外国的 3.alliance uk /əˈlaɪ.əns/ n.结盟国家(或团体),同盟国家(或团体)&...
『 测试 』测试基础
文章目录 1. 调试与测试的区别2. 开发过程中的需求3. 开发模型3.1 软件的生命周期3.2 瀑布模型3.2.1 瀑布模型的特点/缺点 3.3 螺旋模型3.3.1 螺旋模型的特点/缺点 3.4 增量模型与迭代模型3.5 敏捷模型3.5.1 Scrum模型3.5.2 敏捷模型中的测试 4 测试模型4.1 V模型4.2 W模型(双V…...
Pandas 时间处理利器:to_datetime() 与 Timestamp() 深度解析
Pandas 时间处理利器:to_datetime() 与 Timestamp() 深度解析 在数据分析和处理中,时间序列数据扮演着至关重要的角色。Pandas 库凭借其强大的时间序列处理能力,成为 Python 数据分析领域的佼佼者。其中,to_datetime() 函数和 Ti…...
支持向量机的回归用法详解
支持向量机的回归用法详解 在机器学习的广阔领域中,支持向量机(SVM)是一种极具影响力的算法,它不仅在分类任务上表现出色,在回归任务中同样有着独特的应用价值。本文将深入探讨 SVM 的回归用法,包括其基本…...
计算机基础
今天不和大家分享算法了,最近为什么一直分享算法题,一个是因为最近很忙加上状态不太在线,第二个是因为我报了ICPC的比赛,也就是大学生程序设计大赛,所以平时刷算法比较多一些,虽然说结果上也没有很多的收获…...
用C语言实现的——一个支持完整增删查改功能的二叉排序树BST管理系统,通过控制台实现用户与数据结构的交互操作。
一、知识回顾 二叉排序树(Binary Search Tree,BST),又称二叉查找树或二叉搜索树,是一种特殊的二叉树数据结构。 基本性质: ①有序性 对于树中的每个节点,其左子树中所有节点的值都小于该节点的…...
uniapp-商城-53-后台 商家信息(更新修改和深浅copy)
1、概述 文章主要讨论了在数据库管理中如何处理用户上传和修改商家信息的问题,特别是通过深浅拷贝技术来确保数据更新的准确性和安全性。 首先,解释了深拷贝和浅拷贝的区别:浅拷贝使得两个变量共享相同的内存地址,而深拷贝则创建新…...
vue数据可视化开发echarts等组件、插件的使用及建议-浅看一下就行
在 Vue 项目中使用 ECharts 进行数据可视化开发时,可以结合 Vue 的响应式特性和 ECharts 的强大功能,实现动态、交互式的图表展示。 一、ECharts 基础使用 1. 安装 ECharts npm install echarts2. 在 Vue 组件中使用 ECharts <template><div…...
百度AI战略解析:文心一言与自动驾驶的双轮驱动
百度AI战略解析:文心一言与自动驾驶的双轮驱动 系统化学习人工智能网站(收藏):https://www.captainbed.cn/flu 文章目录 百度AI战略解析:文心一言与自动驾驶的双轮驱动摘要引言一、技术架构:大模型与自动…...
MCP Streamable HTTP 传输层的深度解析及实战分析
一、Streamable HTTP 传输层设计革新 1. 核心设计思想 协议融合:将 HTTP/1.1、HTTP/2 与 SSE 协议特性深度整合动态协商:通过 HTTP Header 实现传输协议动态协商(X-MCP-Transport)流式优先:默认启用流式传输,支持半双工通信背压控制:基于 HTTP/2 流级流量控制实现智能速…...
六大设计模式--OCP(开闭原则):构建可扩展软件的基石
写在前面:一个真实的项目悲剧 某电商平台促销功能每次迭代都需要修改核心订单类,导致: ✅ 双十一活动修改导致支付功能崩溃 ✅ 新人优惠引发会员系统连环故障 ✅ 每次发布需全量回归测试 根本原因:系统架构违反开闭原则 一、开闭…...
ActiveMQ 生产环境问题排查与调优指南(一)
一、引言 在当今复杂的分布式系统架构中,消息中间件扮演着至关重要的角色,而 ActiveMQ 作为一款广泛使用的开源消息中间件,凭借其丰富的特性、良好的稳定性和易用性,在众多企业的生产环境中占据了一席之地。它基于 JMS(…...
深入理解 JavaScript 中的 FileReader API:从理论到实践
文章目录 深入理解 JavaScript 中的 FileReader API:从理论到实践前言什么是 FileReader?核心特性 FileReader 的常用方法事件监听实际案例案例 1:读取文本文件内容案例 2:图片预览(Data URL)案例 3&#x…...
Google LLM prompt engineering(谷歌提示词工程指南)
文章目录 基本概念AI输出配置:调整AI的回答方式输出长度温度(Temperature)Top-K和Top-P 提示技术:让AI更好地理解你零样本提示(Zero-shot)少样本提示(Few-shot)系统提示(…...
前端npm包发布流程:从准备到上线的完整指南
无论是使用第三方库还是创建和分享自己的工具,npm都为我们提供了一个强大而便捷的平台,然而很多开发者在将自己的代码发布到npm上时往往面临各种困惑和挑战,本篇文章将从准备工作到发布上线,探讨如何让npm包更易发布及避免常见的坑…...
【MySQL】表空间结构 - 从何为表空间到段页详解
📢博客主页:https://blog.csdn.net/2301_779549673 📢博客仓库:https://gitee.com/JohnKingW/linux_test/tree/master/lesson 📢欢迎点赞 👍 收藏 ⭐留言 📝 如有错误敬请指正! &…...
OB Cloud 云数据库V4.3:SQL +AI全新体验
OB Cloud 云数据库V4.3:SQL AI全新体验 简介 OB Cloud云数据库全新升级至V4.3版本,为用户带来了SQLAI的最新技术体验,强化数据库的传统功能,深度融合了人工智能技术,引入先进的向量检索功能和优化的SQL引擎,…...
【Linux系统】第四节—详解yum+vim
hello 我是云边有个稻草人 Linux—本节课所属专栏—欢迎订阅—持续更新中~ 目录 画板—本节课知识点详解 一、软件包管理器 1.1 什么是软件包 1.2 Linux软件⽣态 1.3 yum具体操作 【查看软件包】 【安装软件】 【卸载软件】 【注意事项】 1.4 安装源 二、vim 2.1 …...
Git的核心作用详解
一、版本控制与历史追溯 Git作为分布式版本控制系统,其核心作用是记录代码的每一次修改,形成完整的历史记录。通过快照机制,Git会保存每次提交时所有文件的完整状态(而非仅记录差异),确保开发者可以随时回…...
Three.js + React 实战系列 - 职业经历区实现解析 Experience 组件✨(互动动作 + 3D 角色 + 点击切换动画)
对个人主页设计和实现感兴趣的朋友可以订阅我的专栏哦!!谢谢大家!!! 在这篇博客中,我们将分析一个极其有趣和互动性的组件 - Experience.jsx,该组件用于在主页中呈现个人的工作经历。 这个组件…...
3D虚拟工厂vue3+three.js
1、在线体验 3D虚拟工厂在线体验 2、功能介绍 1. 全屏显示功能2. 镜头重置功能3. 企业概况信息模块4. 标签隐藏/显示功能5. 模型自动旋转功能6. 办公楼分层分解展示7. 白天/夜晚 切换8. 场景资源预加载功能9. 晴天/雨天/雾天10. 无人机视角模式11. 行人漫游视角模式12. 键盘…...
[Java实战]Spring Boot 解决跨域问题(十四)
[Java实战]Spring Boot 解决跨域问题(十四) 一、CORS 问题背景 什么是跨域问题? 当浏览器通过 JavaScript 发起跨域请求(不同协议、域名、端口)时,会触发同源策略限制,导致请求被拦截。 示例场…...
嵌入式硬件篇---CAN
文章目录 前言1. CAN协议基础1.1 物理层特性差分信号线终端电阻通信速率总线拓扑 1.2 帧类型1.3 数据帧格式 2. STM32F103RCT6的CAN硬件配置2.1 硬件连接2.2 CubeMX配置启用CAN1模式波特率引脚分配过滤器配置(可选) 3. HAL库代码实现3.1 CAN初始化3.2 发…...
(2025)图文解锁RAG从原理到代码实操,代码保证可运行
什么是RAG RAG(检索增强生成)是一种将语言模型与可搜索知识库结合的方法,主要包含以下关键步骤: 数据预处理 加载:从不同格式(PDF、Markdown等)中提取文本分块:将长文本分割成短序列(通常100-500个标记),作为检索单元…...
TWAS、GWAS、FUSION
全基因组关联研究(GWAS,Genome-Wide Association Study)是一种统计学方法,用于在全基因组水平上识别与特定性状或疾病相关的遗传变异。虽然GWAS可以识别与性状相关的遗传信号,但它并不直接揭示这些遗传变异如何影响生物…...
大模型微调终极方案:LoRA、QLoRA原理详解与LLaMA-Factory、Xtuner实战对比
文章目录 一、微调概述1.1 微调步骤1.2 微调场景 二、微调方法2.1 三种方法2.2 方法对比2.3 关键结论 三、微调技术3.1 微调依据3.2 LoRA3.2.1 原理3.2.2 示例 3.3 QLoRA3.4 适用场景 四、微调框架4.1 LLaMA-Factory4.2 Xtuner4.3 对比 一、微调概述 微调(Fine-tun…...
FHE 之 面向小白的引导(Bootstrapping)
1. 引言 FHE初学者和工程师常会讨论的一个问题是; “什么是引导(bootstrapping)?” 从理论角度看,这个问题的答案很简单: 引导就是套用 Gentry 提出的思想——在加密状态下同态地执行解密操作ÿ…...
安装:Kali2025+Docker
安装:Kali2025Docker Kali2025安装 直接官网下载WMware版本 https://www.kali.org/get-kali/#kali-virtual-machines 直接打开运行 初始用户密码 kali/kali sudo -i 命令切换到root 更换镜像 切换到其他可用的 Kali Linux 镜像源可能会解决问题,可以使用国内的镜像源&…...
什么是深拷贝什么是浅拷贝,两者区别
什么是深拷贝什么是浅拷贝,两者区别 1.深拷贝 递归复制对象的所有层级,嵌套的引用类型属性,最后生成一个完全独立的新对象,与原对象无任何引用关联。 特点: 新对象和原对象的所有层级属性是独立的(修改…...
A2A大模型协议及Java示例
A2A大模型协议概述 1. 协议作用 A2A协议旨在解决以下问题: 数据交换:不同应用程序之间的数据格式可能不一致,A2A协议通过定义统一的接口和数据格式解决这一问题。模型调用:提供标准化的接口,使得外部应用可以轻松调…...
第七章 数据库编程
1 数据库编程基础 1.1 数据库系统概述 数据库系统是由数据库、数据库管理系统(DBMS)和应用程序组成的完整系统。其主要目的是高效地存储、管理和检索数据。现代数据库系统通常分为以下几类: 关系型数据库(RDBMS):如MySQL、PostgreSQL、Oracle等&#x…...
电影感户外哑光人像自拍摄影Lr调色预设,手机滤镜PS+Lightroom预设下载!
调色详情 电影感户外哑光人像自拍摄影 Lr 调色,是借助 Lightroom 软件,针对户外环境下拍摄的人像自拍进行后期处理。旨在模拟电影画面的氛围与质感,通过调色赋予照片独特的艺术气息。强调打造哑光效果,使画面色彩不过于浓烈刺眼&a…...
C++--类的构造函数与初始化列表差异
一,引言 在类中成员函数的构造函数担任其将对象初始化的作用,而初始化列表也有着相似的作用。大部分人建议都是初始化列表进行初始化,本文主要进行讲解二者的区别。 首先看一下构造函数的初始化方式: #define _CRT_SECURE_NO…...
深入浅出之STL源码分析4_类模版
1.引言 我在上面的文章中讲解了vector的基本操作,然后提出了几个问题。 STL之vector基本操作-CSDN博客 1.刚才我提到了我的编译器版本是g 11.4.0,而我们要讲解的是STL(标准模板库),那么二者之间的关系是什么&#x…...
Lambda表达式解读
本文通过具体案例演示函数式接口Function<T,R>的三种实现方式演变过程。 一、传统匿名内部类实现 Integer resInt1 t1(new Function<String, Integer>() {Overridepublic Integer apply(String s) {int i Integer.parseInt(s);return i;} });实现特点࿱…...
PySide6 GUI 学习笔记——常用类及控件使用方法(常用类边距QMarginsF)
文章目录 类简介方法总览关键说明示例代码 类简介 QMarginsF 用于定义四个浮点型边距(左、上、右、下),描述围绕矩形的边框尺寸。所有边距接近零时 isNull() 返回 True,支持运算符重载和数学运算。 方法总览 方法名/运算符参数返…...
Android方法耗时监控插件开发
需求:自定义一个Gradle插件,这个Gradle插件可以统计方法的耗时,并当方法耗时超过阈值时,可以通过打印Log日志在控制台,然后可以通过Log定位到耗时方法的位置,帮助我们找出耗时方法和当前线程名,…...
TWAS / FUSION
FUSION 是一套用于执行转录组范围和调控组范围关联研究(TWAS 和 RWAS)的工具。它通过构建功能/分子表型的遗传成分的预测模型,并使用 GWAS 汇总统计数据预测和测试该成分与疾病的关联,目标是识别 GWAS 表型与仅在参考数据中测量的…...
C++中的static_cast:类型转换的安全卫士
C中的static_cast:类型转换的安全卫士 在C编程中,类型转换是不可避免的操作,而static_cast作为C四大强制类型转换运算符之一,是最常用且相对安全的一种转换方式。今天我们就来深入探讨一下这个重要的类型转换工具。 一、static_…...
uniapp-商城-51-后台 商家信息(logo处理)
前面对页面基本进行了梳理和说明,特别是对验证规则进行了阐述,并对自定义规则的兼容性进行了特别补充,应该说是干货满满。不知道有没有小伙伴已经消化了。 下面我们继续前进,说说页面上的logo上传组件,主要就是uni-fil…...
04 mysql 修改端口和重置root密码
当我们过了一段时间,忘了自己当初创建的数据库密码和端口,或者端口被占用了,要怎么处理呢 首先,我们先停止mysql。 一、修改端口 打开my.ini文件,搜索port,默认是3306,根据你的需要修改为其他…...
多线程 2 - 死锁问题
死锁 死锁,是多线程代码中的一类经典问题。加锁能够解决线程安全问题,但如果加锁方式不当,就很可能产生死锁。 出现死锁的三种场景 1、一个线程一把锁 就像上篇文章讲过的,如果对同一个线程上了两把锁,而且上的锁是…...
网络原理(Java)
注:此博文为本人学习过程中的笔记 在网络初始中谈到TCP/IP五层模型,接下来我们将介绍这里面涉及到的网络协议。 应用层是程序员接触最多的层次,程序员写的代码只要涉及到网络通信都可以视为是应用层的一部分。应用层里的东西和程序员直接相…...
HDFS 常用基础命令详解——快速上手分布式文件系统
简介: 本文面向刚接触 Hadoop HDFS(Hadoop 分布式文件系统)的读者,结合 CSDN 博客风格,系统梳理最常用的 HDFS 客户端命令,并配以示例和注意事项,帮助你在开发和运维中快速掌握 HDFS 的文件管理…...