交个朋友 点这里
#lsof usage Show port listen
#show port 80
lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 14052 root 6u IPv4 303704 0t0 TCP *:http (LISTEN)
nginx 14053 nobody 6u IPv4 303704 0t0 TCP *:http (LISTEN)
#add
sudo update-alternatives --install /usr/bin/phpize phpize /home/jason/php/5.4.11/bin/phpize 1
#config
sudo update-alternatives --config phpize
#remove
sudo update-alternatives --remove phpize /usr/local/php/5.4.11/bin/php-phpize
https://github.com/torvalds/linux/blob/master/mm/mmap.c#L286
#include <stdio.h>
#include <unistd.h>
int main() {
int *base = sbrk(0);
brk(base + 1);//expand 4bytes(sizeof int) memory
printf("base.addr=%p\n", base);
printf("base+1.addr=%p\n", base + 1);
printf("After, brk(), current.addr=%p\n", sbrk(0));
*base = 1; #comment out brk, It will seg here.
*(base + 1) = 1;#Why It won't seg me here.
return 0;
}
#include <stdio.h>
#include <unistd.h>
int main() {
int *base = sbrk(0);
int pagesize = getpagesize();
brk(base + 1);//Here are page aligned!!!!!!!!
printf("pagesize=%d\n", pagesize);
printf("base.addr=%p\n", base);
printf("base+1.addr=%p\n", base + 1);
printf("After, brk(), current.addr=%p\n", sbrk(0));
*base = 1;
*(base + pagesize/sizeof(int) - 1) = 1;
printf("Next, please seg me!\n");
*(base + pagesize/sizeof(int)) = 1;
//sleep(10000); sleep a long time, I need to get
//the virtual address range of the heap of this program
//sudo cat /proc/PID/maps |grep heap
return 0;
}
sudo cat /proc/PID/maps |grep heap
#This command could get the virtual address of heap, result are the same
#with output of above progrma
#通过这个命令拿到堆的地址,和上面程序打印出来的地址完全一模一样
> dpkg -S /bin/ls
coreutils: /bin/ls
#So coreutils is the package that contains command ls.
Then goto this page Ubuntu – Ubuntu Packages Search, search it by using that keyword
然后到这个页面Ubuntu – Ubuntu Packages Search里用得到的关键字搜索
top's package download page: http://packages.ubuntu.com/trusty/procps ,On the right side!
top所在包的下载页面 http://packages.ubuntu.com/trusty/procps 右边有一个souce下载。是他是他就是他!
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 0 kB
Anonymous: 0 kB
AnonHugePages: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
Both Shared and Clean has two part of Clean and Dirty. But what does that respent? see stackexchange
Dirty 表示页是脏的, 即与磁盘后备文件的内容不一致, 需要(或正在)写回后备设备 Clean 表示页的内容和后备是一致的.
See fs/proc/task_mmu.c#show_smap See /mm/pagewalk.c#walk_page_range
For both difference of private and shared, dirty and clean : See private_dirty_modify
When talking about private and shared, that is simple, as code shows,
if (page_mapcount(page)>=2) {
//shared
} else {
//private
}