摘要: sudo rm -rf python sudo ln -s /usr/bin/python3 /usr/bin/python 阅读全文
posted @ 2019-03-02 14:03 ForMeDream 阅读(3135) 评论(0) 推荐(0) 编辑
摘要: /**两个线程一个负责监听客户端,一个负责读客户端请求。 服务器模型,*主控线程负责accept监听链接的客户端,*把客户端fd放入任务队列中(),分离子线程则从任务队列取出所有的*客户端描述加入select并处理客户端读请求。*13:06:22*/#include #include #include #include #include #include #include #include #i... 阅读全文
posted @ 2019-02-28 13:00 ForMeDream 阅读(893) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include #include #include union semun { int val; /* Value for SETVAL */ struct semid_ds *buf; /* Buffer... 阅读全文
posted @ 2019-02-26 21:11 ForMeDream 阅读(163) 评论(0) 推荐(0) 编辑
摘要: /* *删除 msgctl(msgid,IPC_RMID,0); ipcrm -q id ipcs -q 查看 *创建 msgqueue 时指定 key 为 IPC_PRIVATE 读取时将不能获得key指定的队列,所以需要自己定key */ #include #include #include #include #include #include #include char path... 阅读全文
posted @ 2019-02-26 16:29 ForMeDream 阅读(530) 评论(0) 推荐(0) 编辑
摘要: 线程间通过 pthread_kill(thid,signo)给指定的thid线程发送signo信号。 创建线程与线程屏蔽字顺序 1. pthread_create(); pthread_sigmask(); 线程创建在前。所以子线程没有继承主线程的接下来设置的屏蔽字。子线程依然可以响应主线程接下来要 阅读全文
posted @ 2019-02-26 02:49 ForMeDream 阅读(1843) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include typedef struct{ int wrok;//线程间通信 标志位 信号灯 int data;//数据 int num; pthread_t rd;//读线程 pthread_t wr;//写线程 sem_t sem;//控制信号量 ... 阅读全文
posted @ 2019-02-25 18:08 ForMeDream 阅读(1296) 评论(0) 推荐(0) 编辑
摘要: gcc -c 只编译不连接 -o *.o(生成.o文件) ar crv name.a *.o *.o (ar 命令把 .o文件打包成 name.a 静态库) 测试 name.a -L 紧跟链接库的路径 -l 库名 -l 库名 阅读全文
posted @ 2019-02-25 17:47 ForMeDream 阅读(390) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 6 int num=0; 7 pthread_mutex_t lock; 8 pthread_t th; 9 10 11 void* th_handler(void* p){ 12 int i=0; 13 for(;i<10;i++){ 14 pth... 阅读全文
posted @ 2019-02-24 14:45 ForMeDream 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 二级指针 指针的指针 阅读全文
posted @ 2019-02-24 02:20 ForMeDream 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<stdlib.h>#include<unistd.h>#define MAX 500typedef struct{ int head; int tail; int* que; int num;}QUE;void initQueue(QUE* q){ 阅读全文
posted @ 2019-02-24 00:16 ForMeDream 阅读(117) 评论(0) 推荐(0) 编辑