Re: Hello driver

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

 



On Fri, Apr 22, 2005 at 17:11:13 +0530, Gaurav Dhiman wrote:
> On 4/22/05, Tyler <tyler@xxxxxxxx> wrote:
> > Thomas Petazzoni wrote:
> > > Hello,
> > >
> > > Greg KH wrote:
> > >
> > >>>     down_interruptible(&sem) ;
> > >>
> > >>
> > >> Why interruptible?
> > >
> > >
> > > Another remark : if you really need to use down_interruptible() (for
> > > some reason), be sure to check the return value of this function. As the
> > > name says, when you call this function, you can be interrupted by a
> > > signal. So, you should not assume that once down_interruptible() as
> > > returned, you own the corresponding semaphore : you may have been
> > > interrupted by a signal.
> > >
> > > Sincerly,
> > >
> > > Thomas
> > Ok, but in fact I'v no reason to use the interruptible locking
> > semaphores function.
> > Thx anyway :)
> 
> I think its always better to use the down_interruptible() rather than
> only down() function, as down_interruptible allows the user
> interference using signals. May I know why you said "I'v no reason to
> use the interruptible locking semaphores function."

a) You should only ever use down_interruptibe if the resource may block
   for long time. Especially considering how hard it is to handle
   interripts correctly.
b) You *MUST* check the return value of down_interruptible, or you'll
   screw up horribly. There is nothing like exceptions in kernel -- when
   interripted, down_interruptible SIMPLY RETURNS!
c) Due to the way interrupting syscalls is done, syscalls may only be
   interrupted when they will have the same result after error. Allowing
   interruption of syscalls that modify something non-idempotently (like
   open O_EXCL, mkdir, rename...) is a road to hell.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@xxxxxx>

Attachment: signature.asc
Description: Digital signature


[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