Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the Win32 registry thread-safe?

If I have two processes accessing a given registry key (e.g. HKLM), should I wrap the the logic in a mutex?

like image 957
JasonRShaver Avatar asked Apr 01 '09 16:04

JasonRShaver


1 Answers

The registry will make sure the actions are atomic, so you don't have to synchronize it yourself.

However, if you have multiple processes / threads accessing the registry at the same time, it doesn't make any guarantees about which happens first. Only that you won't get garbled data.

Edit: Further reading, see The inability to lock someone out of the registry is a feature, not a bug.

like image 184
i_am_jorf Avatar answered Sep 19 '22 15:09

i_am_jorf