call a nonreentrant function