Creating reader writer locks and solving the problem of priority inversion with priority inheritance