linux内核学习笔记
问豆子
这个作者很懒,什么都没留下…
展开
-
共享内存 shared memory 例子
write client/* Filename: shm_write.c */#include<stdio.h>#include<sys/ipc.h>#include<sys/shm.h>#include<sys/types.h>#include<string.h>#include<errno.h>#include<stdlib.h>#include<unistd.h>#includ...原创 2021-03-04 12:07:37 · 10301 阅读 · 1 评论 -
System V 信号量
写了一个demo,用来测试信号量,在终端起两个demo/* t_semget.c Licensed under GNU General Public License v2 or later.*/#include <sys/types.h>#include <sys/ipc.h>#include <sys/sem.h>#include <sys/stat.h>#include <stdio.h>#include &.原创 2021-03-03 21:35:56 · 10009 阅读 · 1 评论 -
系统调用之epoll
epoll的介绍详细请看 man epoll, 或者https://man7.org/linux/man-pages/man7/epoll.7.html 或者有人翻译过了https://www.jianshu.com/p/ee381d365a29自己写了个例子测试, 建立两个fifo, 然后传入给epoll, 向fifo中写入字符串。#include <fcntl.h>#include <sys/types.h>#include <sys/...原创 2021-03-02 19:30:25 · 10232 阅读 · 0 评论 -
系统调用之select
what is select?example例子1, 最简单的官方select例子。#include <stdio.h>#include <stdlib.h>#include <sys/select.h>int main(void){ fd_set rfds; struct timeval tv; int retval; /* Watch stdin (fd 0) to see when it has inp.原创 2021-03-02 11:01:08 · 10380 阅读 · 0 评论 -
系统调用之poll
What is poll?How to use?在https://man7.org/linux/man-pages/man2/poll.2.html中给出了一个简单的例子,可以实现poll多个fds,一旦其中一个fd ready,poll就会返回。/* poll_input.c Licensed under GNU General Public License v2 or later. */#include <poll.h>#include <fcnt.原创 2021-03-01 19:00:31 · 10871 阅读 · 0 评论 -
信号集 SIGINT, SIGTERM, SIGKILL
SIGINT:程序终止信号。当用户按下CRTL+C时通知前台进程组终止进程。SIGTERM:程序结束信号,可以使用 kill <pid> 触发SIGKILL:用来立即结束程序的运行。可以使用kill -9 <pid> 触发SIGTERM和SIGKILL的区别:SIGTERM信号是可以被捕获的,因此可以尝试block,或者忽视,但是SIGKILL不能。下面写了一个简单的例子来佐证这个事情 sig_test.cpp:#include <stdlib...原创 2021-03-01 17:43:48 · 11849 阅读 · 0 评论 -
ubuntu 台式机使用无线网络体验
1. 网购了一款USB无线网卡TL-WN726N2; 编译驱动https://github.com/brektrou/rtl8821CU3. 链接wifi原创 2020-06-28 13:00:29 · 10474 阅读 · 0 评论 -
Linux 内核学习笔记之简单字符设备驱动
设备号#define MINORBITS 20#define MINORMASK ((1U << MINORBITS) - 1)#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))原创 2020-06-06 15:27:58 · 10667 阅读 · 0 评论