Advantage of using function over task

Hi All,

we can not use function if process execution is time consuming, But what is the advantage of using function over task if execution is happening in zero simulation time.

Thanks,
Rahul Kumar

Because a function call is a contract or guarantee that it will not consume time. There are many places in the LRM where you are not allowed to consume time so you must use functions, not tasks. And functions are not allowed to call tasks. You can use this contract in your own code, or whatever API you may develop and know that a method will not consume time. For example, in a mailbox or TLM Fifo, the put() method is a task, and try_put() is a function.

So my advice is to always use function void for any method and only use a task method if there is a possibility that it could consume time.

In reply to dave_59:

Thanks