Hi Botao:
In your case, init_task and temp_task are not in the same context. If you need several tasks to write data to the same SD card, you need to pay attention to the communication and synchronization between tasks.
You can refer to the web_hvac example,
C:\Freescale\Freescale_MQX_4_2\demo\web_hvac\logging_task.c
In this example, several tasks need to write data to USB. There is a light weight semaphore and a message queue to achieve this.
Regards
Daniel