[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(no subject)
From michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Wed Apr 1 18:41:47 2009
Date: Wed, 1 Apr 2009 18:41:47 +0200
From: Michael Blizek <michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: Devesh Sharma <devesh28@xxxxxxxxx>
Cc: kernelnewbies@xxxxxxxxxxxx
Subject: Re: Usage of Semaphore with a workqueue
Message-ID: <20090401164147.GB1738@grml>
References: <309a667c0904010812p23ddde3fjda53a5d3e0250075@xxxxxxxxxxxxxx>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <309a667c0904010812p23ddde3fjda53a5d3e0250075@xxxxxxxxxxxxxx>
User-Agent: Mutt/1.5.18 (2008-05-17)
Status: RO
Content-Length: 1046
Lines: 28
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