kernel/info.c
/*
* linux/kernel/info.c
*
* Copyright (C) 1992 Darren Senn
*/
/* This implements the sysinfo() system call */
#include <asm/segment.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/unistd.h>
#include <linux/types.h>
#include <linux/mm.h>
//系统信息
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;
//初始化变量val
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;
}
kernel/info.c的更多相关文章
- Linux 内核概述 - Linux Kernel
Linux 内核学习笔记整理. Unix unix 已有40历史,但计算机科学家仍认为其是现存操作系统中最大和最优秀的系统,它已成为一种传奇的存在,历经时间的考验却依然声名不坠. 1973 年,在用 ...
- 04.ubuntu下kvm 命令行安装64位ubuntu报"Couldn't find hvm kernel for Ubuntu tree."的问题
1.安装ubuntu时使用的virt-install的配置: virt-install \ --name test4 \ --ram 1024 \ --disk path=/data/01_ubunt ...
- 在 kernel 下打 log。 怪異現象與解決方式。
code battery_log(BAT_LOG_CRTI, "y t: %d \n", (int)my_timer_timeout); battery_log(BAT_LOG_C ...
- 机器学习——支持向量机(SVM)之核函数(kernel)
对于线性不可分的数据集,可以利用核函数(kernel)将数据转换成易于分类器理解的形式. 如下图,如果在x轴和y轴构成的坐标系中插入直线进行分类的话, 不能得到理想的结果,或许我们可以对圆中的数据进行 ...
- User space 与 Kernel space
学习 Linux 时,经常可以看到两个词:User space(用户空间)和 Kernel space(内核空间). 简单说,Kernel space 是 Linux 内核的运行空间,User spa ...
- kernel 4.4.12 外部模块Makefile 脚本编写
kernel 4.4.12 最简单module的编译 上一篇博客上面有一个最简单的模块源代码,今天就上一个Makefile,运行make 就可以编译一个外部的模块. vim Makefile 这个是我 ...
- kernel 4.4.12 EETI eGTouch 电容屏驱动移植
kernel 4.4.12 EETI eGTouch 电容屏驱动移植: 在make menuconfig 里面添加如下选项: 添加通过事件上报接口节点: Device Drivers ---> ...
- AM335x kernel 4.4.12 i2c eeprom AT24c02驱动移植
kernel 4.4.12 i2c eeprom AT24c02驱动移植 在kernel make menuconfig ARCH=ARM 中打开: Device Drivers ---> Mi ...
- Linux kernel make 常用选项介绍
Linux kernel 编译方法大全记录 一.这是一个我自己写的自动make脚本: #!/bin/sh export ARCH=arm export CROSS_COMPILE=arm-linux- ...
- Linux kernel 文件夹说明
Linux 内核代码的目录结构 arch: 包含和硬件体系相关的的代码,每种硬件平台占一个相应的目录,如i386,arm, arm64, powerpc,mips等. block: 块设备驱动程序I/ ...
随机推荐
- http——tinyhttp分析
1.前言: 1)tinyhttpd是一个500行+的http服务器 2)支持迭代和多线程并发两种服务器模型 3)支持GET和POST方法 4)支持CGI(fork.execl方式) 5)虽然响应的ht ...
- C学习
\a:警报 1.exit(),提前结束程序.include <stdlib.h> 2.getch()无缓存.getchar()有缓存,多条连用时注意末尾换行符否则始终.putchar(). ...
- Ftrl in tensorflow
reference :点击这里https://github.com/tensorflow/tensorflow/issues/3725 讲解 http://www.tuicool.com/articl ...
- Yii 多个子目录同步登录
---恢复内容开始--- 配置文件中: 1 'components'=>array( 'user'=>array( 'class'=>'CWebUser', 'identityCo ...
- 常用HTML标签元素结合及简介
常用HTML标签元素结合及简介 <html></html> 创建一个HTML文档<head></head> 设置文档标题和其它在网页中不显示的信息< ...
- Dojo的Gridx使用jsonrest需要注意的地方
在使用gridx时,如果要使用jsonrest,主要的工作主要是在服务端,服务端在返回数据时,必须在返回头里添加Content-Range: 0-9/73 属性和值,其中0表示从第0条记录开始,9表示 ...
- break into Ubuntu System
This morning, I got a spare machine from of of the labmates. The OS is ubuntu 12.04. I could not log ...
- JQuery中$.ajax()方法参数都有哪些?
url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 ...
- mysql配置文件编写
实例: 首先建立 mysql的配置文件 dbconfig.php <?php $phpexcel=array( "host"=>'localhost',//127.0. ...
- C#面向对象概念之继承
//经常讲到继承.重载,但还是有人概念比较模糊,因此想写个例子加深理解 interface ILog { void WriteLine(string message); } class LogBase ...