mmap

面经总结-仅供参考

别等时光非礼了梦想. 提交于 2019-12-20 21:04:52
面经总结-仅供参考 1 服务器如何判断客户端连接不上了 2 心跳包多长时间发一次,如何判断客户端下线了 3 四次挥手 通过什么接口来判断????? 4 epoll只能练500-1000个连接,有没有判断是什么原因引起的 5 noSQL-redis 6 消息队列-应用场景 7 [微服务容器](https://www.cnblogs.com/jsjwk/p/11169296.html) 8 虚函数析构函数和普通虚函数区别,及原因,析构顺序 10 [Redis为什么是单线程的](https://blog.csdn.net/wanderlustlee/article/details/81148840) 11 不同机器进程间如何通信: 12 服务器如何转发消息的 14 西安发消息到上海,接收方消息延迟了,原因 15客户端发了很多消息,服务器怎么及时处理? 16客户端收到大量数据会导致客户端卡顿,怎么优化? 17. 十几个日志文件,用什么shell命令可以筛选出自己想要的日志内容 18. 客户端连接不上服务器的问题一般怎么定位?(未解决) 19. [多进程文件怎么共享,为什么要用mmap。](https://blog.csdn.net/tencupofkaiwater/article/details/88897529) 20. [vi打开文件后,怎么替换无数个想要替换的内容](https:/

mmap and memory usage

烂漫一生 提交于 2019-12-20 18:05:29
问题 I am writing a program that receives huge amounts of data (in pieces of different sizes) from the network, processes them and writes them to memory. Since some pieces of data can be very large, my current approach is limiting the buffer size used. If a piece is larger than the maximum buffer size, I write the data to a temporary file and later read the file in chunks for processing and permanent storage. I'm wondering if this can be improved. I've been reading about mmap for a while but I'm

mmap and memory usage

青春壹個敷衍的年華 提交于 2019-12-20 18:05:13
问题 I am writing a program that receives huge amounts of data (in pieces of different sizes) from the network, processes them and writes them to memory. Since some pieces of data can be very large, my current approach is limiting the buffer size used. If a piece is larger than the maximum buffer size, I write the data to a temporary file and later read the file in chunks for processing and permanent storage. I'm wondering if this can be improved. I've been reading about mmap for a while but I'm

vmsplice() and TCP

安稳与你 提交于 2019-12-20 11:31:16
问题 In the original vmsplice() implementation, it was suggested that if you had a user-land buffer 2x the maximum number of pages that could fit in a pipe, a successful vmsplice() on the second half of the buffer would guarantee that the kernel was done using the first half of the buffer. But that was not true after all, and particularly for TCP, the kernel pages would be kept until receiving ACK from the other side. Fixing this was left as future work, and thus for TCP, the kernel would still

How to use mmap to allocate a memory in heap?

て烟熏妆下的殇ゞ 提交于 2019-12-20 08:46:16
问题 Just the question stated, how can I use mmap() to allocate a memory in heap? This is my only option because malloc() is not a reentrant function. 回答1: Why do you need reentrancy? The only time it's needed is for calling a function from a signal handler; otherwise, thread-safety is just as good. Both malloc and mmap are thread-safe. Neither is async-signal-safe per POSIX. In practice, mmap probably works fine from a signal handler, but the whole idea of allocating memory from a signal handler

ENODEV error in MMAP

心已入冬 提交于 2019-12-20 07:43:53
问题 I'm trying to do a simple mapping of a new text file (given as a parameter) and I'm getting an ENODEV error in the mmap call. The fd is ok (no error in open call). According to the documentation this error means "The underlying file system of the specified file does not support memory mapping." or from another source I found that it can mean that fd is a file descriptor for a special file (one that might be used for mapping either I/O or device memory). I don't understand why any of these

Does mmap always return higher address

大兔子大兔子 提交于 2019-12-20 06:01:11
问题 Does mmap (when called with MAP_ANONYMOUS, that is, for allocating memory) always return higher memory address than a previous call? If not so, Is there any way to make it return a higher address always? 回答1: By default, mmap can return any address aligned on a page boundary, in any order. If you want to enforce that the returned address is the one you specify, you can use the MAP_FIXED flag, but that isn't very portable and reliable. This way you are tying your code with the particular

PHP script keeps doing mmap/munmap

瘦欲@ 提交于 2019-12-20 05:16:23
问题 My PHP script contains a loop, which does nothing much more than echoing and dereferencing pointers (like in $tab[$othertab[$i]]-> stuff). It was working great until yesterday, when this script starting being VERY slow (like 50 times slower than before). After using strace, i figured out that 90% of the time, the script does mmap/munmap. Here is a random portion of the strace log : mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap

strace和ltrace的简单使用

ぃ、小莉子 提交于 2019-12-20 04:05:59
目录 前言 1,strace命令 2,ltrace命令 3,总结 4,参考 前言 strace用来跟踪进程的系统调用或信号产生的情况; ltrace 用来跟踪进程调用库函数的情况。 1,strace命令 root@ubuntu:/opt/files/release/strace/x86_64/bin # ./strace uname execve ( "/bin/uname" , [ "uname" ] , 0x7ffc0cd82290 /* 20 vars */ ) = 0 brk ( NULL ) = 0x1ed4000 access ( "/etc/ld.so.nohwcap" , F_OK ) = -1 ENOENT ( No such file or directory ) access ( "/etc/ld.so.preload" , R_OK ) = 0 open ( "/etc/ld.so.preload" , O_RDONLY | O_CLOEXEC ) = 3 fstat ( 3, { st_mode = S_IFREG | 0644, st_size = 1, .. . } ) = 0 mmap ( NULL, 1, PROT_READ | PROT_WRITE, MAP_PRIVATE, 3, 0 ) = 0x7f4fcdb37000 close ( 3 )

What is the valid address space for a user process? (OS X and Linux)

∥☆過路亽.° 提交于 2019-12-20 01:07:29
问题 The mmap system call documentation says that the function will fail if: MAP_FIXED was specified and the addr argument was not page aligned, or part of the desired address space resides out of the valid address space for a user process. I can't find documentation anywhere saying what would be a valid address to map. (I'm interested in doing this on OS X and linux, ideally the same address would be valid for both...). 回答1: Linux kernel reserves part of virtual address space for itself to where