f



sending user defined signals from kernel space to user space

Hi all

The linux version we are using is 2.4.We have requirement of running a
state machine in kernel space .There are four states in the state
machine namely. STATE_1,STATE_2, STATE_3 and STATE_4. We have
requirement of sending four asynchronous notifications from kernel
space to user space for each state change in the state machine. I am
able to send two signals namely SIGUSR1 and SIGUSR2 from  kernel space
to user space  for states STATE_1 and STATE_2 respectively. Can any one
help me how can I send two more user defined signals from kernel space
to user space for STATE_3 and STATE_4 ?

I am using kill_proc to asynchronously send user defined signals from
kernel space to  user space., but i am not able to send SIGUSR4 and
SIGUSR3
-----------------------------------------------------------------------------------------------------------
kernel space code snippet
-----------------------------------------------------------------------------------------------------------

#define SIGUSR3  ( SIGRTMIN +4)
#define SIGUSR4  ( SIGRTMIN +5)



      retVal = kill_proc(pid_test_driver,SIGUSR1,1);
      if(retVal< 0)
      {
            printk("unable to send signal SIGUSR1 to User  \n");
            retVal = 0;
      }
      else
            printk("success in sending SIGUSR1 to User \n");


      retVal = kill_proc(pid_test_driver,SIGUSR2,1);

      if(retVal< 0)
      {
            printk("unable to send signal SIGUSR2 to User \n");
            retVal = 0;
      }
      else
            printk("success in sending SIGUSR2 to User \n");

      retVal = kill_proc(pid_test_driver,SIGUSR3,1);

      if(retVal< 0)
      {
            printk("unable to send signal SIGUSR3 to User \n");
            retVal = 0;
      }
      else
            printk("success in sending SIGUSR3 to User \n");

      retVal = kill_proc(pid_test_driver,SIGUSR4,1);

      if(retVal< 0)
      {
            printk("unable to send signal SIGUSR4 to User \n");
            retVal = 0;
      }
      else
            printk("success in sending SIGUSR4 to User \n");


-----------------------------------------------------------------------------------------------------------
User space code snippet
-----------------------------------------------------------------------------------------------------------
#define SIGUSR3  ( SIGRTMIN +4)
#define SIGUSR4  ( SIGRTMIN +5)


   retVal = sigaction(SIGUSR1, &action, NULL);
     if(retVal < 0)
     {
       errorVal = errno;
       printf("\n error in setting SIGUSR1 %d \n",errorVal);
       exit(1);
     }
     else
       printf("\n success in registering  SIGUSR1  %d \n",errorVal);


     retVal = sigaction(SIGUSR2, &action2, NULL);
     if(retVal < 0)
     {
       errorVal = errno;
       printf("\n error in setting SIGUSR2 %d \n",errorVal);
       exit(1);
     }
     else
       printf("\n success in registering  SIGUSR2  %d \n",errorVal);


  retVal = sigaction(SIGUSR3, &action2, NULL);
     if(retVal < 0)
     {
       errorVal = errno;
       printf("\n error in setting SIGUSR3 %d \n",errorVal);
       exit(1);
     }
     else
       printf("\n success in registering  SIGUSR3  %d \n",errorVal);



  retVal = sigaction(SIGUSR4, &action2, NULL);
     if(retVal < 0)
     {
       errorVal = errno;
       printf("\n error in setting SIGUSR4 %d \n",errorVal);
       exit(1);
     }
     else
       printf("\n success in registering  SIGUSR4  %d \n",errorVal);


     retVal = fcntl(handle, F_SETOWN, getpid());
     if(retVal < 0)
     {
        printf("\n error in setting owner  \n");
        exit(1);
     }
     else
        printf("\n success in setting owner  \n");

     old_val = fcntl(handle, F_GETFL) ;

     if(old_val < 0)
     {
        printf("\n error in getting the file flags \n");
        exit(1);
     }
     else
        printf("\n success in getting the file flags  \n");

     retVal = fcntl(handle, F_SETFL, old_val | FASYNC);

     if(retVal < 0)
     {
        printf("\n error in enabling asynchronous notification \n");
        exit(1);

     }
     else
        printf("\n success in enabling asynchronous notification  \n");

-----------------------------------------------------------------------------------------------------------

The O/P I get "Real-time signal 3" in user space and

Can anyone help me how to send more signals SIGUSR3 and SIGUSR4 from
kernel space to user space?


Regards
Morphics

0
Morphics
5/30/2006 5:00:14 AM
comp.os.linux.development.apps 5216 articles. 1 followers. Post Follow

2 Replies
685 Views

Similar Articles

[PageSpeed] 59

Morphics wrote:
> Hi all
> 
> The linux version we are using is 2.4.We have requirement of running a
> state machine in kernel space .There are four states in the state
> machine namely. STATE_1,STATE_2, STATE_3 and STATE_4. We have
> requirement of sending four asynchronous notifications from kernel
> space to user space for each state change in the state machine. I am
> able to send two signals namely SIGUSR1 and SIGUSR2 from  kernel space
> to user space  for states STATE_1 and STATE_2 respectively. Can any one
> help me how can I send two more user defined signals from kernel space
> to user space for STATE_3 and STATE_4 ?
> 
> I am using kill_proc to asynchronously send user defined signals from
> kernel space to  user space., but i am not able to send SIGUSR4 and
> SIGUSR3

Your original post is kind of unfinished, but I'll try answering anyway.

SIGRTMIN and SIGRTMAX do not have the same values in the kernel and in
userspace. Maybe that's your problem.

In the kernel, SIGRTMIN is 32 for all platforms except PARISC (where it
is 37) and SIGRTMAX is highly variable.

In the libc on my system (i386), SIGRTMIN is defined as 34 and SIGRTMAX
as 64. I don't know whether this varies across platforms.

In libc there's also __SIGRTMIN (32 on my system, like in the kernel)
and __SIGRTMAX (64).


Values in the kernel:

http://lxr.linux.no/ident?i=SIGRTMIN
http://lxr.linux.no/ident?i=SIGRTMAX

Values in libc:

#include <stdio.h>
#include <signal.h>

int main() {
    printf("SIGRTMIN = %i\n", SIGRTMIN);
    printf("SIGRTMAX = %i\n", SIGRTMAX);

    printf("__SIGRTMIN = %i\n", __SIGRTMIN);
    printf("__SIGRTMAX = %i\n", __SIGRTMAX);
}


Greetings,
Aaron
0
Aaron
6/4/2006 12:15:17 AM
Thanks a lot Aaron ,

It worked , i didn' there is such a difference between user space and
kernel space wrt signals

Morphics

Aaron Isotton wrote:
> Morphics wrote:
> > Hi all
> >
> > The linux version we are using is 2.4.We have requirement of running a
> > state machine in kernel space .There are four states in the state
> > machine namely. STATE_1,STATE_2, STATE_3 and STATE_4. We have
> > requirement of sending four asynchronous notifications from kernel
> > space to user space for each state change in the state machine. I am
> > able to send two signals namely SIGUSR1 and SIGUSR2 from  kernel space
> > to user space  for states STATE_1 and STATE_2 respectively. Can any one
> > help me how can I send two more user defined signals from kernel space
> > to user space for STATE_3 and STATE_4 ?
> >
> > I am using kill_proc to asynchronously send user defined signals from
> > kernel space to  user space., but i am not able to send SIGUSR4 and
> > SIGUSR3
>
> Your original post is kind of unfinished, but I'll try answering anyway.
>
> SIGRTMIN and SIGRTMAX do not have the same values in the kernel and in
> userspace. Maybe that's your problem.
>
> In the kernel, SIGRTMIN is 32 for all platforms except PARISC (where it
> is 37) and SIGRTMAX is highly variable.
>
> In the libc on my system (i386), SIGRTMIN is defined as 34 and SIGRTMAX
> as 64. I don't know whether this varies across platforms.
>
> In libc there's also __SIGRTMIN (32 on my system, like in the kernel)
> and __SIGRTMAX (64).
>
>
> Values in the kernel:
>
> http://lxr.linux.no/ident?i=SIGRTMIN
> http://lxr.linux.no/ident?i=SIGRTMAX
>
> Values in libc:
>
> #include <stdio.h>
> #include <signal.h>
>
> int main() {
>     printf("SIGRTMIN = %i\n", SIGRTMIN);
>     printf("SIGRTMAX = %i\n", SIGRTMAX);
>
>     printf("__SIGRTMIN = %i\n", __SIGRTMIN);
>     printf("__SIGRTMAX = %i\n", __SIGRTMAX);
> }
> 
> 
> Greetings,
> Aaron

0
Morphics
6/6/2006 3:42:33 AM
Reply: