Results 1 to 2 of 2
I am trying to implement a system call in linux that performs a specifc functionality after some seconds have elapsed. For this pupose i use sys_alarm() in my system call ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-07-2011 #1Just Joined!
- Join Date
- Oct 2011
- Posts
- 1
Handling alarm signal in system call implementation
I am trying to implement a system call in linux that performs a specifc functionality after some seconds have elapsed. For this pupose i use sys_alarm() in my system call and pass to it the number of seconds i want the process to wait. When the alarm goes off i call a handler function that is registered using sys_signal(). The problem is that whenever i invoke the system call through a user program, the user program gets stuck...Could you please go through the code and check what is missing ?
#include <linux/linkage.h> //for linking a system call
#include <linux/kernel.h>
#include<linux/reboot.h>
#include<linux/sched.h>
#include<linux/time.h>
#include<linux/signal.h>
#include<linux/unistd.h>
#include<linux/syscalls.h>
volatile int keep_going = 1;
void alarm_handler(int signal)
{
keep_going = 0;
}
asmlinkage long sys_myservice(int arg) {
int delay=20;
sys_signal(SIGALRM, alarm_handler);
sys_alarm(20);
while (keep_going){
//do nothing
}
//write functionality here
return 1;
}
- 10-10-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,160
What do you mean by "whenever i invoke the system call through a user program"? Are you trying to invoke the call directly? Have you written and installed a kernel module to handle the call from the user?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
