Re: [spice-gtk 2/3] usbredir: Use atomic for UsbDeviceManager::event_thread_run

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

 



On Wed, Jun 29, 2016 at 07:20:16PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 29-06-16 17:42, Christophe Fergeau wrote:
> > This variable is accessed from 2 different threads (main thread and USB
> > event thread), so some care must be taken to read/write it.
> 
> The event-thread only reads it, so I believe there is no need for this.

https://en.wikipedia.org/wiki/Memory_ordering#Runtime_memory_ordering
says that on most architectures stores can be reordered after loads, I'd
read this as: main thread sets event_thread_run to FALSE, calls
libusb_hotplug_deregister_callback(), usb event thread returns from
libusb_handle_events(), reads event_thread_run, but reads the old value
(TRUE) rather than the FALSE causing it to exit. I agree that it's
likely that either libusb_hotplug_deregister_callback() and/or
libusb_handle_events() are going to trigger some barrier, but it feels
safer to me to handle the concurrency ourselves.

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]