#include <stdio.h>
#ifdef USE_FTIME
+# include <stdlib.h>
# include <sys/timeb.h> /* for ftime() and struct timeb */
#else
# include <sys/time.h> /* for get/setitimer, gettimeofday, struct timeval */
-#endif USE_FTIME
+#endif /* USE_FTIME */
#include "event.h"
struct fgEVENT {
char description[256];
- void (*event)(); /* pointer to function */
+ void (*event)( void ); /* pointer to function */
int status; /* status flag */
long interval; /* interval in ms between each iteration of this event */
/* initialize the run queue */
-void initq() {
+void initq( void ) {
queue_front = queue_end = 0;
}
/* return queue empty status */
-int emptyq() {
+int emptyq( void ) {
if ( queue_front == queue_end ) {
return(1);
} else {
/* return queue full status */
-int fullq() {
+int fullq( void ) {
if ( (queue_end + 1) % MAX_RUN_QUEUE == queue_front ) {
return(1);
} else {
/* remove a member from the front of the queue */
-int popq() {
+int popq( void ) {
int ptr;
if ( !emptyq() ) {
e = &events[ptr];
+ printf("Running %s\n", e->description);
+
/* record starting time */
#ifdef USE_FTIME
ftime(&e->last_run);
/* Initialize the scheduling subsystem */
-void fgEventInit() {
+void fgEventInit( void ) {
+ printf("Initializing event manager\n");
event_ptr = 0;
initq();
}
/* Register an event with the scheduler, returns a pointer into the
* event table */
-int fgEventRegister(char *desc, void (*event)(), int status, int interval) {
+int fgEventRegister(char *desc, void (*event)( void ), int status,
+ int interval)
+{
struct fgEVENT *e;
e = &events[event_ptr];
+ printf("Registering event: %s\n", desc);
+
if ( strlen(desc) < 256 ) {
strcpy(e->description, desc);
} else {
/* Update the scheduling parameters for an event */
-void fgEventUpdate() {
+void fgEventUpdate( void ) {
}
/* Delete a scheduled event */
-void fgEventDelete() {
+void fgEventDelete( void ) {
}
/* Temporarily suspend scheduling of an event */
-void fgEventSuspend() {
+void fgEventSuspend( void ) {
}
/* Resume scheduling and event */
-void fgEventResume() {
+void fgEventResume( void ) {
}
/* Dump scheduling stats */
-void fgEventPrintStats() {
+void fgEventPrintStats( void ) {
int i;
- printf("Event Stats\n");
-
- for ( i = 0; i < event_ptr; i++ ) {
- printf(" %s cum=%d min=%d max=%d count=%d ave=%.2f\n",
- events[i].description, events[i].cum_time, events[i].min_time,
- events[i].max_time, events[i].count,
- events[i].cum_time / (double)events[i].count);
+ if ( event_ptr > 0 ) {
+ printf("\n");
+ printf("Event Stats\n");
+ printf("-----------\n");
+
+ for ( i = 0; i < event_ptr; i++ ) {
+ printf(" %-20s int=%.2fs cum=%ld min=%ld max=%ld count=%ld ave=%.2f\n",
+ events[i].description,
+ events[i].interval / 1000.0,
+ events[i].cum_time,
+ events[i].min_time, events[i].max_time, events[i].count,
+ events[i].cum_time / (double)events[i].count);
+ }
+ printf("\n");
}
}
/* Add pending jobs to the run queue and run the job at the front of
* the queue */
-void fgEventProcess() {
+void fgEventProcess( void ) {
#ifdef USE_FTIME
struct timeb current;
#else
#endif /* USE_FTIME */
int i;
- /* printf("Processing events\n"); */
+ printf("Processing events\n");
/* get the current time */
#ifdef USE_FTIME
/* $Log$
-/* Revision 1.1 1997/12/30 04:19:22 curt
-/* Initial revision.
+/* Revision 1.6 1998/01/19 18:40:39 curt
+/* Tons of little changes to clean up the code and to remove fatal errors
+/* when building with the c++ compiler.
/*
+ * Revision 1.5 1998/01/06 01:20:27 curt
+ * Tweaks to help building with MSVC++
+ *
+ * Revision 1.4 1997/12/31 17:46:50 curt
+ * Tweaked fg_time.c to be able to use ftime() instead of gettimeofday()
+ *
+ * Revision 1.3 1997/12/30 22:22:42 curt
+ * Further integration of event manager.
+ *
+ * Revision 1.2 1997/12/30 20:47:58 curt
+ * Integrated new event manager with subsystem initializations.
+ *
+ * Revision 1.1 1997/12/30 04:19:22 curt
+ * Initial revision.
+ *
*/