![](https://img-blog.csdnimg.cn/20190813235542398.jpeg?x-oss-process=image/resize,m_fixed,h_224,w_224)
Linux 应用编程
主要记录在Linux下使用的一下函数,功能。
主要有进程间通讯、线程间通讯、网络通讯、时间函数、库封装调用等等
钱德勒宾
玫瑰吸收光芒,大地按捺清香。
展开
-
Linux:监控键盘_C代码
程序:#include <sys/types.h>#include <fcntl.h>#include <time.h>#include <stdio.h>#include <unistd.h>#include <linux/input.h>void listen_device(const char *dev,...原创 2020-01-17 10:14:27 · 895 阅读 · 0 评论 -
Linux:监控鼠标_C代码
程序:#include <sys/types.h>#include <fcntl.h>#include <time.h>#include <stdio.h>#include <unistd.h>#include <linux/input.h>void listen_mice(const char *dev, i...原创 2020-01-17 09:37:02 · 430 阅读 · 0 评论 -
Linux:内核环形缓存区kfifo使用
内核环形缓存区kfifo使用学习C语言的人有时候会问,去哪里看大佬写的代码,然后自己消化学习。其实优秀的代码就在你身边:Linux内核。里面有顶级大师的手笔,有对C语言特性发挥到极致的应用。没有秀一些冷门的知识,只用大家都熟知的特性,就可以完成牛逼的功能。最近项目用到了环形缓存区的功能,是典型的消费者和生产者问题。所以想到了内核中的fifo。想直接把内核中需要的代码拿过来,用到自己的代...原创 2019-07-12 19:52:57 · 1976 阅读 · 1 评论 -
Linux:fd_set 结构体定义及使用
在使用select函数时,fd_set结构体是很重要的。想正确使用select函数,理解fd_set是必不可少的。<sys/select.h>下面给出<sys/select.h>头文件的全部内容:/* `fd_set' type and related macros, and `select'/`pselect' declarations. Copyright...原创 2019-07-09 19:22:36 · 8469 阅读 · 0 评论 -
线程(一):使用pthread_cond_timedwait 设置相对时间
参考链接:https://blog.csdn.net/yichigo/article/details/23459613源码:#include <stdio.h>#include <pthread.h>#include <time.h>pthread_condattr_t test_conda;pthread_mutex_t test_mut...原创 2019-06-27 22:07:04 · 1683 阅读 · 0 评论 -
线程(二):线程/线程锁相关的函数原型
/* int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr); */ /* int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock, const pthread_rwlock...原创 2019-07-08 19:34:08 · 381 阅读 · 0 评论 -
线程(三):pthread_attr_setdetachstate 函数用法
用法:pthread_t tid;pthread_attr_t attr;pthread_attr_init(&attr);pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);pthread_create(&tid, &attr, THREAD_FUNCTION, arg);设...原创 2019-07-08 19:35:34 · 5746 阅读 · 0 评论 -
线程(四):pthread_attr_setstacksize设置线程堆栈大小
pthread_attr_setstacksize可以设置线程堆栈大小,用法: pthread_t thread; int ret; pthread_attr_t thread_attr; pthread_attr_init(&thread_attr); pthread_attr_setstacksize(&thread_attr, 256*1...原创 2019-07-08 19:36:29 · 7090 阅读 · 0 评论 -
线程(五):pthread_detach不会阻塞等待线程结束
#include <stdio.h>#include <string.h>#include <pthread.h> /*创建线程头文件*/static pthread_t pid;void *pfun(){ while(1) { printf("---- \n"); sleep(1); } }int main(){ int r...原创 2019-07-16 19:50:16 · 699 阅读 · 0 评论 -
进程(一):创建及基本概念
进程创建相关原创 2019-08-14 23:52:45 · 315 阅读 · 0 评论 -
进程(二):进程间通讯:无名管道/有名管道
无名管道/有名管道原创 2019-08-14 23:43:41 · 296 阅读 · 0 评论 -
进程(三):进程间通讯:消息队列
消息对列原创 2019-08-15 22:39:32 · 307 阅读 · 0 评论 -
进程(四):进程间通讯:信号
信号原创 2019-08-14 23:44:25 · 228 阅读 · 0 评论 -
进程(五):进程间通讯:信号量
进程间通讯:信号量原创 2019-08-14 23:45:03 · 173 阅读 · 0 评论 -
进程(六):进程间通讯:共享内存
进程间通讯:共享内存原创 2019-08-14 23:45:42 · 179 阅读 · 0 评论 -
进程(七):进程间通讯:本地套接字
待更新可通过该方法实现模块间的消息转发机制原创 2019-08-14 23:46:28 · 311 阅读 · 0 评论 -
Linux:常用时间函数
参考链接:(大神讲的真好)https://www.cnblogs.com/linuxbug/p/4887006.html下面涉及到的函数全部都可以在:man 3 ctime 中找到。1.time:头文件:#include <time.h>函数原型:time_t time(time_t *t);函数描述:returns the time as the nu...原创 2019-08-27 20:05:05 · 3134 阅读 · 0 评论