当前位置: 首页 > news >正文

如何查看vs中建设好的网站如何替别人建网站挣钱

如何查看vs中建设好的网站,如何替别人建网站挣钱,营销自己的网站,域名价格查询在 Linux C 应用编程中,对于多线程编程中的定时器函数使用,通常可以借助 pthread 库和系统提供的定时器相关的函数来实现。 首先,常见的定时器函数有 setitimer() 和 alarm() 。setitimer() 函数可以更精确地设置定时器,它可以设…

在 Linux C 应用编程中,对于多线程编程中的定时器函数使用,通常可以借助 pthread 库和系统提供的定时器相关的函数来实现。

首先,常见的定时器函数有 setitimer() 和 alarm() 。setitimer() 函数可以更精确地设置定时器,它可以设置为 ITIMER_REAL(以实时时间递减)、ITIMER_VIRTUAL(以进程在用户态执行的时间递减)和 ITIMER_PROF(以进程在用户态和内核态执行的时间递减)三种模式。

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
#include <time.h>#define TIMER_INTERVAL_SEC 2void timer_handler(union sigval sv)
{printf("Timer expired. Thread ID: %ld\n", pthread_self());
}void* thread_function(void* arg)
{timer_t timer_id;struct sigevent sev;sev.sigev_notify = SIGEV_THREAD;sev.sigev_notify_function = timer_handler;sev.sigev_value.sival_ptr = &timer_id;timer_create(CLOCK_REALTIME, &sev, &timer_id);struct itimerspec its;its.it_interval.tv_sec = TIMER_INTERVAL_SEC;its.it_interval.tv_nsec = 0;its.it_value.tv_sec = 1;its.it_value.tv_nsec = 0;timer_settime(timer_id, 0, &its, NULL);while (1) {sleep(1);}timer_delete(timer_id);pthread_exit(NULL);
}int main()
{pthread_t thread_id1, thread_id2;pthread_create(&thread_id1, NULL, thread_function, NULL);pthread_create(&thread_id2, NULL, thread_function, NULL);pthread_join(thread_id1, NULL);pthread_join(thread_id2, NULL);return 0;
}
#include <stdio.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>#define TIMER_SIG SIGRTMINvoid timer_handler(int sig, siginfo_t *si, void *uc) {// 定时器到期时被调用的处理函数printf("Timer fired!\n");
}int main() {timer_t timerid;struct sigevent sev;struct itimerspec its;struct sigaction sa;// 设置处理函数sa.sa_flags = SA_SIGINFO;sa.sa_sigaction = timer_handler;sigemptyset(&sa.sa_mask);if (sigaction(TIMER_SIG, &sa, NULL) == -1) {perror("sigaction");exit(1);}// 创建定时器sev.sigev_notify = SIGEV_SIGNAL;sev.sigev_signo = TIMER_SIG;sev.sigev_value.sival_ptr = &timerid;if (timer_create(CLOCK_REALTIME, &sev, &timerid) == -1) {perror("timer_create");exit(1);}// 启动定时器its.it_value.tv_sec = 2; // 初次到期时间,2秒后its.it_value.tv_nsec = 0;its.it_interval.tv_sec = 1; // 定时器周期,每隔1秒its.it_interval.tv_nsec = 0;if (timer_settime(timerid, 0, &its, NULL) == -1) {perror("timer_settime");exit(1);}sleep(10); // 等待定时器触发几次return 0;
}

http://www.yayakq.cn/news/184315/

相关文章:

  • 鹿泉城乡建设局网站世纪明珠网站建设
  • 公司网站海报怎么做wordpress分享统计插件下载
  • 门图书馆户网站建设方案在线画流程图的网站
  • 网站的经典推广方法wordpress搭建电子商城
  • 网站出现乱码怎么办互联网公司排名500强名单
  • 移动网站开发内容免费做网站的网站
  • 大型门户网站建设大概多少钱北京网站设计学校
  • 网站模块设计怎么做天津企业网站设计报价
  • 可以建网站的软件怎么在word里做网站
  • 建设一个网站要多市场营销专业就业方向
  • 外贸网站推广渠道锦州网站开发建设
  • 西充建设局网站产品创意设计案例
  • 南京培训网站建设餐饮vi设计手册
  • 如何建设一个静态网站6黑镜主题2.0wordpress
  • 金昌市住房和城乡建设局网站男人做爽的免费网站
  • 收录网站查询做网站首页的图片怎么缩小
  • 广州网站关键排名我的网站现在没有排名_我想问是不是花钱做百度推广就会有排名
  • 自己架设网站备案linux做网站哪个版本好
  • 外贸做的好的网站公司做网站一般多少钱
  • 试用型网站怎么做wordpress手机模板
  • 四川建设网站电子招标主要的网站开发技术路线
  • 网站联系方式设置要求哈尔滨企业建站服务商
  • 顺义手机网站建设电商首页设计图
  • 东莞住建局官网网站齐鲁建设网站
  • 有系统源码可以做网站吗重庆城乡建设子网站
  • 南昌智能建站模板万网买网站
  • 柳州网站推广哪家好做网站公司哪家强
  • 自己做的网站别人怎么上网找到档案网站建设外包公司
  • 山东住房建设部网站天津公司网站建设费
  • 南昌定制网站开发多少钱hemi网站怎么做热图