Re: Usage of Semaphore with a workqueue

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

 



Hi!

On 07:32 Sat 04 Apr     , Devesh Sharma wrote:
> Hi michi and peter, Nice discussion.
> 
> On Fri, Apr 3, 2009 at 10:09 PM, Michael Blizek
> <michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> > Hi!

...

> > Devesh wanted to do trylock of a semaphore inside a workqueue and return
> > ERESTARTSYS if locking fails. There are some things which are wrong with
> > this approach.

...

> > 2) I have never used trylock and I still do not know what he wants to do with
> > it.
> I am just trying to understand trylock APIs and analysing the
> differences b/w the _interruptible and trylock..

Basically try to lock the mutex/semaphore and fail without waiting if it is
currently locked. I have never used it so far, but it may be useful, if you
can process something else in the mean time. e.g. You have a queue of requests
and if you fail to lock 1 request, you can put it at the end of the queue and
process the next request.

> > 3) ERESTARTSYS is for use with the _interruptable functions of mutex_lock
> > and others. It makes only sense inside system calls, because its purpose is
> > to exit the system call prematurely in order to let a signal be delivered to
> > the user space process. The system call will then fail with errno set to
> > EINTR.
> > 3.1) Returning ERESTARTSYS in a workqueue will not not work. The workqueue
> > function has to return void, so the return code will get lost.
> > 3.2) Returning ERESTARTSYS is only valid for the _interruptable functions if
> > a signal is pending. Returning it after trylock if something is currently
> > locked will not work (why would you want to do this anyway?).
> Ohh......its this way!! I was in an impression that...if ERESTARTSYS
> is returned, _anyhow_ (I mean independent of _interruptible or
> trylock), the execution context (system call)
> will restart. That is why I was thinking, that one can return
> ERESTARTSYS even with trylock..:(
> Are you saying that using ERESTARTSYS is worthless with trylock? Can
> you clarify "Is only valid for the _interruptable" if its returned
> even with trylock then will functioning of ERESTARTSYS will be droped?
> or its inherent prperty of implementation to by-pass the functioning?

See the last posting of Peter Teoh.

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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