swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ordering events in a swarm ....


From: xueyue
Subject: Re: ordering events in a swarm ....
Date: Fri, 11 Jun 1999 18:05:16 +0000

Dear Marcus, 
Thank you for sening the example below!
First, this example will work, and I did come to this stage.
But I was trying a case similar to following  following situation:
when
> - start
> {
>   count = 0;
>   schedule = [Schedule create: globalZone];
>   [self schedule: 3];
>   [[schedule activateIn: nil] run];
>   return self;
> }
> 
becomes 

- start
{
  count = 0;
  schedule = [Schedule create: globalZone];
  [self schedule: 3];
   [[schedule activateIn: nil] run];
   [schedule at: 7 createActionTo: objecta message: M(actiona)];
   [schedule at: 5 createActionTo: objectb message: M(actionb)];
  // ...more new schedule for 'schedule' object
  // ... 
   return self;
}


where objecta and objectb are two different objects.
I used your code test this idea. The modified code can be 
compiled, but actiona, actionb, ..., are not excuted. This was what I
got when I ran my own code. 
My original thought was that: 'schedule' object is created, activated,
and run at first; then some new objects such as objecta, objectb, ...,
are created at some random stages later, and they will randomly send
'schedule' actions, such as actiona, actionb, .....
Maybe my original idea was wrong. I will give up trying. 
Marcus' example currently will help me.
Thanks again!





 

Marcus G. Daniels wrote:
> 
> >>>>> "XH" == xueyue  <address@hidden> writes:
> 
> XH> So, the question here really is: can 'schedule' randomly schedule
> XH> events and excute them in their supposed order?
> 
> Yes, that certainly should work.
> 
> Can you frob this program to demonstrate the broken behavior you think
> exists?  I can't reproduce what you describe.
> 
> #import <simtools.h>
> #import <activity.h>
> #import <objectbase/SwarmObject.h>
> #import <random.h>
> 
> #define ITERATIONS 10000
> #define MINSTEP 9
> #define MAXSTEP 250
> #define REGULARSTEP 15
> 
> @interface Controller: SwarmObject
> {
>   unsigned count;
>   id <Schedule> schedule;
>   unsigned scheduled[ITERATIONS * MAXSTEP];
>   unsigned executed[ITERATIONS * MAXSTEP];
> }
> - (void)schedule: (timeval_t)t;
> - reschedule;
> - start;
> @end
> 
> @implementation Controller
> 
> - (void)schedule: (timeval_t)t
> {
>   scheduled[t]++;
>   [schedule at: t createActionTo: self message: M(reschedule)];
> }
> 
> - reschedule
> {
>   timeval_t now = getCurrentTime ();
> 
>   printf ("now: %lu", now);
> 
>   executed[now]++;
>   if (count < ITERATIONS)
>     {
>       unsigned off =
>         [uniformUnsRand getUnsignedWithMin: MINSTEP withMax: MAXSTEP];
>       timeval_t then1 = now + off;
>       timeval_t then2 = now + REGULARSTEP;
> 
>       printf (" then1: %lu then2: %lu (%u)", then1, then2, off);
> 
>       [self schedule: then1];
>       [self schedule: then2];
>       count++;
>     }
>   putchar ('\n');
>   return self;
> }
> 
> - start
> {
>   count = 0;
>   schedule = [Schedule create: globalZone];
>   [self schedule: 3];
>   [[schedule activateIn: nil] run];
>   return self;
> }
> 
> - (void)check
> {
>   timeval_t i;
> 
>   printf ("checking..\n");
>   for (i = 0; i < MAXSTEP * ITERATIONS; i++)
>     if (executed[i] != scheduled[i])
>       printf ("mismatch on timestep %lu (schedule: %u executed: %u)\n",
>               i, scheduled[i], executed[i]);
> }
> @end
> 
> int
> main (int argc, const char **argv)
> {
>   initSwarmBatch (argc, argv);
> 
>   [[[Controller create: globalZone] start] check];
> 
>   return 0;
> }
> 
> /*
> Local Variables:
> compile-command: "/opt/gnu/bin/gcc -o s2 -g -Wno-import 
> -L/opt/SUNWtcl/8.0/sun4/lib -R/opt/SUNWtcl/8.0/sun4/lib 
> -L/opt/SDGblt/2.4g/lib -R/opt/SDGblt/2.4g/lib -L/opt/SDGlibffi/1.20/lib 
> -R/opt/SDGlibffi/1.20/lib -L/opt/SDGswarm/1.4.1/lib -L/opt/SDGzlib/1.1.3/lib 
> -L/usr/local/X11/lib -R/usr/local/X11/lib -L/usr/openwin/lib 
> -R/usr/openwin/lib -L/opt/SDGhdf5/1.0.1/lib -I/opt/SDGswarm/1.4.1/include 
> s2.m -lanalysis -lsimtools -lsimtoolsgui -lactivity -ltkobjc -lrandom 
> -lobjectbase  -ldefobj -lcollections -lmisc  -ltclobjc -ltk8.0 -ltcl8.0 -lBLT 
> -lsocket -ldl -lnsl -L/usr/openwin/lib -lhdf5 -lpng -lz -lXpm -lX11 -lffi -lm 
> -lobjc -lpthread -lposix4"
> End:
> */
> 
>                   ==================================
>    Swarm-Support is for discussion of the technical details of the day
>    to day usage of Swarm.  For list administration needs (esp.
>    [un]subscribing), please send a message to <address@hidden>
>    with "help" in the body of the message.

-- 
Dr Xueyue Huang
Center for Transport Studies
Imperial College 
London SW7 2BU

(+44) 171 594 6037

Attachment: vcard.vcf
Description: Card for Xueyue Huang


reply via email to

[Prev in Thread] Current Thread [Next in Thread]