lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [task #7235] Create timeout framework for NO_SYS=1


From: Iordan Neshev
Subject: [lwip-devel] [task #7235] Create timeout framework for NO_SYS=1
Date: Fri, 13 Nov 2009 14:59:33 +0000
User-agent: Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.00

Follow-up Comment #17, task #7235 (project lwip):

It's been quite a long time since this
thread was started. So far the only 
discussion was about how to implement the timers.
I can confirm that nosys.c and nosys.h, sent by
Frederic work perfect for me with only one 
difference: Added

        if( time_diff < 0 )     {
                /* the '> 0' is an easy wrap-around check: the big gap at the 
wraparound
step is simply ignored... */
                time_diff = 0;
                last_time = cur_time;
        }

before the if (time_diff > 0) check.

Otherwise when the tick counter overflows the value
0xFFFF0000, the (time_diff > 0) check will fail
for the next 65.535 seconds! This happens, as you know,
every 49 days. Not a big deal but may be irritating.
This is all I can say about the timers.

Now the timeouts:
I implemented a nosys framework with a small array
of timeout structs (12 bytes):

struct nosys_timeout_s {
  u32_t time;
  nosys_timeout_handler h;
  void *arg;
};

struct nosys_timeout_s nosys_timeouts[NOSYS_TIMEOUTS_NUM];

The following functions are defined:
void nosys_timeouts_init(void);
void nosys_timeout(u32_t msecs, nosys_timeout_handler h, void *arg);
void nosys_untimeout(nosys_timeout_handler h, void *arg);
void nosys_tout_timers(void);
u8_t nosys_getfreetouts(void);

#if 1   /* Test nosys_timeouts implementation */
void test_nosys_timeouts(void);
#endif

They work exactly as the sys_* cousins.
The timers are one-shot, but there is no problem
to request the timeout inside itself. This is
how it can becomes periodic like the others in
timers_table[];

There is also a test_nosys_timeouts() function
that proofs everything works as expected.

If you accept this, the following should be added to opt.h:
#ifndef NOSYS_TIMEOUTS_NUM
#define NOSYS_TIMEOUTS_NUM 5    /* Define how many simultaneous timeout can be
active*/
#endif

#ifndef NOSYSTO_DEBUG
#define NOSYSTO_DEBUG                      LWIP_DBG_OFF
#endif

This is the log when the test is started:
nosys_timeouts_init(): Ready

 starting test_nosys_timeouts...

 Reg TO @ idx 0, time 1000, h 0x00037538, arg 0x40006A0C
 Reg TO @ idx 1, time 2000, h 0x000375B4, arg 0x40006A10
 Reg TO @ idx 2, time 3000, h 0x00037658, arg 0x40006A14

 nosys_tout_timers: Starting TO @ idx 0, handler 0x00037538, arg 0x40006A0C

 my_timeout1 fired, arg = 0 <--

 nosys_tout_timers: Finished TO @ idx 0 <--

 nosys_tout_timers: Starting TO @ idx 1, handler 0x000375B4, arg 0x40006A10

 my_timeout2 fired, arg = 1 <--

 Reg TO @ idx 0, time 2000, h 0x000375B4, arg 0x40006A10

 nosys_tout_timers: Finished TO @ idx 1 <--

 nosys_tout_timers: Starting TO @ idx 2, handler 0x00037658, arg 0x40006A14

 my_tout3a fired, arg = 1 <--(free: 4)

 Reg TO @ idx 1, time 2000, h 0x00037708, arg 0x40006A14

 nosys_tout_timers: Finished TO @ idx 2 <--

 nosys_tout_timers: Starting TO @ idx 0, handler 0x000375B4, arg 0x40006A10

 my_timeout2 fired, arg = 2 <--

 Reg TO @ idx 0, time 2000, h 0x000375B4, arg 0x40006A10

 nosys_tout_timers: Finished TO @ idx 0 <--



(file #19043, file #19044, file #19045, file #19046)
    _______________________________________________________

Additional Item Attachment:

File name: nosys.c                        Size:5 KB
File name: nosys.h                        Size:1 KB
File name: nosys_timeouts.c               Size:6 KB
File name: nosys_timeouts.h               Size:0 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/task/?7235>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]