linux 1.0 内核注解 linux/kernel/info.c
时间:2009-03-08 来源:taozhijiangscu
/********************************************
*Created By: 陶治江
*Date: 2009-3-6
********************************************/
#include <asm/segment.h> #include <linux/sched.h>
#include <linux/string.h>
#include <linux/unistd.h>
#include <linux/types.h>
#include <linux/mm.h> // struct sysinfo {
// long uptime; /* Seconds since boot */
// unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
// unsigned long totalram; /* Total usable main memory size */
// unsigned long freeram; /* Available memory size */
// unsigned long sharedram; /* Amount of shared memory */
// unsigned long bufferram; /* Memory used by buffers */
// unsigned long totalswap; /* Total swap space size */
// unsigned long freeswap; /* swap space still available */
// unsigned short procs; /* Number of current processes */
// char _f[22]; /* Pads structure to 64 bytes */
//};
asmlinkage int sys_sysinfo(struct sysinfo *info)
{
int error;
struct sysinfo val;
struct task_struct **p; error = verify_area(VERIFY_WRITE, info, sizeof(struct sysinfo));
if (error)
return error;
memset((char *)&val, 0, sizeof(struct sysinfo)); val.uptime = jiffies / HZ; //系统启动秒数 val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT); for (p = &LAST_TASK; p > &FIRST_TASK; p--)
if (*p) val.procs++; //当前进程数 //一看就是内存管理了 :-(
si_meminfo(&val);
si_swapinfo(&val); memcpy_tofs(info, &val, sizeof(struct sysinfo));
return 0;
}
文档地址:http://blogimg.chinaunix.net/blog/upfile2/090308130027.pdf
*Created By: 陶治江
*Date: 2009-3-6
********************************************/
#include <asm/segment.h> #include <linux/sched.h>
#include <linux/string.h>
#include <linux/unistd.h>
#include <linux/types.h>
#include <linux/mm.h> // struct sysinfo {
// long uptime; /* Seconds since boot */
// unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
// unsigned long totalram; /* Total usable main memory size */
// unsigned long freeram; /* Available memory size */
// unsigned long sharedram; /* Amount of shared memory */
// unsigned long bufferram; /* Memory used by buffers */
// unsigned long totalswap; /* Total swap space size */
// unsigned long freeswap; /* swap space still available */
// unsigned short procs; /* Number of current processes */
// char _f[22]; /* Pads structure to 64 bytes */
//};
asmlinkage int sys_sysinfo(struct sysinfo *info)
{
int error;
struct sysinfo val;
struct task_struct **p; error = verify_area(VERIFY_WRITE, info, sizeof(struct sysinfo));
if (error)
return error;
memset((char *)&val, 0, sizeof(struct sysinfo)); val.uptime = jiffies / HZ; //系统启动秒数 val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT); for (p = &LAST_TASK; p > &FIRST_TASK; p--)
if (*p) val.procs++; //当前进程数 //一看就是内存管理了 :-(
si_meminfo(&val);
si_swapinfo(&val); memcpy_tofs(info, &val, sizeof(struct sysinfo));
return 0;
}
文档地址:http://blogimg.chinaunix.net/blog/upfile2/090308130027.pdf
相关阅读 更多 +
排行榜 更多 +