In this paper we address the impact of task allocation to the system power consumption of a homogenous multi-core processor with a main focus on its impact on the leakage power and fan power. Although the leakage power is determined by the average die temperature and the fan power is determined by the peak temperature, our analysis shows that the overall power can be minimized if a task allocation with minimum peak temperature is adopted together with an intelligent fan speed adjustment technique that finds the optimal tradeoff between fan power and leakage power. We further propose a multi-agent distributed task migration technique that searches for the best task allocation during runtime. By choosing only those migration requests that will result chip maximum temperature reduction, the proposed framework achieves large fan power savings as well as overall power reduction. Experimental results show that, our agent-based distributed task migration policy can save up to 37.2% fan power and 17.9% system overall power compared to the random mapping policy when the temperature constraint is tight. When the temperature constraint is loose, the overall system power is insensitive to the task allocation.