Hi!

I don't understand this patch. To me it looks like both the timer thread 
and the main thread will be waiting on the same selection object 
(gl_tcb.sel_obj). Shouldn't a separate selection object be used to 
synchronize thread start-up, to avoid a race here? Secondly, I don't 
understand why we need this synchronization in the first place. 
Shouldn't the timer functions work no matter if the timer thread is 
running or not? Of course, no timer will expire until the timer thread 
has started, but it should be possible to create timers regardless of 
whether the thread is running or not.

regards,

Anders Widell

On 01/03/2017 04:42 PM, Zoran Milinkovic wrote:
>   src/base/sysf_tmr.c |  16 ++++++++++++++++
>   1 files changed, 16 insertions(+), 0 deletions(-)
>
>
> sysfTmrCreate() will wait for max 1 second for the timer thread to be fully 
> ready to start timers.
>
> diff --git a/src/base/sysf_tmr.c b/src/base/sysf_tmr.c
> --- a/src/base/sysf_tmr.c
> +++ b/src/base/sysf_tmr.c
> @@ -402,6 +402,10 @@ static uint32_t ncs_tmr_wait(void)
>   
>       ts_current = ts_start;
>   
> +     /* Send the first indication to the selection object
> +      * to synchronize threads */
> +     m_NCS_SEL_OBJ_IND(&gl_tcb.sel_obj);
> +
>       while (true) {
>               set.fd = m_GET_FD_FROM_SEL_OBJ(gl_tcb.sel_obj);
>               set.events = POLLIN;
> @@ -526,6 +530,18 @@ bool sysfTmrCreate(void)
>               m_NCS_SEL_OBJ_DESTROY(&gl_tcb.sel_obj);
>               return false;
>       }
> +
> +     /* Wait for max 1 sec for ncs_tmr_wait() to be fully ready.
> +      * The function fails if the timer thread is not ready within 1 sec */
> +     rc = osaf_poll_one_fd(gl_tcb.sel_obj.rmv_obj, 1000);
> +     if(rc != 1) {
> +             m_NCS_TASK_RELEASE(gl_tcb.p_tsk_hdl);
> +             ncs_patricia_tree_destroy(&gl_tcb.tmr_pat_tree);
> +             m_NCS_SEL_OBJ_DESTROY(&gl_tcb.sel_obj);
> +             return false;
> +     }
> +     m_NCS_SEL_OBJ_RMV_IND(&gl_tcb.sel_obj, true, true);
> +
>       return true;
>   }
>   
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Opensaf-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensaf-devel
>


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to