When I read the code,I find there are some thread which access the same uorb topic,
that is not advertised and subscribed with the function orb_advertise_multi and orb_subscribe_multi.
So I read the the uorb modules,the read function of uorb topic is:
ssize_t
uORB::DeviceNode::read(struct file *filp, char *buffer, size_t buflen)
{
SubscriberData *sd = (SubscriberData *)filp_to_sd(filp);
/* if the object has not been written yet, return zero */
if (_data == nullptr) {
return 0;
}
/* if the caller's buffer is the wrong size, that's an error */
if (buflen != _meta->o_size) {
return -EIO;
}
/*
* Perform an atomic copy & state update
*/
irqstate_t flags = px4_enter_critical_section();
if (_generation > sd->generation + _queue_size) {
/* Reader is too far behind: some messages are lost */
_lost_messages += _generation - (sd->generation + _queue_size);
sd->generation = _generation - _queue_size;
}
if (_generation == sd->generation && sd->generation > 0) {
/* The subscriber already read the latest message, but nothing new was published yet.
* Return the previous message
*/
--sd->generation;
}
/* if the caller doesn't want the data, don't give it to them */
if (nullptr != buffer) {
memcpy(buffer, _data + (_meta->o_size * (sd->generation % _queue_size)), _meta->o_size);
}
if (sd->generation < _generation) {
++sd->generation;
}
/* set priority */
sd->set_priority(_priority);
/*
* Clear the flag that indicates that an update has been reported, as
* we have just collected it.
*/
sd->set_update_reported(false);
px4_leave_critical_section(flags);
return _meta->o_size;
}
As the description of above code,Multiple thread can read the same topic even if I don’t use orb_advertise_multi and orb_subscribe_multi. Am I correct?