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: Marcus G. Daniels
Subject: Re: ordering events in a swarm ....
Date: 09 Jun 1999 10:08:54 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.3.10

>>>>> "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.



reply via email to

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