Re: spin_lock_irqsave or spin_lock in work queue handlers?

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

 



On 21:34 Tue 04 Mar     , Lukas Razik wrote:
> Hello all!
>
> In a work handler (of a work queue) I want to avoid the concurrently usage 
> of a socket (because there can be more worker-threads on a SMP system)...
>
> My first idea was to use spin_lock_irqsave in the work handler:

...

> Then I tried:
> ...
> spin_lock(&tx_d->lock);
> sock_sendmsg(...);
> spin_unlock(&tx_d->lock);
> ...
> and I get no error messages anymore but now a nice person asked me if 
> that's safe and I think it isn't because interrupts are on in work handlers 
> or not?

It probably works as long as there is no code which locks this spinlock with
interrupts disabled. But I recommend using a mutex instead, as it can sleeps.
The spinlock does busy waiting...
	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.homelinux.net


--
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