Re: spinlocks and kernel timer !!!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/22/06, Bennett, Robert P <Robert.Bennett@xxxxxx> wrote:
>
> > -----Original Message-----
> > From: kernelnewbies-bounce@xxxxxxxxxxxx
> > [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of pradeep singh
> > Sent: Wednesday, March 22, 2006 9:59 AM
> > To: kernel-issues
> > Subject: spinlocks and kernel timer !!!
> >
> >
> > Hi
> >
> > static void some_method()
> > {
> >       unsigned long expires;
> >       static struct timer_list *timer;
> >       expires = jiffes + 20;
> >       data = 5;
> >       timer->expires = expires;
> >       timer->function = my_function;
> >       timer->data = data;
> >       init_timer(timer);   /*initalise timer*/
> >       spin_lock_irqsave(&spinlock, iflags);
> >       spin_unlock_irqrestore(&spinlock, iflags);
> >
> >       return 0;
> > }
> >
> > static int __init mod_init( void )
> > {
> >       printk(KERN_DEBUG "in init..\n");
> >       some_method();
> >       printk(KERN_DEBUG "after some method in init..\n");
> >
> >       return 0;
> > };
> >
> > static void __exit mod_exit( void )
> > {
> >       printk(KERN_DEBUG "bye world...\n");
> >
> > }
> >
> > My question is between spin_lock_irqsave() and
> > spin_unlock_irqrestore() code is supposed to be atomic right?
> > Now as i have initialised a timer structure in the
> > function.If the jiffies gets equal to expires in between
> > spinlock() and spinunlock() will my_function() execute?
> >
> > What will happen and why?
>
>         You will OOPS as soon as you dereference "timer", since you did
> not initialize it.

does this means init_timer( timer ) will not initialise the timer ?

I think LDD3 says about init_timer(timer) to initialise the timer :),
where am i getting this all wrong ? Can you please explain ?

thank you

>         As for the behavior of the timer, I would expect that nothing is
> going to happen until after the
>         spin_unlock_irqrestore() has been executed, since local
> interrupts are disabled.
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux