[Implemented] Add support for Win32 critical sections

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

[Implemented] Add support for Win32 critical sections

Post by Mistrel »

On Linux and OSX, POSIX mutexes act as critical sections, but on Windows they have additional kernel overhead as they can be shared between processes.

It would be nice if PureBasic could add support for the "critical section" idiom to wrap Win32 functionality and default back to mutexes on other OSs. I am currently using a #CompilerIf but it would be nice if this were abstracted away for me.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Add support for Win32 critical sections to Thread librar

Post by freak »

What is called a "Mutex" in PB is actually implemented on Windows using the CriticalSection APIs. We don't use the Windows kernel object called "Mutex".
quidquid Latine dictum sit altum videtur
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Add support for Win32 critical sections to Thread librar

Post by blueb »

Thanks Freak.
quidquid Latine dictum sit altum videtur
How true! :D
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Add support for Win32 critical sections to Thread librar

Post by Mistrel »

Thanks for the tip. :)
Post Reply