#include #include #include #include #include #include #include "acquisitionManager.h" #include "msg.h" #include "iSensor.h" #include "multitaskingAccumulator.h" #include "iAcquisitionManager.h" #include "debug.h" //producer count storage volatile unsigned int produceCount = 0; pthread_t producers[4]; static void *produce(void *params); /** * Semaphores and Mutex */ //TODO /* * Creates the synchronization elements. * @return ERROR_SUCCESS if the init is ok, ERROR_INIT otherwise */ static unsigned int createSynchronizationObjects(void); /* * Increments the produce count. */ static void incrementProducerCount(void); static unsigned int createSynchronizationObjects(void) { //TODO printf("[acquisitionManager]Semaphore created\n"); return ERROR_SUCCESS; } static void incrementProducerCount(void) { //TODO } unsigned int getProducerCount(void) { unsigned int p = 0; //TODO return p; } //TODO create accessors to limit semaphore and mutex usage outside of this C module. unsigned int acquisitionManagerInit(void) { unsigned int i; printf("[acquisitionManager]Synchronization initialization in progress...\n"); fflush( stdout ); if (createSynchronizationObjects() == ERROR_INIT) return ERROR_INIT; printf("[acquisitionManager]Synchronization initialization done.\n"); for (i = 0; i < PRODUCER_COUNT; i++) { //TODO } return ERROR_SUCCESS; } void acquisitionManagerJoin(void) { unsigned int i; for (i = 0; i < PRODUCER_COUNT; i++) { //TODO } //TODO printf("[acquisitionManager]Semaphore cleaned\n"); } void *produce(void* params) { D(printf("[acquisitionManager]Producer created with id %d\n", gettid())); unsigned int i = 0; while (i < PRODUCER_LOOP_LIMIT) { i++; sleep(PRODUCER_SLEEP_TIME+(rand() % 5)); //TODO } printf("[acquisitionManager] %d termination\n", gettid()); //TODO }