Re: Usage of Semaphore with a workqueue

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

 



Hello Michael thanks for replying, My comments are inline below

On Wed, Apr 1, 2009 at 10:11 PM, Michael Blizek
<michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi!
>
> On 20:42 Wed 01 Apr     , Devesh Sharma wrote:
>> Hello list,
>>
>> Consider a case where I have a workqueue, a work is submitted to a it
>> from some interrupt handler
>> Lets say, some where in a code, it tries to get some semaphore to
>> enter into a critical section,
>> and fails to get it, sholud I still return from the work function by
>> returning ERESTARTSYS?
>
> No, this is not a good idea. The work function which is called is expected to
> return void. If you return ERESTARTSYS anyway, your function will not be
> called again.
So should I assume semaphores can not be used with workqueues? if used
and down_trylock() is used
then some kind of wait mechanism has to be used? Also what is the case
with down_interruptible() is used?

>
> If your function is executed in workqueue context, it will be able to sleep and
> it to wait for the semaphore, but it should not take too long, because it might
> delay other tasks. In this case, you can set the workqueue up in a way that it
> has its own threads and does not cause delays for other workqueue users.
>
> BTW: What is your reason for using semaphores? See
> Documentation/mutex-design.txt
Hmm...........this document talks about not to use mutexes with
tasklet which clear my probable next
question..:). I just wanted to know th feasibility of semaphores usage
with workqueue also.
>
>        -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