Minimizing stack and communication memory usage in real-time embedded applications