01 2022 档案
摘要:转载自 : Web service是什么?- 阮一峰的网络日志 作者: 阮一峰 日期: 2009年8月26日 我认为,下一代互联网软件将建立在Web service(也就是"云")的基础上。 我把学习笔记和学习心得,放到网志上,欢迎指正。 今天先写一个最基本的问题,Web service到底是什么?
阅读全文
摘要:#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <signal.h> #includ
阅读全文
posted @ 2022-01-27 14:43
hellozhangjz
摘要:转载:https://www.cnblogs.com/Tour/p/4170839.html 编写同步队列时,有用到条件变量,对操作队列的线程进行同步。当队列为空时,允许get线程挂起,直到add线程向队列添加元素并通过唤醒条件变量,get线程继续向下运行。条件变量在多线程程序中用来实现“等待->唤
阅读全文
posted @ 2022-01-27 14:42
hellozhangjz
摘要:https://www.aliyundrive.com/s/oBvP7BcjsCS https://blog.csdn.net/weixin_36750623/article/details/83547803 /* 反应堆服务器: 接收客户端的信息,然后发送回去 监听到事件才做对应的回调函数,这是r
阅读全文
posted @ 2022-01-26 14:04
hellozhangjz
摘要:把高电平看作文件描述符是可读或可写状态,低电平黑色表示不可读或不可写,epoll_wait的水平触发就是蓝色的时候epoll_wait就会被触发,而边缘触发就是红色的时候epoll_wait会触发,且只会触发一次。比如,client_fd在某时刻充入数据,epoll_wait第一次检测到,水平、边缘
阅读全文
摘要:声明:此文只是为自己方便理解,做了一些具象的比喻和假设,并不符合客观事实,谨慎阅读! 在一台主机中, 两个进程想要通信可以通过一个管道(文件):一个从管道的一端写,一个从另一端读 , 然而管道是半双工的 , 如果一个进程既想读又想写 , 那就创建两个管道。利用socket进行网络通信的过程与之类
阅读全文
摘要:#include "../wrap/wrap.h" #include <sys/epoll.h> #define SIZE 1024 #define FUCK printf("close or free me\n") #define PORT 8000 #define IP "192.168.68.
阅读全文
posted @ 2022-01-25 13:45
hellozhangjz
摘要:wrap.c见多进程服务器-cainaiozjz #include <stdio.h> #include <sys/select.h> #include <sys/types.h> #include <unistd.h> #include "wrap.h" #include <sys/time.h>
阅读全文
posted @ 2022-01-24 21:09
hellozhangjz
摘要:主程序: #include "wrap.h" #include <signal.h> #include <sys/wait.h> //多进程服务器 void communicate(int client_fd, char *IP) { char buf[1024]; while (1) { prin
阅读全文
摘要:条件变量实现:记一次由虚假唤醒产生的bug 信号量实现: #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h
阅读全文
摘要:记一次由虚假唤醒产生的bug 用int a代表产品数量最少0最多10,有两个生产者,三个消费者,用多线程和条件变量模拟生产消费过程: #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h
阅读全文
摘要:线程共享的资源 文件描述符表 每种信号的处理方式 当前工作目录 用户ID和组ID 内存空间(除了栈区) 线程非共享资源 线程ID 函数运行上下文(各种寄存器的值),栈指针 栈空间 errno变量 信号屏蔽字 调度优先级 线程常用操作 线程号:pthread_self() #include <pthr
阅读全文
摘要:静态变量具有全局变量的生命周期,但属于不同作用域。 (全局)静态变量:作用域为本文件,无法在别的文件用extern声明。 局部静态变量:作用域为所在代码块。 类内静态变量:作用域为类内。 静态成员函数只能访问类的静态变量,不能访问某个对象的非静态变量。 全局变量、(全局)静态变量、类内静态变量在编一
阅读全文
摘要:守护进程 通常,执行命令都要在终端执行。产生的进程也于终端相联系,当shell退出时,和这和终端相关联的进程会收到SIGHUP信号,默认动作是终止进程。守护进程就是一个不依赖终端的进程 进程组 shell启动一个进程,会给该进程创建一个进程组,进程组id就是进程的pid,也可以用setpgrp函
阅读全文
摘要:#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <time.h> #define S
阅读全文
摘要:捕捉信号 signal()函数(不建议) #include <signal.h> typedef void(*sighandler_t)(int); sighandler_t signal(int signum, sighandler_t handler); 功能: 注册信号处理函数(不可用于 SI
阅读全文
摘要:信号集 阻塞信号集:sigprocmask()函数 有的进程想延迟处理一些信号,但又不能忽略,于是就有了阻塞信号的需求。将一些信号值添加到阻塞信号集记录,这些信号发送给进程时进程收不到信号(相当于黑名单),然后将这些信号移除阻塞信号集,进程会立马收到这些信号,进而进行处理。 信号集类型是si
阅读全文
摘要:定时产生信号:alarm()函数 #include <unistd.h> unsigned int alarm(unsigned int seconds); 功能: 设置定时器(闹钟)。在指定seconds后(自然计时法),内核会给当前进程发送14 SIGALRM信号。进程收到该信号,默认动作终止。
阅读全文
摘要:信号的产生 信号的产生是由内核检测到中断,例如Ctrl C或者代码里有除以0,然后系统内核根据不同的类型发送给进程不同的信号。 查看信号的编号用kill -l。 常规信号: 编号 信号 对应事件 默认动作 1 SIGHUP 用户退出shell时,由该shell启动的所有进程将收到这个信号 终止进程
阅读全文
摘要:A,B双方通信,A想向B发送信息,又不想让别人知道,使用非对称加密:若A向B发送信息,A需要知道B的公钥简称B-pub,用B-pub加密信息后 发送给B,B再用自己的私钥B-prv解密出信息。 A想验证B的身份,可以把“123”用B-pub加密后发送给B,若B能用B-prv解密出来并发送给A,那么A
阅读全文
摘要:一个管道文件的通信半双工的,且不能用lseek()函数操作,其他操作与普通文件一样。 1、匿名pipe #include <unistd.h> int pipe(int pipefd[2]); 功能:创建无名管道。 参数: pipefd : 为 int 型数组的首地址,其存放了管道的文件描述符 pi
阅读全文
摘要:进程间控制 一、创建进程:fork()函数 #include <sys/types.h> #include <unistd.h> pid_t fork(void); 功能: 用于从一个已存在的进程中创建一个新进程,新进程称为子进程,原进程称为父进程。 参数: 无 返回值: 成功:子进程中返回 0,父
阅读全文
摘要:二分查找 什么情况用二分算法 对于数组f[x]或者函数f(x) 给出x,容易求Y 给出Y,不容易求x 函数单调 泛型情况下可以把小于目标值看成0,大于等于目标值看成1,问题就转化成查找第一个1的情况。 int binary_search_find_first_one(vector<int> nums
阅读全文
posted @ 2022-01-18 13:41
hellozhangjz
摘要:#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <string.h> const i
阅读全文
摘要:软件下载主页: https://gitee.com/ylzheng/CopyTranslator/wikis/windows 可以设置始终置顶,监听剪切板,翻译起来非常方便
阅读全文
摘要:Ctrl Shift P 输入:snipp,选配置用户代码片段,新建全局代码片段文件,修改下列模板: { // Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, pre
阅读全文
摘要:exec函数不创建新进程,只用磁盘上的程序替换当前进程的正文段、数据段、堆段和栈段。然后从main函数开始运行。 exec函数族使用说明 #include <unistd.h> int execl(const char *pathname, const char *arg, ...) int exe
阅读全文
摘要:其他系统调用 stat #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> int stat(const char *path, struct stat *buf); int lstat(const char *pathn
阅读全文
摘要:常用系统调用 open #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int open(const char *pathname, int flags, mode_t mode); 参数: pathname:文件的路径
阅读全文
摘要:- 启动gdb:`gdb program` - 设置运行参数:`set args 10 20 30` - 启动程序: `run(r)`,`start` - 显示源代码:`list(l)` - 显示当前栈帧和运行行:`frame(f)` - 设置显示源代码的行数:`set listsize count
阅读全文
摘要:静态链接 (1)制作静态链接 #生成目标文件 gcc -c add.c -o add.o gcc -c sub.c -o sub.o #制作静态库 ar -rcs libmylib.a add.o sub.o 在使用ar工具是时候需要添加参数:rcs r更新 c创建 s建立索引 (2)使用静态库 g
阅读全文
摘要:#wildcard – 查找指定目录下的指定类型的文件 SRC = $(wildcard src/*.c) #patsubst – 匹配替换,体会这个模式替换,把相同的部分用%代替 OBJS = $(patsubst src/%.c, obj/%.o, $(SRC)) TARGET = bin/te
阅读全文
摘要:vim技巧 命令模式下:==是缩进当前行,gg=G是格式化全文 :m,n s/vivian/sky m~n行的第一个 vivian 换为 sky :m,n s/vivian/sky/g m~n行所有 vivian 为 sky Ctrl + V是块选择模式 *跳转到变量或函数的定义处 vimrc "输
阅读全文

浙公网安备 33010602011771号