Resource allocation and optimization for multiple-user legacy and cognitive radio systems