
C
文章平均质量分 80
gdizcm
反应比较慢
展开
-
linux线程取消, pthread线程取消,pthread_testcancel用法
linux线程取消理解,thread取消原创 2023-12-24 11:24:19 · 2023 阅读 · 0 评论 -
MQTT 环境快速搭建(linux)
1. 安装MQTT服务器 上网搜索apache activemq,找到它的官网。然后下载Linux版本。写文档时版本为ActiveMQ 5.16.3 Release 解压后进入目录,运行:./bin/activemq console 即可启动服务2. 安装MQTT 客户端 在https://github.com/eclipse/paho.mqtt.c下载安装包并解压,进入目录。 make 报错,然后sudo apt install libssl-dev...原创 2021-10-14 20:02:13 · 651 阅读 · 0 评论 -
timer_create定时器
主要内容转载文章https://blog.youkuaiyun.com/sinat_36184075/article/details/80489402头文件:#include <signal.h>#include <time.h>函数声明:int timer_create(clockid_t clockid, struct sigevent * sevp, timer_t * timerid);功能:创建一个POSIX标准的进程定时器参数: @clockid 可选系...原创 2020-11-09 16:29:21 · 716 阅读 · 0 评论 -
使用RTC实时时钟
向rtc设备设置一个周期时间,在循环中每次时间到达时调用。需要管理员权限运行。#include <stdio.h>#include <linux/rtc.h>#include <sys/ioctl.h>#include <sys/time.h>#include <sys/types.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>原创 2020-10-28 15:26:38 · 459 阅读 · 0 评论 -
Linux setitimer定时器(微秒精度)
头文件:#include <sys/time.h>int setitimer(int which, const struct itimerval *new_value, struct itimerval *old_value); //设置定时器setitimer提供三种类型的定时器(即which的值):1. ITIMER_REAL:以实际时间递减,每次到期时发送SIGALRM信号;2. ITIMER_VIRTUAL:以进程在用户模式CPU消耗的时间递减,每次到期时发送SIG...原创 2020-10-09 11:08:07 · 2025 阅读 · 0 评论 -
Linux定时器 select(微秒精度)poll(毫秒精度)
头文件与函数#include <sys/select.h>int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);void FD_CLR(int fd, fd_set *set); //将set中第fd位清除int FD_ISSET(int fd, fd_set *set);//判断set中第fd位是否位1,是返回1否返回1void FD_原创 2020-10-07 15:15:37 · 2428 阅读 · 0 评论 -
Linux秒精度定时器alarm
alarm - 设置传递信号的闹钟头文件与函数:#include <unistd.h>unsigned int alarm(unsigned int seconds);函数描述: alarm()函数以seconds秒为单位发出SIGALRM信号。如果seconds值为0,所有正在等待的alarm信号取消。alarm信号只有一个有效,若有多个,则最后设置的有效。返回值:alarm() 返回上次alarm调用剩余的时间,若之前没有调用则返回0.实例:...原创 2020-10-06 21:14:48 · 500 阅读 · 0 评论 -
C/C++精确计算程序运行时间(Windows)
1、头文件time.h,计时函数clock() clock_t clock(void); //clock_t 是long类型 该函数返回从开启这个进程到该时刻所用的时间,每秒分成CLOCKS_PER_SEC个单元。如果经过的时间过长超出最大表示范围,则返回-1。clock_t start = clock(); // the code need to measure...原创 2019-10-18 15:56:44 · 5239 阅读 · 1 评论