The question is: after using OS_OPT_PEND_NON_BLOCKING program has been circulating in the task B won't switch to run the task A,
The following is a task B receive function
Void modbus_tcp_thread (void * arg)
{
Struct netbuf * p;
U8 I=0;
U8 buf [10].
OS_MSG_SIZE size;
OS_ERR err;
//printf (" * * modbus_tcp_thread task start: \ r \ n ");
Printf (" * * modbus_tcp_thread task task priority: % d \ r \ n ", MODBUSTCP_PRIO);
EMBEnable ();
While (1)
{
EMBPoll ();
//request message OS_OPT_PEND_BLOCKING if there is no message block, wait until the message is received
P=OSTaskQPend ((OS_TICK) 0,
(OS_OPT) OS_OPT_PEND_NON_BLOCKING,//OS_OPT_PEND_NON_BLOCKING if message queue no
//task you have any news returned directly
(OS_MSG_SIZE *) & amp; The size,
(CPU_TS *) 0,
(OS_ERR *) & amp; Err);
If (err==OS_ERR_NONE)
{
Printf (" size: % d ", size);
Memcpy (buf, p, size);
Printf (" Modbus receive data: ");
for(i=0; i
Printf (" % d ", buf [I]);
}
printf("\r\n");
}
Myfree (SRAMIN, p);//release the memory
}
}
The following is A task A send function:
Printf (" the first set of data: % d ", j);
for(i=0; i<10; I++)
{
Buf [I]=I * j;
Printf (" % d ", buf [I]);
}
printf("\r\n");
//send a message
OSTaskQPost ((OS_TCB *) & amp; ModbusTCPTaskTCB,//send the message to the task Msgdis
(void *) buf,
(OS_MSG_SIZE) 10,
(OS_OPT) OS_OPT_POST_FIFO,
(OS_ERR *) & amp; Err1);
Added the following: use OS_OPT_PEND_BLOCKING, when the task after A B sends A message to A task, task B will perform the following printing, if don't send the message task B will be suspended, until the message received, now only to make the task B on time and no news received while () circulation!!!!!!!!!!
CodePudding user response:
Prioritization, right?CodePudding user response: