Link to home
Start Free TrialLog in
Avatar of Vigus
Vigus

asked on

Timer and Javascript Function Query

The following is a routine ( i am using it in javascript)

timer ( )
{
    myfun();


}



function myfun()
{
    x = a + b // Replace it with a very very complex calculation, that takes processor time = 5 ms
   print x  ;
}


now say my timer ( expires in 5ms ) is superfast, and gets called in   1 ms . But my function myfun(), takes 5 ms .
What would happen in this case ? Note: My timer expires in 5ms.

Thanks.

Avatar of sijohnkj
sijohnkj

timer()
{
myfun(int a,int b,int x)
{
x=a+b;
print x:
}
}
it may help u..
Avatar of Vigus

ASKER

I am not finding any solution here.
My question is about, timer's behaviour, when a function taking a considerable time to give output.

If the function which is getting called itself takes 5ms to solve.
And a timer is installed , that calls that function after every 1ms. And expires after 5ms.

then , what would happen. How many times the function would be called ? More than 1 time ? Or only 1 time, because by the time, timer expired, the function couldnot solve itself completely.
ASKER CERTIFIED SOLUTION
Avatar of siddagrl
siddagrl
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vigus

ASKER

thnx