I am using workqueues in my module. Since work_struct or delayed_work can be context switch, they can sleep and are safe.
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..So does this means i need to serialize my work handler function between work events manually?
e.gWhat 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).
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; }
-- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ