linux进程相关系统文件 共享内存管理

2015-11-02 22:46:00
admin
原创 4910
摘要:linux进程相关系统文件 共享内存管理

一、linux系统常用文件

/proc/sys/kernel/pid_max:进程ID最大值,默认32768;

/proc/sys/kernel/threads-max:系统最大线程数,默认29732;

/proc/pid/environ:进程所有环境变量;

/proc/pid/fd:进程所有打开的fd,包括文件、设备、socket、pipe;

/proc/pid/task/tid:进程所有线程信息,主线程pidtid一样;

/var/log/messages:系统日志文件,比如段错误;

/var/log/dmesg:硬件启动日志;


/proc/net/tcp:

1、记录所有IPV4连接信息,netstat基于该文件实现;

2、文件内容都是16进制,80端口对应值是0050;

3、local_address本地地址,rem_address远程地址、st连接状态、inode文件描述符;

4、状态码:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/net/tcp_states.h


二、共享内存管理

系统共享内存配置:

1、shmmax,单块共享内存最大值;

2、shmmin,单块共享内存最小值;

3、shmseg,单个进程最多可以使用多少块共享内存;

4、shmmni,所有进程最多可以使用多少块共享内存;

5、shmall,系统总共可以分配多少共享内存,单位为页;

6、查看共享内存参数/proc/sys/kernel/varname;


ipcs - provide information on ipc facilities

1、-m shared memory segments
2、-q  message queues
3、-s semaphore arrays
4、-a all (this is the default)

5、查询共享内存:ipcs -m


ipcrm [ -M key | -m id | -Q key | -q id | -S key | -s id ]

1、-m shmid:removes the shared memory segment identified by shmid after the last detach is performed.

2、-q msgid:removes the message queue identified by msgid.

3、-s semid:removes the semaphore identified by semid.

4、删除共享内存:ipcrm -m shmid

发表评论
评论通过审核之后才会显示。