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:15:14 AM
comp.linux.development.system 5436 articles. 0 followers. zixenus (12) is leader. Post Follow

1 Replies
366 Views

Similar Articles

[PageSpeed] 36

Morphics wrote:
> Hi all
>=20
> 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 ?
>=20
> 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

There are no SIGUSR3 and SIGUSR4 signals.
See man 7 signal.
You could either use other, less frequently used, signals, e.g. SIGIOT,=20
SIGEMT, SIGSTKFLT, SIGPWR but not all of these may be present on your=20
architecture.
You could also provide a /proc interface for access to the state=20
variable and use a single signal only.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett

0
Josef
5/30/2006 6:51:26 AM
Reply: