use rwlock instead of a mutex in trap_manager, avoids possible deadlock