Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

jagne kvrj, ngochan1126@hotmail.­com, a asdfghjhhjjkl', cvezrtg, chink chinese frankies, lambhead@rocketmail.com, priwalfdept77@yahoo.de, from scipy.optimize import minpack2 ImportError: DLL load failed: 找不到指定的模块。, yamlå, adfghjshjklç

Links

XODOX
Impressum

#1: 帮看下我的kernel module为什么会挂呢

Posted on 2012-08-23 03:42:28 by 得做大侠

#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysproto.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/kthread.h>
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/mutex.h>


void* p = 0;
int flag = 0;
struct proc *newpp = NULL;
struct thread *newthr = NULL;
struct mtx g_mtx;
int thrd1 = 1;
int thrd2 = 2;

struct task_args
{
int id;
};

static void thread_fun(void* arg)
{
while(1){
mtx_lock(&g_mtx);
tsleep(&p, 0, "nomessage", 50);
printf("in thread %d\n", *(int*)arg);
mtx_unlock(&g_mtx);
tsleep(&p, 0, "nomessage", 50);
if(flag == 3){
kthread_exit();
}
}
}
/*
* The function for implementing the syscall.
*/

static int
task_ops (struct thread *td, struct task_args *arg)
{
int result = 0;
printf("task id:%d\n", arg->id);
switch(arg->id){
case 1:
/*create thread 1*/
result = kthread_add(thread_fun, &thrd1, NULL, NULL, 0, 0,
"thread1");
if(result != 0){
printf("create thread failed\n");
}else{
printf("new thread1 created\n");

}
break;
case 2:
/*create thread 2*/
result = kthread_add(thread_fun, &thrd2, NULL, NULL, 0, 0,
"thread2");
if(result != 0){
printf("create thread failed\n");
}else{
printf("new thread2 created\n");
}
break;
case 3:
/*stop the thread*/
flag = 3;
break;
default:
break;
}
return 0;
}

/*
* The `sysent' for the new syscall
*/

static struct sysent my_sysent[2] = {
{
1, /* sy_narg */
(void*)task_ops /* sy_call */
},
};

/*
* The offset in sysent where the syscall is allocated.
*/
#if 0
static int offset[] = {NO_SYSCALL,NO_SYSCALL};
#endif
static int offset[] = {212};

char module_name[]= "task module";
/*
* The function called at load/unload.
*/

static int
load (struct module *module, int cmd, void *arg)
{
int error = 0;
switch (cmd) {
case MOD_LOAD :
printf ("module loaded\n");
mtx_init(&g_mtx, "testmutex", NULL, MTX_DEF);
break;
case MOD_UNLOAD :
printf ("module unloaded\n");
break;
default :
error = EOPNOTSUPP;
break;
}
return error;
}

SYSCALL_MODULE(mymodule, &offset[0], &my_sysent[0], load,
(void*)module_name);

系统调用的形式对放开放
./call 1 执行没有问题
./call 2 后系统就挂了
堆栈如下图
http://hiphotos.baidu.com/abonege/pic/item/f942ab4bd11373f04953ac04a40f4bfbf
bed043a.jpg
--

※ 来源:・水木社区 http://newsmth.net・

Report this message

#2: Re: NAS4Free和FreeNAS是什么关系?

Posted on 2012-08-23 04:15:53 by

刚找到S1200KPR,发现您twitter上已经yy过了,在国内跟大神的步伐真是累。。。

【 在 delphij (许可证超出一页纸,非*即盗!) 的大作中提到: 】
: 可以,但是 dedup 之类的就不要想了。另外我怀疑(没证据)Atom对4GB内存的支持
: 也有点问题,我自己的 Atom 系统如果内存占的很满的话,ZFS会出现写入数据损坏
: 的问题。
: ...................

--

※ 来源:・水木社区

Report this message