Message passing to kernel - Minix

This is a discussion on Message passing to kernel - Minix ; i want to add a system call(successfuly added) and pass the message(which contains int and a string) /*code i used my program calling system call printmsg*/ message mm; mm.m1_i1=10; mm.m1_p1="hello"; printmsg(&mm); /*user library*/ printmsg(*m1) { printf("integer is:%d",m1->m1_i1); /*getting correct output ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Message passing to kernel

  1. Message passing to kernel

    i want to add a system call(successfuly added) and pass the
    message(which contains int and a string)

    /*code i used my program calling system call printmsg*/

    message mm;
    mm.m1_i1=10;
    mm.m1_p1="hello";
    printmsg(&mm);

    /*user library*/

    printmsg(*m1)
    {
    printf("integer is:%d",m1->m1_i1); /*getting correct output as
    10*/
    printf("str:%s",%s",m_in->m1_p1); /*getting output as hello*/
    return(_syscall(FS,PRINTMSG,m1));
    }


    /* my system call code in misc.c */

    int printmsg()
    {
    printf("integer is:%d",m_in.m1_i1); /*getting correct output as
    10*/
    printf("str:%s",%s",m_in.m1_p1); /*getting str: all_nr=%d slot1=
    %d */
    return ok;
    }

    m_in which is a global varaible..m1 will be assigned to m_in once
    syscall is made. correct me if am wrong.

    i could not able to pass the string to system call(kernel). am getting
    something like "str: all_nr=%d slot1=%d " but the integer values is am
    getting.At the same time i print in user library am getting correct
    output for both. i have sent lot of times to debug.. can onyone help
    me out..

  2. Re: Message passing to kernel

    > m_in which is a global varaible..m1 will be assigned to m_in once
    > syscall is made. correct me if am wrong.
    >
    > i could not able to pass the string to system call(kernel). am getting
    > something like "str: all_nr=%d slot1=%d " but the integer values is am
    > getting.At the same time i print in user library am getting correct
    > output for both. i have sent lot of times to debug.. can onyone help
    > me out..


    Your user process, the servers (pm, fs, ...), and the kernel all live
    in different address spaces. A valid pointer in one context typically
    points to random junk in another.

    To do something like this, you have to copy the string to the address
    space of the server first. To find out how to do this, take a look at
    those function calls taking string arguments that are already there.
    One good example would be the exec system call in pm.

    --
    With kind regards,
    Erik van der Kouwe

+ Reply to Thread