
C语言
文章平均质量分 54
shenhuxi_yu
记录职业生涯
展开
-
riscv 栈空间静态分析
分析riscv架构的裸机代码中最大栈空间。原创 2024-03-07 16:57:49 · 1091 阅读 · 0 评论 -
C语言define 进制数
define 进制数原创 2023-02-15 16:40:17 · 616 阅读 · 0 评论 -
libc 获取文件/文件夹/存储设备 size
libc获取文件大小用stat系统调用即可strcut statst_size代表文件sizest_mode文件类型与文件权限#include <sys/stat.h>DESCRIPTIONThe <sys/stat.h> header shall define the structure of the data returned by the functions fstat(), lstat(), and stat().The stat structu.原创 2021-11-01 20:29:16 · 516 阅读 · 0 评论 -
ulimit 命令使用说明
ulimits areper-process, not per-user nor per-system.Theulimitcommand is built into the shell, so it remains within the same process; however, the adjusted limit only affectsthatprocess, as well as everything you run from it (child processes inherit ...原创 2020-12-18 15:34:41 · 2917 阅读 · 0 评论 -
gcc -fstack protector 原理
之前有次写驱动的时候自己挖了个坑把short类型的参数当int来用导致子函数返回时提示踩了stack protector 机制埋设的guard原创 2020-05-18 10:24:43 · 2457 阅读 · 0 评论 -
gdb 内存操作
使用gdb调试程序,读写操作是很普遍的事情。其中,读操作包括:读取某个变量的值 读取某个内存地址里的内容 读取某个寄存器的值对应地,写操作包括:修改某个变量的值 修改某个内存地址里的内容 修改某个寄存器的值本文将首先简单介绍一下读操作,然后重点介绍一下写操作。1. 读操作读取某个变量的值:p <var> 读取某个内存地址里的内容:x /NFU <...转载 2020-03-23 11:29:46 · 5495 阅读 · 0 评论 -
网络拥塞控制介绍
原理介绍Linux操作系统中的流量控制器TC(Traffic Control)用于Linux内核的流量控制,它利用队列规定建立处理数据包的队列,并定义队列中的数据包被发送的方式, 从而实现对流量的控制。TC模块实现流量控制功能使用的队列规定分为两类,一类是无类队列规定, 另一类是分类队列规定。 无类队列规定相对简单,而分类队列规定则引出了分类和过滤器等概念,使其流量控制功能增强。无类队...转载 2019-12-11 20:22:11 · 1172 阅读 · 0 评论 -
zephyr 多线程与调度
环境: qemu_cortex_m3 zephyr 1.14.1zephyr 支持抢占调度,deadline调度k_thread_create 创建线程优先级列表---------COOP-------PREMPTmax:-16 min:14max:0 min:14----------max:-17 min:0error...原创 2019-11-27 15:27:04 · 493 阅读 · 0 评论 -
kernel gpio userspace 使用
kernel gpio userspace 使用kernel gpio userspace sysfspoll gpiofd 配合gpio 中断monitor gpio状态合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX...原创 2019-11-05 23:59:47 · 431 阅读 · 0 评论 -
linux rt 线程调度
aarch64 linux4.9最近遇到问题需要trace某个rt线程调度情况trace event filter:echo 1 > sched/sched_switch/enable echo "next_comm == xxx" >sched/sched_switch/filter (filter 格式可以cat format 同目录下获得)echo 1 ...原创 2019-07-18 00:37:21 · 1292 阅读 · 0 评论 -
使用TRACE_EVENT trace linux 执行过程
阅读lwn.net文章 Using the TRACE_EVENT() macro 用qemu 做实验原创 2019-07-15 23:14:00 · 921 阅读 · 0 评论 -
linux 线程优先级 rt_prio static_prio prio normal_prio
转载:https://www.cnblogs.com/tongye/p/9615625.htmlkthread_create 创建线程的时候是默认的优先级默认的RT线程rt_prio是0,rt_prio范围是0-99调整线程优先级的函数sched_setschduler 可以调整线程优先级,因为GPL的原因会有必要绕到user space调用的userspace的sched_set...转载 2019-07-15 23:08:47 · 1370 阅读 · 0 评论 -
linux kmemleak false positive
linux4.9 aarch32用kmemleak scan 系统memleak的时候会有一堆的误报的memleak 的callstack,kmemleak 本身就存在这个缺陷这种误报称为 false positive(假阳性)用win10 自带的Ubuntu 用qemu 模拟memleak 做实验分析下什么样的情况会产生false positiveon going.........原创 2019-07-10 23:15:46 · 396 阅读 · 0 评论 -
linux Coherent dma 实现
linux 4.9 armv8void *dma_alloc_coherent(struct device *dev, size_t size,dma_addr_t *dma_handle, gfp_t flag)参数:dev device 结构体中有dma相关的控制比如dma_mask,dma_handle 作实参传递返回的pa,flag分配memory时的控制选项比如GFP_KER...原创 2019-05-21 01:15:37 · 3144 阅读 · 2 评论 -
exterC
时常在cpp的代码之中看到这样的代码:[cpp] view plain copy print?#ifdef __cplusplus extern "C" { #endif //一段代码 #ifdef __cplusplus } #endif 这样的代码到底是什么意思呢?首转载 2017-04-05 21:47:25 · 282 阅读 · 0 评论 -
linux access_ok 用户指针检查
copy_from_user 与 copy_to_user 函数在使用使用user space指针的时候都会用access_ok 函数检查检查的内容:#define access_ok(type, addr, size) (__range_ok(addr, size) == 0)#define __range_ok(addr, size) ({ \ unsigned long flag, rok...原创 2018-06-24 15:42:43 · 4891 阅读 · 2 评论 -
51单片机keil 库函数说明
NOTEThe Keil C51 library includes a number of helper routines for the C51 compiler. These routines perform mundane tasks like loading and storing objects. The code to perform these operations is not i...转载 2018-06-26 20:24:49 · 3189 阅读 · 0 评论 -
arm linux userspace segment fault
偶尔遇到了个userspace的segment fault 的问题,从网上搜了下debug的方法环境是arm64 Linux4.9链接:https://www.doulos.com/knowhow/arm/Embedded_Linux_Debugging_User_Space_Seg_Faults/参照链接中的方法debug:1、异常的时候Linux dmesg 根本没打出来segfault 类似...原创 2018-07-06 00:00:43 · 536 阅读 · 0 评论 -
Linux gdb debug deadlock
gdb 最常用的是在线程挂掉的时候查看现场kernel space的deadlock 一般有debug config lock_up hard_lock soft_lock帮助debug,userspace 发生deadlock的时候可以从现场的call stack 找到mutex 的owner帮助debug两个线程会互相等待对方的mutexgcc -g deadlock.c -...原创 2018-07-17 00:11:19 · 623 阅读 · 0 评论 -
linux platform driver with dts
遇到一个跟init顺序相关的问题,code结构大概如下,目的是用initcall的顺序来控制flag_a的相关的flowtest_a_init{ if(flag_a)......paltform_driver_register(&a_driver);}arch_initcall(test_a_init);b_probe{set_flag_a=1;}b_driver=...原创 2018-06-29 00:58:40 · 788 阅读 · 0 评论 -
linux platform driver without dts
linux3.0 spi-s3c64xx.c最近写一个spi dma的程序,不得已要先改在linux3.0上面有dts支持的情况下一般是dts 的devnode 跟platform driver的of_match_table 的compatible 属性match然后probe3.0的时候还不支持dts,那用来match的属性各自在何处定义的呢static int platfor...原创 2018-07-25 22:51:46 · 480 阅读 · 0 评论 -
arm64 linux bad mode Serror 系统异常
最近在linux4.9 arm64遇到了bad mode的kernel oopsoops的内容大概如下,而且oops过后看起来系统并没有异常,oops出现的概率比较小,而且每次oops打印的信息中task 都是不同的,oops之后,看起来大部分时候系统还是可以正常运行的[ 1259.654597] Bad mode in Error handler detected, code 0xb...原创 2018-07-26 00:14:38 · 13129 阅读 · 0 评论 -
arm hardware breakpoint 与 watchpoint 原理
aarch32 linux4.9kernel 有breakpoint的编码实例data_breakpoint.c相关函数:register_wide_hw_breakpoint //kernel space 地址register_user_hw_breakpoint //user space 地址breakpoint 与watchpoint的原理需要查阅armv7_arch...原创 2018-10-18 23:56:12 · 4808 阅读 · 0 评论 -
C语言define定义数组和函数指针
define预编译原创 2017-07-23 22:09:49 · 17364 阅读 · 0 评论