Re: Usage of Semaphore with a workqueue

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

 



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.

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

	-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