[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] How to delay a period for simulaton in C?(resume at samepoint)
Hi
On Tue, 20 Jun 2000, Anaking wrote:
> I'm developing a Queue, it deque a flow according to it's token acquired.
> If there is token for one flow but no packet in it's packetqueue, I want to
> pretend to transmit a packet so as to give impact to other flows on delay.
> So i want to delay a period and then return NULL packet.
> If I define timeout function, how to return the control to deque function.
> Actually, the timeout function here is doing nothing. Or is it uneccessary to
> return to deque()?
What kind of queue is it ? How do you know there is a token ? Do you use
timeout() to generate tokens ? If the latter is true, at this moment you
can check whether there is a packet and than do whatever.
Carlos
>
> Thanks for your reply. I appreciate your help on this.
>
> On Sun, 18 Jun
> 2000, you wrote: > Hi,
> >
> > Carlos Alberto Kamienski wrote:
> > > Hi
> > >
> > > I don't think it's possible to stop a function and resume later in the
> > > same point in simulation time.
> > > The way the scheduler schedule events is by calling functions ("handle"
> > > function), so that you'll probably have to change your implementation a
> > > little bit to get the same effect.
> > >
> > > Carlos
> >
> > I agreed with Carlos, I think ns work as: when there is a next scheduled
> > task, it will jump to the task based on the virtual time keep by the
> > simulator. So the simulation time is increased from one task to one task and
> > not increased continously.
> > Thus you can't used sleep( ) to do the job. The time you wake up from sleep
> > will not be the same for the simulation time.
> >
> > [My suggestion, maybe there are lot of better methods]
> > How about split the function you want to stop and resume into two, than
> > first function will call the timer.scheduled() for a delay. When the timer
> > expired, call your second function to continue your job. (you must keep the
> > state variable for the first function if your second function need to
> > continue base on some value calculated/?? in 1st function.)
> >
> > regards
> > Tan Su Wei
>