Nice approach....
Some general comments are
-The while loop can be in an ioctl rather than in the init_module. So that you
can do repeated testing.
-The condition (jiffies != num) can be dangerous, especially in a preemptible
kernel, it should be (jiffies < num) otherwise there is a danger of going into
an infinite loop.
-If init_module returns -1, I don't think it would be successfully loaded. Done
intentionally ?
If the above were a result of a quickly written module then please ignore the
comments.
Gopu.
-----Original Message-----
From: Sangharsha p g
Sent: Tuesday, August 17, 2004 2:20 PM
To: Gopu Bhaskar (WT01 - EMBEDDED & PRODUCT ENGINEERING SOLUTIONS)
Cc: ilugc@xxxxxxxxxxxxx
Subject: Re: [Ilugc] RE:Kernel 2.6
?
Thanks a lot for the reply, I will do that, I have given small kernel module
which I feel this is the way of testing preemptiveness of the kernel.The below
shown module I am using
#define __KERNEL__
#define MODULE
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/sched.h>
static int init_module(void)
{
unsigned long num=jiffies+(10*HZ);
while(jiffies!=num) {
? //schedule(); /* uncomment this line to relinquish the CPU*/
? ? ? ? }
return -1;
}
static void cleanup_module(void)
{
? ? ? ? printk("module unloaded\n");
}
When you try to load the above module since it is a non-preemptible kernel, it
will in that loop for 10 secs(since it is jiffies+(10*HZ)).So during that U try
type some thing OR try to move the mouse since it is non-premtible kernel you
can't do anything.If it is a pr-emtible it will allow you to do so(This is what
my way of testing if any comments OR better way of testing pls let me know).
Regards,
Sangharsh
Confidentiality Notice
The information contained in this electronic message and any attachments to
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
Mailadmin@xxxxxxxxx immediately
and destroy all copies of this message and any attachments.