I am reading RTCS code(MQX4.0), and confused that TCPIP_task has two argrument.
In the rtcs\source\tcpip\tcpip.c:
void TCPIP_task
(
pointer dummy,
pointer creatro
)
while all other task, such as shell task has only one argrument.
Hi,
This is because TCP/IP task is created by calling function RTCS_task_create() instead of standard MQX _task_create(). RTCS_task_create has following prototype:
extern uint_32 RTCS_task_create
(
char_ptr name,
uint_32 priority,
uint_32 stacksize,
void (_CODE_PTR_ start)(pointer, pointer),
pointer arg
);
As you can see every task created by this function must have two parameters (task parameter and creator). However the TCP/IP task require no parameter so it is called 'dummy' in its definition.
Thanks a lot, Karel.
After going through the code, I wanna try to summurize this:
1. RTCS_task_create created the task RTCS_task, and take a local variable "&task" as parameter, then wait the task.sem be posted.
{
......
struct rtcs_task_state task;
RTCS_sem_init(&task.sem);
task.start = start;
task.arg = arg;
task.error = RTCS_OK;
...
task_template.TASK_ADDRESS = RTCS_task;
task_template.CREATION_PARAMETER = (uint_32)&task;
if (_task_create(0, 0, (uint_32)&task_template) == MQX_NULL_TASK_ID) {
...
} /* Endif */
RTCS_sem_wait(&task.sem);
RTCS_sem_destroy(&task.sem);
return task.error;
} /* Endbody */
2. RTCS_task run and call task->start(task->arg, task), ie, TCPIP_task(task->arg, task). The "task" here point to "struct rtcs_task_state task" within RTCS_task_create's stack.
3. TCPIP_task runs and post task.sem and continue running
4. RTCS_task_create return.
So the "creator" just a local variable of the creator.