The code to get the size of kernel stack

2009-05-13 04:13:30来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

Compiled, kldload and kldunload it. Note, kernel will panic while kldunload the module.

#include
#include
#include
#include
#include
#include  /* for net/if.h */
#include  /* string functions */
#include
#include
#define XX_SIZE 1024
static int
test_stack(int i)
{
char buf[XX_SIZE];

buf[0] = 0x0;
buf[XX_SIZE - 1] = 0x0;

printf("level %d\n", i);
test_stack(i + 1);
return 0;
}
static int
xxs_modevent(module_t mod, int type, void *unused)
{
switch (type) {
  case MOD_LOAD:
   break;
  case MOD_UNLOAD:
   test_stack(1);
   break;
  default:
   return EINVAL;
}
return 0;
}
static moduledata_t xxs_mod = {
"xxs",
xxs_modevent,
0
};
DECLARE_MODULE(xxs, xxs_mod, SI_SUB_PSEUDO,SI_ORDER_ANY);
MODULE_VERSION(xxs, 1);
Tip: Modify KSTACK_PAGES to resize the kernel stack

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/132/showart_152458.html

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:OpenVPN在Linux下的安装配置和使用

下一篇:QEMU --- 一个快速的 CPU 仿真器