#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>

#define TIME_CST 330000

int cpt = 0;

void do_work(unsigned int duration) /* duration en millisecondes */
{
    int i;

    for(i=0;i<TIME_CST *duration;i++) asm volatile ("nop");
}

void handler()
{
    t2();
    t3();
    t4();
    t2();
    t3();
    t2();
    t4();
    t2();
    t3();
    t2();
    t4();
    t2();
    t3();
}

void t2()
{
    printf("t2\n");
    do_work(333);
}

void t3()
{
    printf("t3\n");
    do_work(1000);
}

void t4()
{
    printf("t4\n");
    do_work(2000);
}


int main()
{
    while(1)
    handler();
    while(1)
    pause();
    return 0;
}
