Hi Pradeep....
I am using workqueues in my module.
Since work_struct or delayed_work can be context switch, they can
sleep and are safe.
Sleep, yes. But safe? You need to elaborate what kind of safety you
refer here...
So does this means i need to serialize my work handler function
between work events manually?
Well, if you need to protect some shared structures or variables, then
probably you need serialization. or perhaps you can construct a lock
free algorithm..
e.g
static void work_handler(struct work_struct *work)
{
/*Do something here*/
unsigned long delay = jiffies + 20;
INIT_DELAYED_WORK(&mydelayedwork, work_handler);
schedule_delayed_work(mydelaydwork, delay);
}
static int my_init(void)
{
/*do something*/
unsigned long delay = jiffies + 20;
INIT_DELAYED_WORK(&mydelayedwork, work_handler);
schedule_delayed_work(mydelaydwork, delay)
return 0;
}
What I don't know from the above snippet is, how the code flow looks
like? my_init() and then work_handler(), followed by work_handler
queuing itself to the work queue over and over again until certain
condition is met? If that is correct, IMHO you don't need any
serialization (even if you're on SMP).
regards,
Mulyadi.
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ