M2_SETI/T2/tp/exercice-1/displayManager.c

48 lines
1 KiB
C
Raw Normal View History

2022-11-18 15:07:43 +01:00
#include <unistd.h>
#include <stdio.h>
#include <pthread.h>
#include "displayManager.h"
#include "iDisplay.h"
#include "iAcquisitionManager.h"
#include "iMessageAdder.h"
#include "msg.h"
#include "multitaskingAccumulator.h"
#include "debug.h"
// DisplayManager thread.
pthread_t displayThread;
/**
* Display manager entry point.
* */
static void *display( void *parameters );
void displayManagerInit(void){
2022-11-19 16:11:18 +01:00
// TODO DONE
pthread_create(&displayThread, NULL, display, NULL);
2022-11-18 15:07:43 +01:00
}
void displayManagerJoin(void){
2022-11-19 16:11:18 +01:00
//TODO DONE
pthread_join(displayThread, NULL);
2022-11-18 15:07:43 +01:00
}
static void *display( void *parameters )
{
2022-11-22 14:39:55 +01:00
D(printf("[displayManager]Thread created for display with id %d\n", gettid()));
2022-11-18 15:07:43 +01:00
unsigned int diffCount = 0;
2022-11-19 16:11:18 +01:00
MSG_BLOCK mBlock;
2022-11-18 15:07:43 +01:00
while(diffCount < DISPLAY_LOOP_LIMIT){
sleep(DISPLAY_SLEEP_TIME);
//TODO
2022-11-19 16:11:18 +01:00
diffCount++;
mBlock = getCurrentSum();
messageDisplay(&mBlock);
print(getProducedCount(),getConsumedCount());
2022-11-18 15:07:43 +01:00
}
2022-11-22 14:39:55 +01:00
printf("[displayManager] %d termination\n", gettid());
2022-11-19 16:11:18 +01:00
//TODO DONE
pthread_exit(NULL);
2022-11-18 20:10:14 +01:00
}