  Device-to-device (D2D) communication is an enabling technology for fog
computing by allowing the sharing of computation resources between mobile
devices. However, temperature variations in the device CPUs affect the
computation resources available for task offloading, which unpredictably alters
the processing time and energy consumption. In this paper, we address the
problem of resource allocation with respect to task partitioning, computation
resources and transmit power in a D2D-aided fog computing scenario, aiming to
minimize the expected total energy consumption under probabilistic constraints
on the processing time. Since the formulated problem is non-convex, we propose
two sub-optimal solution methods. The first method is based on difference of
convex (DC) programming, which we combine with chance-constraint programming to
handle the probabilistic time limitations. Considering that DC programming is
dependent on a good initial point, we propose a second method that relies on
only convex programming, which eliminates the dependence on user-defined
initialization. Simulation results demonstrate that the latter method
outperforms the former in terms of energy efficiency and run-time.
