Per parameter lock

As discussed in #43 here is a first proposal for shared device and parameter locks.