How to write a loadable module to handle socket communication
- From: "Joe Zhou" <zhouyonghao@xxxxxxxxx>
- Date: 4 May 2006 01:27:02 -0700
I'm puzzled about how to time the thread's working in kernel
modules.I'm writing a module to improve the lvs(linux virtual serve)
about the load balacncing algorithm using udp socket to get real node's
load info .So I need to send the load info on time repeatly, e.g. once
per 5 secs.I use the schedule_timeout(time_interval) to make the
sending code work on time , yet it doesn't work as expected.Between
once invoking of schedule_timeout(time_interval) the load info is sent
for nearly 20 times.Anyone can give some advise about how to time the
function to work?Any advice is appreciated , thank U all in advance:)
My code is as blow
/* loop to send the load msg to the load-balancer */
while(1){
set_current_state(TASK_UNINTERRUPTIBLE) ;
// send_load() is the func to send load info
just for once, so call it repeatly in the while loop , this func is
called until the module is cleaned up when it runs to the init_module()
if( (ret = send_load(sock , (struct sockaddr*)&servaddr ,
addrlen)) < ERR_BASE)
break ; //function is interrupted , it happens when this module is
cleanup
// make sure it will wait until 5secs eclasps to 0
schedule_timeout(ret) ;
}
.
- Follow-Ups:
- Prev by Date: Re: algorithm for interrupt priority levels
- Next by Date: How to time the kernel thread to work on time repeatly
- Previous by thread: 35,000 linux man pages online
- Next by thread: Re: How to write a loadable module to handle socket communication
- Index(es):
Relevant Pages
|