Device-to-Device (D2D) communication technology, under the standardization of third generation partnership project and a component of the evolving fifth generation architecture, is mainly aimed to increase system capacity and data rate via providing direct communications between end devices without the use of routing data through the network. Apart from the attracting features, due to the resource sharing between cellular user equipment (CUE) and D2D user equipment (DUE) in such communications, an efficient algorithm for resource and power allocation to DUE, especially for mobile users is necessary to maintain the performance. The current paper introduces a joint mode algorithm for mobile user to choose between cellular and D2D communications and thereby, analyzes resource allocation issues. We propose an efficient algorithm for mobility management of users based on their current connection modes. The locations of D2D pairs are estimated by Levenberg-Marquardt method based on the received signal strength (RSS) from different macrocells. Since the range of D2D communication is much shorter than that of cellular communication, in order to prevent ping-pong handoffs between cellular and D2D modes, we propose the estimation of the next RSS samples in cellular mode prior to switching to D2D mode. In both cellular and D2D modes, the allocated resource block (RB) is the one with the highest signal to interference plus noise ratio (SINR) in order to increase the throughput, under the condition of providing minimum SINR requirement of CUE. This is achieved via transmission power control of the D2D pair. For performance evaluation, we studied the effects of increasing velocity of D2D and cellular users, number of users, and SINR threshold. The results indicate that the proposed solution fairly manages the communication mode of mobile users and incurs improvement in system throughput. [ABSTRACT FROM AUTHOR]