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