c - Looping through a changing event list -


i have list of machines ping depending on response time. machines pinged each t milliseonds 5 times. depending on response time these 5 pings on each machine adjust time of ping stretch or contract it, till arriving @ configuration this:

machine1: t1....t2....t3....t4....t5 machine2: t1......t2......t3......t4......t5 .. machinen: ..t1..t2..t3..t4..t5             ^             |machine needs pinged @ tick 

t1..tn represents (millisecond) ticks of clock.

having thread per machine ping evident, not optimal solution due number of machines.

rather, 1 thread iteratites through global order of events desirable, this:

while(true){    fetch_next_machine_to_be_pinged();   ping_it();    if(any_machine_pinged_5_times());      reorder_events(); //adjust time of next 5 ping    //continue } 

what best way achieve this? (ps: language c).

i use priority queue.

at time, queue contain 1 entry per machine. "priority" of entry m timestamp when machine m needs pinged next, , payload token identifying machine (so know whom ping).


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -