同步机制 求帮助!1!
我想请教一下 2.2内核中的等待队列 struct wait_queue 和 2.6.9里面的定义是一样的么?如果不一样, 那2.6里的应该怎么定义和用
我这里有份代码, 是可以在2.2下编译通过, 那如果加在2.6.9的内核中,应该怎么去改??? 急, 真的很急!!
#include <linux/kernel.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/unistd.h>
#include <linux/slab.h>
#include <asm/system.h>
#define TRUE 1
#define FALSE 0
#define MAX_NAME_LEN 64
#define MAX_EVENTS 32
struct Event {
int ownerPid;
struct wait_queue *queue;
int numBlocked;
int usageCount;
};
static struct Event eventArray; /* The event array */
asmlinkage int sys_getevntnum(char *name) {
/* dummy */
return 0;
}
/* Initialize the event array */
void __init evnt_init(void) {
int i;
for(i = 0; i<MAX_EVENTS; i++) {
eventArray.ownerPid = -1;
eventArray.queue = NULL;
eventArray.numBlocked = 0;
eventArray.usageCount = 0;
}
}
/* Open an event for shared use */
asmlinkage int sys_evntopen(int eventNum)
{
int i;
if(eventNum == 0) {
/* Look for an available slot */
for(i=0; i < MAX_EVENTS; i++) {
if (eventArray.ownerPid == -1) {
eventArray.ownerPid = current->pid;
eventArray.usageCount = 1;
return i;
}
}
return -1; /* No events available */
}
eventArray.usageCount++;
return eventNum;
}
/* Deallocate this event */
asmlinkage int sys_evntclose(int eventNum) {
struct wait_queue *qEntry;
/* Could validate owner(s), but this version does not do so */
/* Release blocked processes */
qEntry = eventArray.queue;
while(eventArray.numBlocked > 0) {
qEntry->task->state = TASK_RUNNING;
remove_wait_queue(
&(eventArray.queue), qEntry);
qEntry = qEntry->next;
eventArray.numBlocked--;
}
eventArray.ownerPid = -1;
eventArray.queue = NULL;
eventArray.usageCount = 0;
return 0;
}
asmlinkage int sys_evntwait(int eventNum) {
struct wait_queue **queue;[code]
/* Add current task to the blocked process list */
queue = &(eventArray.queue);
sleep_on(queue);
return 0;
}
asmlinkage int sys_evntsig(int eventNum) {
struct wait_queue **queue;
queue = &(eventArray.queue);
wake_up(queue);
return 0;
}[/code]
我修改一些实现系统调用的必要东西之后, 用这几个空函数可以实现这些新的系统调用(这些代码是一个event.c文件 放在linux-2.6.9/arch/i386/kernel 中编译)
应该怎么样该这些代码才能在2.6.9中编译通过???(编译内核到这个文件的时候, 显示remove_wait_queue , sleep_on, wake_up 的参数错误, 我应该怎么改????????
谢谢先
页:
[1]