1 /****************************************************************
3 * Spark Management Routines (Sparks.lc) *
5 * Contains the spark-management routines used by GUM *
6 * (c) The Parade/AQUA Projects, Glasgow University, 1995 *
7 * Kevin Hammond, 27 February 1995 *
9 *****************************************************************/
13 #if defined(PAR) || defined(GRAN) /* whole file */
18 This uses GranSim-style sparkqs rather than old-style sparks as used
19 in the threaded world. The problem with the latter is that they
20 contain insufficient information (we also need to know whether a spark
21 is local/global etc.). Problem: at the moment GUMM uses threaded-style
22 sparks (presumably). ToDo: Fix this...
26 FindLocalSpark(forexport)
32 while (PendingSparksHd[REQUIRED_POOL] < PendingSparksTl[REQUIRED_POOL]) {
33 spark = *PendingSparksHd[REQUIRED_POOL]++;
34 if (SHOULD_SPARK(spark))
37 while (PendingSparksHd[ADVISORY_POOL] < PendingSparksTl[ADVISORY_POOL]) {
38 spark = *PendingSparksHd[ADVISORY_POOL]++;
39 if (SHOULD_SPARK(spark))
46 fprintf(stderr,"FindLocalSpark: under GRAN!\n");
50 sparkq spark, prev, next, thespark;
56 for (poolcount = 0, pool = REQUIRED_POOL;
57 thespark == NULL && poolcount < 2;
58 ++poolcount, pool = ADVISORY_POOL) {
59 for (prev = NULL, spark = PendingSparksHd[pool];
60 spark != NULL && thespark == NULL; spark = next) {
61 next = SPARK_NEXT(spark);
63 if (SHOULD_SPARK(SPARK_NODE(spark))) {
64 /* Don't Steal local sparks */
65 if (forexport && !SPARK_GLOBAL(spark)) {
69 SPARK_NEXT(spark) = NULL;
75 if (spark == PendingSparksHd[pool])
76 PendingSparksHd[pool] = next;
79 SPARK_NEXT(prev) = next;
82 if (PendingSparksHd[pool] == NULL)
83 PendingSparksTl[pool] = NULL;
85 return (thespark == NULL ? NULL : thespark);
112 Spark(closure, required)
117 I_ pool = required ? REQUIRED_POOL : ADVISORY_POOL;
119 if (SHOULD_SPARK(closure) && PendingSparksTl[pool] < PendingSparksLim[pool]) {
120 *PendingSparksTl[pool]++ = closure;
126 #endif /* PAR or GRAN -- whole file */