Distributed Cross-Layer Algorithms for the Optimal Control of Multihop Wireless Networks