/* iothing.h */ #define MAX_THINGS 10000 /* maximum (globally) thing count. */ #define THING_RUNNING 1 /* Indicates that the *thingy is running */ #define THING_STOPPED -1 #define THING_STOPPING 0 /* These are legal t_wait and t_release arguments */ #define SEM_READWRITE_THINGY 1 #define SEM_WAIT_THING 2 #define SEM_GETWORK 3 #define SEM_WAITFORWORKER 4 #define SEM_RIOMPI 5 #define SEM_RIOREAD 6 #define SEM_ANNOUNCE 7 #define SEM_ABARRIER 8 #define SEM_SYNCIO 9 /* These are the mutex's (t_lock and t_unlock arguments) */ #define READWRITEBASKETMUTEX 1 #define OUTBASKETMUTEX 2 #define THINGLISTMUTEX 3 #define WORKQUEUEMUTEX 4 #define WORKDONEQUEUEMUTEX 5 /*--------------------------------------------------------------------- * There are several queues that iop_things can be stuck into. This * structure is common to all iop_thing queues and is the thing passed * to the enqueue/dequeue routines for adding/deleting things from these * queues respectively. */ typedef struct { thing_t *first; /* first thing in the queue */ thing_t *last; /* last thing in the queue */ int mutex; /* mutex for this queue (for t_lock/unlock) */ char name[32]; /* null terminated string with the name of this queue */ } iop_queue_t; /*--------------------------------------------------------------------- * The work queue (for the TM) contains entries contributed by worker's * calling workDone or getWork. */ struct work_item { int sizeofworkID; int sender; /* the node which deposited this item */ int completed; /* nonzero if the contribution was work Done */ char workID[THING_MAX_WORKID]; /* these will be workID_thing pointers */ struct work_item *prev; struct work_item *next; }; typedef struct work_item work_item_t; typedef struct { work_item_t *first; work_item_t *last; int mutex; char name[32]; } work_queue_t; /*------------------------------------------------------------------------- * Internal support routines */ void returnStatus( thing_t *iop ); unsigned write_bytes( HANDLE fd, void *buffer, unsigned nbytes, unsigned long offset ); unsigned read_bytes( HANDLE fd, void *buffer, unsigned nbytes, unsigned long offset ); void dowrite_thingy( thing_t *iop ); void doread_thingy( thing_t *iop ); DWORD WINAPI readwrite_thingy(void); DWORD WINAPI mpi_thingy(void); void enqueue_iop_thing(thing_t *iopp, iop_queue_t *qp); thing_t* dequeue_iop_thing(iop_queue_t *qp, thing_t *ip); work_item_t* dequeue_work_thing( work_queue_t *qp); void enqueue_work_thing( work_item_t *work, work_queue_t *qp); thing_t* find_thing( char *name ); /* find thing on list of things */ thing_t* add_thing( char *name, int attribute, int home, int forwardit ); /* add.. */ int remove_thing( char *name, int forwardit ); /* remove.. */ HANDLE open_thing( char *name, thing_attributes_t attributes, int create ); int read_thyng(thing_t *thing, unsigned long offset, void *localAddress, unsigned nbytes, thing_t *status, void (*callback)(void*,void*), void *callback_data ); int write_thyng(thing_t *thing, unsigned long offset, void *localAddress, unsigned nbytes, thing_t *status, void (*callback)(void*,void*), void *callback_data ); int init_lock_things(); double timediff(struct timeval *tim1, struct timeval *tim2); void get_timers(double *cpu,double *et);