Home > other >  UCOSIII built-in messages, the use of OS_OPT_PEND_NON_BLOCKING, the task can't switch
UCOSIII built-in messages, the use of OS_OPT_PEND_NON_BLOCKING, the task can't switch

Time:09-26

I use UCOSIII built-in messaging, want to pass the task A B sends A message to A task, task B according to the received message and print, task B have other work to do at the same time, want to pass OS_OPT_PEND_NON_BLOCKING, check if there is no received A message will continue to cycle, no task B block,
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:

reference 1st floor lbing7 response:
prioritization right?
you dig the grave

CodePudding user response:

refer to the second floor g62r83t27 response:
Quote: refer to 1st floor lbing7 response:

Prioritization, right?
you dig the grave?


Should be random push system?

There was a time not to, I also only dig two or three pages

CodePudding user response:

The division of planning a priority

CodePudding user response:

While (1) it should be delay with (ucosIII delay function in the system, not to write their own time delay), other tasks or no chance to run, I just learn this, and I don't know right
  • Related