codey-06
asked on
looping
Hi I am writing a kernel module.
I need a continuous loop that will look for tcp traffic and read from skb to store each source ip address from ip_hdr->saddr into an array
I can get it to read packets one at a time but I need it to loop, but when I try to implement a continuous loop the system crashes/hangs.
Can anyone offer any advice/possible fixes?
Cheers
I need a continuous loop that will look for tcp traffic and read from skb to store each source ip address from ip_hdr->saddr into an array
I can get it to read packets one at a time but I need it to loop, but when I try to implement a continuous loop the system crashes/hangs.
Can anyone offer any advice/possible fixes?
Cheers
ASKER
Hi yes you are correct, the loop is using up all the kernel resources. Is there a quick fix?
Have you tried some kind of sleep (I cannot remember the API call). This may give the OS and other processes time to run.
ASKER
Thank you. If anyone could offer a bit more help it would be very much appreciated?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, take a look at the functions:
set_current_state(TASK_INT ERRUPTIBLE );
schedule_timeout (signed long timeout);
See chapter 7 of the book link I provided.
set_current_state(TASK_INT
schedule_timeout (signed long timeout);
See chapter 7 of the book link I provided.
ASKER
Brilliant thank you
http://www.scs.ch/~frey/linux/kernelthreads.html
I think your problem might be that your loop is running and using all available kernel/process time. Thus, giving the result of maybe locking up your machine. Is that what is happening?