#include<stdio.h>
#include<unistd.h>
#include<signal.h>
void handler(int signo)
{
}
// sigsuspend()函数的功能就是-“解除信号屏蔽”-“挂起进程等待信号”-“执行信号处理函数”- “出错返回”。
// 所以sigsuspend()函数函数同pause()函数一样只有出错返回值。在对程序时序要求比较严格的程序中一般使用sigsuspend()函数
int mysleep(int time)
{
// 当前进程 屏蔽SIGALRM信号
sigset_t set, oset;
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigprocmask(SIG_BLOCK, &set, &oset); // 设置set为当前进程的信号集,保存进程以前的信号集合oset
// 设置SIGALRM信号的处理方式
struct sigaction act;
struct sigaction oact;
act.sa_handler = handler;
act.sa_mask = set;
act.sa_flags = 0;
sigaction(SIGALRM, &act, &oact); // oact,保存SIGALRM信号原来的处理方式
// 闹钟函数,在进程中设置一个定时器,当定时器指定的时间到时,它向进程发送SIGALRM信号
alarm(time);
sigset_t susmask = oset;
sigdelset(&susmask, SIGALRM);
// “解除信号屏蔽” - “挂起进程等待信号” - “执行信号处理函数” - “出错返回”
sigsuspend(&susmask);
int _time = alarm(0);
// 重置进程对SIGALRM信号原来的处理方式
sigaction(SIGALRM, &oact, NULL);
// 重置进程原来的信号集
sigprocmask(SIG_BLOCK, &oset, NULL);
return _time;
}
int main()
{
while (1)
{
printf(“hello yingying\n”);
mysleep(2);
}
return 0;
}
参考:
https://www.jb51.net/article/112394.htm
数据库:事务特性:acid,如何实现acid,
https://blog.csdn.net/hxpjava1/article/details/79409395
http://blog.jobbole.com/108569/
https://blog.csdn.net/javaMare/article/details/85163824
https://www.cnblogs.com/AndyAo/p/8228099.html
https://www.w3cschool.cn/architectroad/architectroad-two-phase-commit.html
http://oceanbase.org.cn/?p=195
https://weibo.com/ttarticle/p/show?id=2309403965965003062676