You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
721 B
28 lines
721 B
#include<linux/sched.h>
|
|
#include<asm/segment.h>
|
|
#include<all.h>
|
|
struct message msg_que[1024];
|
|
unsigned int msg_que_fron = NULL, msg_que_rear = NULL;
|
|
void post_message(int type){
|
|
if (msg_que_rear != msg_que_fron - 1) {
|
|
struct message msg;
|
|
msg.mid = type;
|
|
msg.pid = current->pid;
|
|
msg_que[msg_que_rear] = msg;
|
|
msg_que_rear = (msg_que_rear + 1) % 1024;
|
|
}
|
|
}
|
|
int sys_get_message(struct message *msg) {
|
|
struct message tmp;
|
|
if(msg_que_rear == msg_que_fron){
|
|
put_fs_long(-1,&msg->mid);
|
|
put_fs_long(-1,&msg->pid);
|
|
return;
|
|
}
|
|
|
|
tmp = msg_que[msg_que_fron];
|
|
msg_que[msg_que_fron].mid = 0;
|
|
msg_que_fron = (msg_que_fron + 1) % 1024;;
|
|
put_fs_long(tmp.mid,&msg->mid);
|
|
put_fs_long(current->pid,&msg->pid);
|
|
} |