I'm using Qemu along with a network simulator and I need to perform a 
synchronization every N cycles. What is the best way to do this in Qemu so that 
I can call a function periodically say every N instructions or simulated cpu 
cycles?

Currently I have a routine in main_loop() in vl.c but it seems like my 
synchronization routine is not called consistently. I'm showing the code 
snippet below to give you a better idea.

#define NETWORK_SYNC_CPU_CYCLES 100000
static void main_loop(void)
{
    int r;
#ifdef NETWORK_COSIM    
    int check_counter = NETWORK_SYNC_CPU_CYCLES; // 
#endif    

    qemu_main_loop_start();

    for (;;) {
        do {
            bool nonblocking = false;
#ifdef NETWORK_COSIM
           if (--check_counter == 0)
                 network_sync();
#endif
     :
     :
}

Thanks

Adnan 

Reply via email to