waitlatch流程
【pg】
0)bgwriter进程调用waitlatch
(gdb) p set->epoll_fd
$1 = 3
1)backend调用setLatch
给bgwriter发sigusr1
2)bgwriter收到信号
往管道里写一个字符,退出信号处理函数
【opengauss】
bgwriter比较类似,改为给线程发信号
1)注册sigusr1处理函数
(void)gspqsignal(SIGUSR1, bgwriter_sigusr1_handler);
2)setlatch实现
SetLatch(g_instance.xx->yyLatch);
gs_signal_send(owner_pid, SIGUSR1);
a) gs_signal_find_slot找到要发送线程所在GsSignalSlot
b) 调用gs_signal_set_signal_by_threadid设置模拟信号
c) 调用gs_signal_thread_kill(thread_id, RES_SIGNAL);
3)bgwriter收到信号后写管道
4)bgwriter被唤醒
rc = select(hifd + 1, &input_mask, &output_mask, NULL, tvp);