If you really want a software option, MaxiVista might be able to do what you want; but is primarily intended to slave the screen of one computer to a second, not to let you swap a monitor between two computers. Reading the documentation I think you might need to have a dedicated screen for your PC to control it though, since it only supports using a mac as an extra monitor for a PC and not the other way around.
You might be able to make it work by installing the software on the PC, connecting the monitor to the mac and en/disabling it on the mac to switch the monitor between computers. It's not clear from the documentation if the software will auto-reconnect or not.
When I tried it a few years ago, it used a fairly large chunk of CPU power on one of the computers (don't recall if it was the master or slave). I think you'd probaby be better with a hardware option (multiple inputs on monitor or KVM switch).