> -----Original Message-----
> From: ext Anders Roxell [mailto:[email protected]]
> Sent: Friday, August 22, 2014 1:16 AM
> To: Petri Savolainen
> Cc: [email protected]
> Subject: Re: [lng-odp] [PATCH] Timer bug corrections
> 
> On 2014-08-21 14:58, Petri Savolainen wrote:
> > - Start POSIX timer in odp_timer_create
> > - return correct value int odp_timeout_tick
> >
> > Signed-off-by: Petri Savolainen <[email protected]>
> > ---
> >  platform/linux-generic/odp_timer.c | 127 ++++++++++++++++++++++++---
> ----------
> >  1 file changed, 83 insertions(+), 44 deletions(-)
> >
> > diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-
> generic/odp_timer.c
> > index 73a690b..1bf37f9 100644
> > --- a/platform/linux-generic/odp_timer.c
> > +++ b/platform/linux-generic/odp_timer.c
> > @@ -29,9 +29,11 @@ typedef struct {
> >  } tick_t;
> >
> >  typedef struct {
> > +   int               allocated;
> >     volatile int      active;
> >     volatile uint64_t cur_tick;
> >     timer_t           timerid;
> > +   odp_timer_t       timer_hdl;
> >     odp_buffer_pool_t pool;
> >     uint64_t          resolution_ns;
> >     uint64_t          max_ticks;
> > @@ -40,8 +42,10 @@ typedef struct {
> >  } timer_ring_t;
> >
> >  typedef struct {
> > -   timer_ring_t     timer[NUM_TIMERS];
> > -   odp_atomic_int_t num_timers;
> > +   odp_spinlock_t lock;
> > +   int            num_timers;
> > +   timer_ring_t   timer[NUM_TIMERS];
> > +
> >  } timer_global_t;
> 
> [...]

Added lock.

> 
> >
> > -   odp_timer.timer[id].pool          = pool;
> > -   odp_timer.timer[id].resolution_ns = RESOLUTION_NS;
> > -   odp_timer.timer[id].max_ticks     = MAX_TICKS;
> > +   timer = &odp_timer.timer[id];
> > +   timer->allocated = 1;
> > +   odp_timer.num_timers++;
> > +
> > +   odp_spinlock_unlock(&odp_timer.lock);
> > +
> > +   timer_hdl = id + 1;
> > +
> > +   timer->timer_hdl     = timer_hdl;
> > +   timer->pool          = pool;
> 
> pool change to pool_hdl

No need to highlight that odp_buffer_pool_t is a handle, because 
it's always that outside of the buffer pool implementation. Timer handle vs.
index needs highlighting since this file uses both (implements it).

> 
> > +   timer->resolution_ns = RESOLUTION_NS;
> > +   timer->max_ticks     = MAX_TICKS;
> > +
> > +   for (i = 0; i < MAX_TICKS; i++) {
> > +           odp_spinlock_init(&timer->tick[i].lock);
> > +           timer->tick[i].list = NULL;
> > +   }
> >
> > +   timer->active = 1;
> >     odp_sync_stores();
> >
> > -   odp_timer.timer[id].active = 1;
> > +   timer_start(timer);
> >
> > -   return id + 1;
> > +   return timer_hdl;
> >  }
> >
> > -odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t timer, uint64_t
> tmo_tick,
> > +odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t timer_hdl,
> uint64_t tmo_tick,
> >                                    odp_queue_t queue, odp_buffer_t buf)
> >  {
> >     int id;
> > @@ -269,10 +306,12 @@ odp_timer_tmo_t
> odp_timer_absolute_tmo(odp_timer_t timer, uint64_t tmo_tick,
> >     timeout_t *new_tmo;
> >     odp_buffer_t tmo_buf;
> >     odp_timeout_hdr_t *tmo_hdr;
> > +   timer_ring_t *timer;
> >
> > -   id = timer - 1;
> > +   id = timer_hdl - 1;
> 
> I got confused here, whats the difference between timerid and id and
> timer_hdl?

Timerid comes from POSIX API. It's used only for referencing the POSIX timer.

-Petri
 
> Cheers,
> Anders
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to