> In this class there is a MyClass::WriteHardware method that must be executed with mutual exclusion
Or is that just the tip of the iceberg, and there are many other contention points within the same class over the hardware?
How will MyClass.so initialise itself on first use?
You need to make sure you always end up with exactly one instance of your hardware, protected by whatever mechanism you choose, regardless of how close in time both processes are started.
What happens if one process just dies (or is killed) while it has some kind of 'lock'?
You need to use a synchronization method from the OS, such as a semaphore or file lock as a building for synchronisation.
An alternative, is to manage the resource with a single program, say a daemon, then have the two programs talk to that daemon; client-server. The programs, then, don't even need to be on the same computer.