美文网首页
2019-07-23

2019-07-23

作者: 多血 | 来源:发表于2019-07-23 22:33 被阅读0次

线程同步

互斥量mutex,读写锁rwlock,条件变量cond

demo:
https://www.jianshu.com/p/88fdd500cf44

传递给pthread_cond_wait的互斥变量对条件进行保护,调用者把锁住的互斥量传给函数。函数把调用线程放到等待条件的线程列表上,然后对互斥量解锁,这两个操作时原子操作。这样就关闭了条件检查和线程进入休眠状态等待条件改变这两个操作之间的时间通道,这样线程就不会错过条件的任何变化。pthread_cond_wait返回时,互斥量再次被锁住。

https://feng-qi.github.io/2017/05/08/Why-do-pthreads-condition-variable-functions-require-a-mutex/

Redis BIO

http://tech-happen.site/de55b491.html

Redis AOF

http://tech-happen.site/fd3e9e30.html
1.write前先写入aof_buf中,aof_buf本质是sds,所以不会存在写满的情况。

Redis AOF Rewrite

http://mysql.taobao.org/monthly/2018/12/06/
http://tech-happen.site/d15eb256.html

管道

https://www.geeksforgeeks.org/pipe-system-call/

存量数据

遍历redis把key-value写入新aof文件过程

增量数据

通过pipe发送给子进程,子进程发送停止信号后,余下的增量由父进程写入aof

Redis RDB

http://www.web-lovers.com/redis-source-rdb.html
子进程,关闭监听的套接字closeListeningSockets(AOF Rewrite也是)

相关文章

网友评论

      本文标题:2019-07-23

      本文链接:https://www.haomeiwen.com/subject/bsszlctx.html