FLTK logo

Re: [fltk.general] Creating a thread safe logging widget

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Creating a thread safe logging widget Bill Spitzak Jun 12, 2022  
 
Modern ones I think use (small) per-thread heaps. The problem then is that allocating and freeing in different threads loses the multithreading advantage of this and may result in locking anyway.


On Sun, Jun 12, 2022 at 10:57 AM Ian MacArthur <imacarthur@gmail.com> wrote:
On 12 Jun 2022, at 18:40, Gonzalo Garramuno wrote:
>
>
>> El 12 jun. 2022, a las 14:29, Ian MacArthur <imacarthur@gmail.com> escribió:
>>
>> Now, it is entirely possible that the modern OS memory allocators are fully multi-thread aware and so do not cause a serialization when used like this, but I am old now and do not know!
>>
>
> The new and delete operators are thread safe.  Malloc is safe depending on OS and compiler flags.  On modern Unix, it is thread safe.  On Windows, it is thread safe if compiled with one of the multithreaded flags (like /MD).
> Or at least that’s what stack overflow said :D

Sorry, I was not clear: I have no doubt they are thread-safe, rather what I do not know is how that safety is achieved.
Historically it was achieved by having a "global lock" on the heap, which had the effect that if multiple threads were allocating/deallocating they would be serialized at that point, breaking the multi-thread nature of the operations.

Now, there are lockless ways this can be done, and it is entirely feasible that the modern allocators do that (I think that is what Matt is saying) but certainly in the past the allocators were rendered thread-safe by dint of using what was essentially a master lock, and I have seen this have “unfortunate” side effects that badly perturbed the multi-thread nature of the runtime code.
So I try to avoid that (which is why I, I suppose, I don’t know whether it is even true or not now!)






--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/F1C78245-B245-4CF6-9E04-6D0C8D9222C0%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/CAL-8oAjHMzr3gS3yRjEzxRkjN3JYjh8zuuXcj-ziDZ5yn_rwNQ%40mail.gmail.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.