九:几点补充:
1: Slab中使用的页面都会加上“PG_slab”标志,以跟一般的页面区别。另外,在释放内存的时候,经常需要用到从页面到slab的对应转换关系。那是怎样标识的呢?
关于标志:
注意有以下代码:
static void *kmem_getpages(kmem_cache_t *cachep, int flags, int nodeid)
{
……
while (i--) {
//为分得的每一个页面设置PG_slab标志
SetPageSlab(page);
page++;
}
……
}
关于从页面到slab的转换:
向伙伴系统请求内存
static int cache_grow (kmem_cache_t * cachep, int flags)
{
……
//请求内存过后,设置内存属性
set_slab_attr(cachep, slabp, objp);
……
}
static void set_slab_attr(kmem_cache_t *cachep, struct ......
#include <stdio.h>
#include <unistd.h>
#define FOO "foo"
int main(void)
{
if(!access(FOO, F_OK))
{
if(!unlink(FOO))
{
}
else
{
printf("remove %s failed\n", FOO);
}
}
else
{
printf("%s not existed\n", FOO);
}
return 0;
} ......
#include <stdio.h>
#include <unistd.h>
#define FOO "foo"
int main(void)
{
if(!access(FOO, F_OK))
{
if(!unlink(FOO))
{
}
else
{
printf("remove %s failed\n", FOO);
}
}
else
{
printf("%s not existed\n", FOO);
}
return 0;
} ......
Linux 下面使用RPC需要使用到命令rpcgen.
在Linux下开发RPC程序流程如下:
1.写一个rpc程序,
如test.x
2.使用rpcgen生成必须的文件,通常是客户端和服务器端以及头文件
$rpcgen test.x
3.使用rpcgen生成服务器端和客户端的C语言代码
$rpcgen -Ss -o test_server.c test.x
$rpcgen -Sc -o test_client.c test.x
4.编辑源文件,加入你想要的服务等
5.使用gcc编译生成可执行文件
$gcc -Wall -o test_server test_server.c test_clnt.c test_srv.c
$gcc -Wall -o test_client test_clnt.c test_client.c
6.使用rpcgen生成Makefile
$rpcgen -Sm test.x>Makefile
7.执行测试
$./test_server
$./test_client 127.0.0.1
问题:
1.服务器无法启动,错误如下:
Cannot register serv ......
点评:安装软件包 rpm -i 包全名 删除 rpm -e name(不是包名) 参数 -ivh 获得一个详细的安装进程 --nodeps 忽略依赖关系 --force 强制安装 -U 包名:升级安装 -F 更新不管是什么直接覆盖 --replacepkgs这样 RPM 将忽略该错误信息 -vih --repla
内容来自: 脚本之家 www.jb51.net
安装软件包
rpm -i 包全名
删除
rpm -e name(不是包名)
参数
-ivh 获得一个详细的安装进程
--nodeps 忽略依赖关系
--force 强制安装
-U 包名:升级安装
-F 更新不管是什么直接覆盖
--replacepkgs这样 RPM 将忽略该错误信息 -vih --replacepkgs
-q name :查询
-qa查询所有已安装的RPM
-qi name 查询这个软件详细信息
-ql 显示列表
-qf path :查询一个文件属于哪个包
-qp 包名 :查文件是什么
-qpl 包名 :针对一个没装过的包
rpm -qc 配置文件
效验 rpm -Va
rpm -Vf /bin/ls
rpm -Vp 包名
5 -- MD5 校验和
S -- 文件长度
L -- 符号链接
T -- 文件修改日期
D -- 设备
U -- 用户
G -- 用户组
M -- 模式 (包含许可和文件类型)
? -- 不可读文件
  ......
一、要求:
1、能够显示出Makefile的总数
2、能显示一级目录下的Makefile总数、Makefile列表及其Makefile的内容
3、能将上述内容写入相应的文件
二、实例
rm -rf ~/Desktop/linux_Makefile/*
for i in `find . -maxdepth 1 -type d`
#仅仅是当前目录,所以请将本脚本放在linux源码目录下执行。
do
echo $i
mkdir -p ~/Desktop/linux_Makefile/$i
find $i -type f -name "Makefile" -print | echo -e ""$i" Total is:`wc -l`" >> ~/Desktop/linux_Makefile/total_Makefile_list_about.txt
#
Makefile的总数
find $i -type f -name "Makefile" -print | echo -e "\n"$i"'s Makefile Total number is:`wc -l`\n" > ~/Desktop/linux_Makefile/$i/"$i"_Makefile_list.txt
find $i -type f -name "Makefile" -print >> ~/Desktop/linux_Makefile/$i/"$i"_Makefile_list.txt
find $i -type f -name "Makefile" -printf "\n# ============================================================ ......
/*
kmalloc can apply 128KB memory only. This func support any continous memory allocate more than 2MB.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kallsyms.h>
#define KMEM_PAGES //apply more than one page
#define KMEM_DEBUG //debug message switch
/*
// Pure 2^n version of get_order
static __inline__ __attribute_const__ int get_order(unsigned long size)
{
int order;
size = (size - 1) >> (PAGE_SHIFT - 1);
order = -1;
do {
size >>= 1;
order++;
} while (size);
return order;
}
*/
/*
alloc memory for DMA using in kernel space.
*/
void *kmem_alloc(size_t size, dma_addr_t *dma_handle, unsigned long flags)
{
& ......