• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/genericProc/ssBackEnd/ssb_eventq.h

00001 /*
00002  * eventq.h - event queue manager interfaces
00003  *
00004  * This file is a part of the SimpleScalar tool suite written by
00005  * Todd M. Austin as a part of the Multiscalar Research Project.
00006  *  
00007  * The tool suite is currently maintained by Doug Burger and Todd M. Austin.
00008  * 
00009  * Copyright (C) 1994, 1995, 1996, 1997, 1998 by Todd M. Austin
00010  *
00011  * This source file is distributed "as is" in the hope that it will be
00012  * useful.  The tool set comes with no warranty, and no author or
00013  * distributor accepts any responsibility for the consequences of its
00014  * use. 
00015  * 
00016  * Everyone is granted permission to copy, modify and redistribute
00017  * this tool set under the following conditions:
00018  * 
00019  *    This source code is distributed for non-commercial use only. 
00020  *    Please contact the maintainer for restrictions applying to 
00021  *    commercial use.
00022  *
00023  *    Permission is granted to anyone to make or distribute copies
00024  *    of this source code, either as received or modified, in any
00025  *    medium, provided that all copyright notices, permission and
00026  *    nonwarranty notices are preserved, and that the distributor
00027  *    grants the recipient permission for further redistribution as
00028  *    permitted by this document.
00029  *
00030  *    Permission is granted to distribute this file in compiled
00031  *    or executable form under the same conditions that apply for
00032  *    source code, provided that either:
00033  *
00034  *    A. it is accompanied by the corresponding machine-readable
00035  *       source code,
00036  *    B. it is accompanied by a written offer, with no time limit,
00037  *       to give anyone a machine-readable copy of the corresponding
00038  *       source code in return for reimbursement of the cost of
00039  *       distribution.  This written offer must permit verbatim
00040  *       duplication by anyone, or
00041  *    C. it is distributed by someone who received only the
00042  *       executable form, and is accompanied by a copy of the
00043  *       written offer of source code that they received concurrently.
00044  *
00045  * In other words, you are welcome to use, share and improve this
00046  * source file.  You are forbidden to forbid anyone else to use, share
00047  * and improve what you give them.
00048  *
00049  * INTERNET: dburger@cs.wisc.edu
00050  * US Mail:  1210 W. Dayton Street, Madison, WI 53706
00051  *
00052  * $Id: ssb_eventq.h,v 1.1.1.1 2006-01-31 16:35:49 afrodri Exp $
00053  *
00054  * $Log: not supported by cvs2svn $
00055  * Revision 1.2  2004/11/16 04:17:46  arodrig6
00056  * added more documentation
00057  *
00058  * Revision 1.1  2004/08/05 23:51:44  arodrig6
00059  * grabed files from SS and broke up some of them
00060  *
00061  * Revision 1.1.1.1  2000/03/07 05:15:16  karu
00062  * this is the repository created for my own maintanence.
00063  * created when spec95 (lisp and compress worked).
00064  * compress still had the scanf("%i") problem
00065  * DIFF from the repository I am using alongwith ramdass on /projects
00066  * need to merge the two sometime :-)
00067  *
00068  * Revision 1.1.1.1  2000/02/25 21:02:50  karu
00069  * creating cvs repository for ss3-ppc
00070  *
00071  * Revision 1.4  1998/08/27 08:28:14  taustin
00072  * implemented host interface description in host.h
00073  * added target interface support
00074  *
00075  * Revision 1.3  1997/03/11  01:12:30  taustin
00076  * updated copyright
00077  * long/int tweaks made for ALPHA target support
00078  *
00079  * Revision 1.1  1996/12/05  18:50:23  taustin
00080  * Initial revision
00081  *
00082  *
00083  */
00084 
00085 #ifndef EVENTQ_H
00086 #define EVENTQ_H
00087 
00088 #include <stdio.h>
00089 
00090 #include "ssb_host.h"
00091 #include "ssb_misc.h"
00092 #include "ssb_bitmap.h"
00093 
00094 /* This module implements a time ordered event queue.  Users insert
00095  *
00096  */
00097 
00098 /* event actions */
00099 enum eventq_action {
00100   EventSetBit,                  /* set a bit: int *, bit # */
00101   EventClearBit,                /* clear a bit: int *, bit # */
00102   EventSetFlag,                 /* set a flag: int *, value */
00103   EventAddOp,                   /* add a value to a summand */
00104   EventCallback,                /* call event handler: fn * */
00105 };
00106 
00107 /* ID zero (0) is unused */
00108 typedef unsigned int EVENTQ_ID_TYPE;
00109 
00110 //: event descriptor 
00111 //!SEC:ssBack
00112 struct eventq_desc {
00113   struct eventq_desc *next;     /* next event in the sorted list */
00114   SS_TIME_TYPE when;            /* time to schedule write back event */
00115   EVENTQ_ID_TYPE id;            /* unique event ID */
00116   enum eventq_action action;    /* action on event occurrance */
00117   union eventq_data {
00118     struct {
00119       BITMAP_ENT_TYPE *bmap;    /* bitmap to access */
00120       int sz;                   /* bitmap size */
00121       int bitnum;               /* bit to set */
00122     } bit;
00123     struct {
00124       int *pflag;               /* flag to set */
00125       int value;
00126     } flag;
00127     struct {
00128       int *summand;             /* value to add to */
00129       int addend;               /* amount to add */
00130     } addop;
00131     struct {
00132       void (*fn)(SS_TIME_TYPE time, int arg);   /* function to call */
00133       int arg;                  /* argument to pass */
00134     } callback;
00135   } data;
00136 };
00137 
00138 /* initialize the event queue module, MAX_EVENT is the most events allowed
00139    pending, pass a zero if there is no limit */
00140 void eventq_init(int max_events);
00141 
00142 /* schedule an action that occurs at WHEN, action is visible at WHEN,
00143    and invisible before WHEN */
00144 EVENTQ_ID_TYPE eventq_queue_setbit(SS_TIME_TYPE when,
00145                                    BITMAP_ENT_TYPE *bmap, int sz, int bitnum);
00146 EVENTQ_ID_TYPE eventq_queue_clearbit(SS_TIME_TYPE when, BITMAP_ENT_TYPE *bmap,
00147                                      int sz, int bitnum);
00148 EVENTQ_ID_TYPE eventq_queue_setflag(SS_TIME_TYPE when,
00149                                     int *pflag, int value);
00150 EVENTQ_ID_TYPE eventq_queue_addop(SS_TIME_TYPE when,
00151                                   int *summand, int addend);
00152 EVENTQ_ID_TYPE eventq_queue_callback(SS_TIME_TYPE when,
00153                                      void (*fn)(SS_TIME_TYPE time, int arg),
00154                                      int arg);
00155 
00156 /* execute an event immediately, returns non-zero if the event was
00157    located an deleted */
00158 int eventq_execute(EVENTQ_ID_TYPE id);
00159 
00160 /* remove an event from the eventq, action is never performed, returns
00161    non-zero if the event was located an deleted */
00162 int eventq_remove(EVENTQ_ID_TYPE id);
00163 
00164 /* service all events in order of occurrance until and at NOW */
00165 void eventq_service_events(SS_TIME_TYPE now);
00166 
00167 void eventq_dump(FILE *stream);
00168 
00169 #endif /* EVENT_H */

Generated on Fri Oct 22 2010 11:02:24 for SST by  doxygen 1.7.1