The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Chinmaya Mishra <chinmaya4@gmail.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Enabling message queue in 2.6.10 kernel
Date: Fri, 07 Jul 2006 15:33:52 +0530	[thread overview]
Message-ID: <44AE3188.6000304@innomedia.soft.net> (raw)

Hi All,
I am trying for message queue in linux-2.6.10 kernel.
I export sys_msgget(), sys_msgctl(), sys_msgsnd() and sys_msgrcv() in
the kernel with following EXPORT_SYMBOL(sys_msgget) and so on.
Then compile the kernel, boot with the new image.

My code is like this.
#include <linux/module.h>
#include <linux/kernel.h>

#include <linux/types.h>
#include <linux/ipc.h>
#include <linux/msg.h>
#include <linux/syscalls.h>

#include <asm/system.h>

int msqid, ret;
/* this is the thread function that we are executing */
void mymsgSend(void)
{
        struct msgbuf sbuf;
        printk("Start send message \n");
        memset(&sbuf, '\0', sizeof(sbuf));
        if((msqid = sys_msgget((key_t)1234, 0666 | IPC_CREAT )) < 0) {
                printk("Err: sys_msgget \n");
                return ;
        }
        sbuf.mtype = 1;
        //sprintf(sbuf.mtext,"a");
        ret = sys_msgsnd(msqid, &sbuf, sizeof(sbuf), IPC_NOWAIT);
        printk("Send ret = %d \n", ret);
        if (ret < 0) {
                printk("Err: sys_msgsnd \n");
                return ;
        }
        return ;
}

void mymsgRecv(void)
{
        int msqid;
        struct msgbuf rbuf;
        printk("Start recv message  \n");
        memset(&rbuf, '\0', sizeof(rbuf));
        if ((msqid = sys_msgget((key_t)1234, 0666)) < 0) {
                printk("Err: sys_msgget \n");
                return ;
        }
        rbuf.mtype = 1;
        ret = sys_msgrcv(msqid, (struct msgbuf *)&rbuf, sizeof(rbuf), 
rbuf.mtype, IPC_NOWAIT);
        printk("Recv ret = %d \n", ret);
        if (ret < 0) {
                printk("Err: sys_msgrcv \n");
                return ;
        }
        printk("Mesg Recv = %s \n", rbuf.mtext);
        return;
}

/* load the module */
int init_module(void)
{
              mymsgSend();
              msleep(1000);
              mymsgRecv();
        }
        return(0);
}

/* remove the module */
void cleanup_module(void)
{
        printk("Stop Kernel Thread \n");
        sys_msgctl(msqid, IPC_RMID, NULL);
        return;
}


But the out put messages in # dmesg <enter> is like this

Start send message
Send ret = -14
Err: sys_msgsnd
Start recv message
Recv ret = -42
Err: sys_msgrcv
Stop Kernel Thread

Is there any thing I am missing. Please help soon.


With Regards,
Chinmaya.

             reply	other threads:[~2006-07-07  9:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-07 10:03 Chinmaya Mishra [this message]
2006-07-07 10:08 ` Enabling message queue in 2.6.10 kernel Arjan van de Ven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44AE3188.6000304@innomedia.soft.net \
    --to=chinmaya4@gmail.com \
    --cc=chinmaya@innomedia.soft.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox