上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 164 下一页

2021年4月27日

摘要: #include <iostream> #include <utility> #include <thread> #include <chrono> #include <functional> #include <atomic> #include <vector> using namespace s 阅读全文
posted @ 2021-04-27 19:29 tycoon3 阅读(198) 评论(0) 推荐(0)

2021年4月26日

摘要: root@ubuntu:~/cmd# perf stat -a -e L1-dcache-load-misses,L1-icache-load-misses -p 206 -- sleep 5 Performance counter stats for process id '206': 114,2 阅读全文
posted @ 2021-04-26 20:04 tycoon3 阅读(206) 评论(0) 推荐(0)

2021年4月23日

摘要: 原理 TLB(Translation lookaside buffer)为页表(存放虚拟地址的页地址和物理地址的页地址的映射关系)在CPU内部的高速缓存。TLB的命中率越高,页表查询性能就越好。 TLB的一行为一个页的映射关系,也就是管理了一个页大小的内存: TLB管理的内存大小 = TLB行数 x 阅读全文
posted @ 2021-04-23 18:05 tycoon3 阅读(678) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <unistd.h> int main(int argc, char **argv) { int a[1000][1000]; if(1 == argc) { for(int i = 0; i < 1000; ++i) { for(int j 阅读全文
posted @ 2021-04-23 17:57 tycoon3 阅读(1402) 评论(0) 推荐(1)

2021年4月22日

摘要: 1. 为什么调用pthread_cond_wait之前需要检查条件 在线程调用 pthread_cond_signal() 之前,如果没有线程调用 pthread_cond_wait() 处于阻塞状态,那么什么都不会发生; 在线程调用 pthread_cond_signal() 之后,线程调用了 p 阅读全文
posted @ 2021-04-22 17:41 tycoon3 阅读(1500) 评论(0) 推荐(1)

2021年4月21日

摘要: 处理 SIGPIPE 在网络编程中经常会遇到SIGPIPE信号,默认情况下这个信号会终止整个进程,当然你并不想让进程被SIGPIPE信号杀死。我们不禁会这样思考: 在什么场景下会产生SIGPIPE信号? 要怎样处理SIGPIPE信号? SIGPIPE产生的原因是这样的:如果一个 socket 在接收 阅读全文
posted @ 2021-04-21 19:33 tycoon3 阅读(2504) 评论(0) 推荐(0)
摘要: 如果我们在调用accept函数返回之前, 该客户端TCP发送了一个RST(复位)。在服务器中, 表现为该连接仍在TCP队列中, 等待服务器进程调用accept的时候RST到达。此时返回的套接字是一个已连接,但是却有接受了RST的套接字。 模型图如下: #include <stdio.h> #incl 阅读全文
posted @ 2021-04-21 17:49 tycoon3 阅读(127) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-04-21 17:09 tycoon3 阅读(32) 评论(0) 推荐(0)
摘要: 1、前言 昨天总结了一下Linux下网络编程“惊群”现象,给出Nginx处理惊群的方法,使用互斥锁。为例发挥多核的优势,目前常见的网络编程模型就是多进程或多线程,根据accpet的位置,分为如下场景: (1)单进程或线程创建socket,并进行listen和accept,接收到连接后创建进程和线程处 阅读全文
posted @ 2021-04-21 17:03 tycoon3 阅读(1035) 评论(0) 推荐(0)
摘要: #include <iostream> #include <memory> #include <thread> #include <chrono> #include <mutex> struct Test { Test() { std::cout << " Test::Test()\n"; } ~T 阅读全文
posted @ 2021-04-21 15:08 tycoon3 阅读(140) 评论(0) 推荐(0)
上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 164 下一页

导航