use of trigger()

hi,

I was looking into some legacy code that
creates an aperiodic component with priority 99 and RT scheduler.
The component reads and writes to some socket.
It is configured and started.
The updateHook of this component=
updateHook{
//read from socket
//do some calculations/write to some ports
//write to socket
this->trigger();
}
That last line is my question: it implies that the updateHook triggers the execution of its activity, hence itself, no?
Hence if it has highest priority on a RT system,
it will just run forever, as fast as possible, starving all the other processes, correct?
There is no sleep()/wait() or similar...
How does it work (at what update frequency?) and what could be intended?
I expected something that synchronized with the socket connection, but that
doesn't seem to be there...

Nick

use of trigger()

2015-08-25 15:12 GMT+02:00 Dominick Vanthienen <nick [dot] vanthienen [..] ...>
:

> hi,
>

Hi Nick,

>
> I was looking into some legacy code that
> creates an aperiodic component with priority 99 and RT scheduler.
> The component reads and writes to some socket.
> It is configured and started.
> The updateHook of this component=
> updateHook{
> //read from socket
> //do some calculations/write to some ports
> //write to socket
> this->trigger();
> }
> That last line is my question: it implies that the updateHook triggers the
> execution of its activity, hence itself, no?
>

right

> Hence if it has highest priority on a RT system,
> it will just run forever, as fast as possible, starving all the other
> processes, correct?
> There is no sleep()/wait() or similar...
> How does it work (at what update frequency?) and what could be intended?
> I expected something that synchronized with the socket connection, but that
> doesn't seem to be there...
>

I think the hint is in the read from socket: if you are polling, then you
will create a thread running forever; otherwise, if you make a blocking
read with a timeout, your thread will be paused and awaken when something
arrives on the socket (or when the timeout triggers), then having time for
other threads to execute.

We have some similar design here on some components with a timeout on a
blocking read.

Charles

>
> Nick
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

use of trigger()

Hi Charles,

On 08/25/2015 03:44 PM, Charles Lesire-Cabaniols wrote:
>
>
> 2015-08-25 15:12 GMT+02:00 Dominick Vanthienen
> <nick [dot] vanthienen [..] ... <mailto:nick [dot] vanthienen [..] ...>>:
>
> hi,
>
>
> Hi Nick,
>
>
> I was looking into some legacy code that
> creates an aperiodic component with priority 99 and RT scheduler.
> The component reads and writes to some socket.
> It is configured and started.
> The updateHook of this component=
> updateHook{
> //read from socket
> //do some calculations/write to some ports
> //write to socket
> this->trigger();
> }
> That last line is my question: it implies that the updateHook
> triggers the execution of its activity, hence itself, no?
>
>
> right
>
> Hence if it has highest priority on a RT system,
> it will just run forever, as fast as possible, starving all the
> other processes, correct?
> There is no sleep()/wait() or similar...
> How does it work (at what update frequency?) and what could be
> intended?
> I expected something that synchronized with the socket connection,
> but that
> doesn't seem to be there...
>
>
> I think the hint is in the read from socket: if you are polling, then
> you will create a thread running forever; otherwise, if you make a
> blocking read with a timeout, your thread will be paused and awaken
> when something arrives on the socket (or when the timeout triggers),
> then having time for other threads to execute.
>
> We have some similar design here on some components with a timeout on
> a blocking read.
Thanks!
Indeed, this is how it works :)
it uses

|int n = recvfrom(m_socket, (void*) &m_msr_data,sizeof(m_msr_data),0, (sockaddr*) &m_remote_addr, &m_sock_addr_len);|

>
> Charles
>
>
> Nick
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> <mailto:Orocos-Users [..] ...>
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>