BUG 1048764: Factor out the exec-with-semaphore pattern out of hardware module r=dustin

--HG--
branch : defualt
Closing erroneous 'defualt' branch

--HG--
branch : defualt
extra : close : 1
Merge change from Bug 1048764
Merge to production

--HG--
branch : production