add lock/unlock in getc