/* file: event.h */ /* * Tom Laramee * HW #3 * Sim for Wireless LAN * * header file for event.h for wireless LAN MAC protocol. * (esentially supplied by TA from last year) * */ #include #include #include extern struct event *evList; /* External event list pointer (main.c) */ extern struct proc * qptr[]; /* External array of node queues */ extern int iseed; /* Seed for the random # genertor (main.c) */ extern double lambdaN; /* Node arrival rate (main.c) */ extern double timeNextEvent; /* Time of next event */ extern double sysTime; /* Global clock time */ /************************************************************************/ /* global data structures */ /************************************************************************/ struct event { double evtime; /* this field used for insertion into event list */ int evcode; /*==0 => arrival to system, 1 is departure */ int nodecode; /* nodeid at which event takes place */ int jobdest; /* nodeid to which the job is scheduled by this event */ struct event *next; struct event *prev; }; struct proc { /* structure containing info about a queued job */ long int jobid; /* id of job arriving */ double local_arrival_time; /* arrival time at this queue */ double sys_arrival_time; /* arrival time from the source */ double attribute; struct proc *next; struct proc *prev; }; typedef struct event tEvent; /* Type: event */ typedef struct event * tEventPtr; /* Pointer to type: event */ typedef struct proc tProc; /* Type: proc */ typedef struct proc * tProcPtr; /* Pointer to type: proc */ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ prototypes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ struct event *alloc_evrec(void); /* Malloc space for a tEvent */ void free_evrec(struct event *evptr); /* Free space hel by a tEventPtr */ void insertevent(struct event *p); double uni(void); void nextarrival( void ); struct proc *get_firstproc(int q_id); void free_procrec(struct proc *procptr); struct proc *alloc_procrec(void); void insertproc(struct proc *procptr, int q_id); struct event *get_next_event(void);