This commit is contained in:
higepi 2022-11-15 17:49:58 +01:00
parent 3660e6e280
commit 1358af8c4b
49 changed files with 2 additions and 601 deletions

View file

@ -0,0 +1,2 @@
Tech node (nm), Capacity (bytes), Number of banks, Associativity, Output width (bits), Access time (ns), Random cycle time (ns), Dynamic search energy (nJ), Dynamic read energy (nJ), Dynamic write energy (nJ), Standby leakage per bank(mW), Area (mm2), Ndwl, Ndbl, Nspd, Ndcm, Ndsam_level_1, Ndsam_level_2, Data arrary area efficiency %, Ntwl, Ntbl, Ntspd, Ntcm, Ntsam_level_1, Ntsam_level_2, Tag arrary area efficiency %,
90, 131072, 1, 2, 512, 1.47098, 1.86851, N/A, 0.303592, 0.615022, 63.7023, 2.24949, 2, 2, 1, 2, 2, 1, 78.3192, 2, 2, 4, 1, 8, 1, 77.9289,

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,44 +0,0 @@
.POSIX:
CC = cc
CFLAGS = -std=c11 -Wall -Wextra -O3 -mcx16 -pthread #-DDEBUG
LDFLAGS = -pthread
#LDLIBS = -latomic
C= $(wildcard *.c)
H= $(wildcard *.h)
PREAMBULE_SRCS := preambule.c
POSIX_SRCS := $(filter-out %preambule.c %Atomic.c %TestAndSet.c, $(C))
ATOMIC_SRCS := $(filter-out %preambule.c %POSIX.c %TestAndSet.c, $(C))
TESTANDSET_SRCS := $(filter-out %preambule.c %POSIX.c %Atomic.c, $(C))
DEPS= $(H:.h)
PREAMBULE_OBJS= $(PREAMBULE_SRCS:.c=.o)
POSIX_OBJS= $(POSIX_SRCS:.c=.o)
ATOMIC_OBJS= $(ATOMIC_SRCS:.c=.o)
TESTANDSET_OBJS= $(TESTANDSET_SRCS:.c=.o)
preambule: $(PREAMBULE_OBJS) $(DEPS)
$(CC) $(LDFLAGS) -o preambule $(PREAMBULE_OBJS) $(LDLIBS)
posix: $(POSIX_OBJS) $(DEPS)
$(CC) $(LDFLAGS) -o mySoftwarePosix $(POSIX_OBJS) $(LDLIBS)
atomic: $(ATOMIC_OBJS) $(DEPS)
$(CC) $(LDFLAGS) -o mySoftwareAtomic $(ATOMIC_OBJS) $(LDLIBS)
testandset: $(TESTANDSET_OBJS) $(DEPS)
$(CC) $(LDFLAGS) -o mySoftwareTestAndSet $(TESTANDSET_OBJS) $(LDLIBS)
clean:
rm -f preambule mySoftwarePosix mySoftwareAtomic mySoftwareTestAndSet $(PREAMBULE_OBJS) $(POSIX_OBJS) $(ATOMIC_OBJS) $(TESTANDSET_OBJS)
runpreambule: clean preambule
./preambule
runposix: clean posix
./mySoftwarePosix
runatomic: clean atomic
./mySoftwareAtomic
runtestandset: clean testandset
./mySoftwareTestAndSet

View file

@ -1,26 +0,0 @@
#ifndef ACQUISITION_MANAGER_H
#define ACQUISITION_MANAGER_H
#include "msg.h"
/**
* Initializes the acquisitions
*/
unsigned int acquisitionManagerInit(void);
/**
* Waits that acquisitions terminate
*/
void acquisitionManagerJoin(void);
/**
* Get producer count (debug output)
*/
unsigned int getProducerCount(void);
/**
* Get new message (blocking)
*/
void getMessage(volatile MSG_BLOCK* mBlock);
#endif

View file

@ -1,144 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <semaphore.h>
#include <unistd.h>
#include <pthread.h>
#include <fcntl.h>
#include "acquisitionManager.h"
#include "msg.h"
#include "iSensor.h"
#include "mySoftware.h"
#include "iAcquisitionManager.h"
#include "debug.h"
//producer count storage
volatile unsigned int produceCount = 0;
pthread_t producers[4];
static void *produce(void *ithread);
/**
* Semaphores and Mutex
*/
pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
// Ring buffer
MSG_BLOCK buffer[100];
unsigned int buf_head = 0;
unsigned int buf_tail = 0;
/*
* 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)
{
pthread_mutex_lock(&m1);
produceCount++;
pthread_mutex_unlock(&m1);
}
unsigned int getProducerCount(void)
{
unsigned int p = 0;
pthread_mutex_lock(&m1);
p = produceCount;
pthread_mutex_unlock(&m1);
return p;
}
void getMessage(volatile MSG_BLOCK* mBlock) {
volatile MSG_BLOCK msg;
char done = 0;
// Voir TD Vincent David
// Là c'est une version de personne frustrée ne correspondant pas au TD
while (!done) {
pthread_mutex_lock(&m1);
if (buf_tail > buf_head) {
msg = buffer[buf_tail];
buf_tail++;
done = 1;
}
pthread_mutex_unlock(&m1);
}
*mBlock = msg;
}
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++)
{
pthread_create(&producers[i], NULL, &produce, &i);
}
return ERROR_SUCCESS;
}
void acquisitionManagerJoin(void)
{
unsigned int i;
for (i = 0; i < PRODUCER_COUNT; i++)
{
pthread_join(producers[i], NULL);
}
//TODO
printf("[acquisitionManager]Semaphore cleaned\n");
}
void *produce(void *ithread)
{
D(printf("[acquisitionManager]Producer created with id %d\n", gettid()));
unsigned int i = 0;
MSG_BLOCK msg;
char done = 0;
while (i < PRODUCER_LOOP_LIMIT)
{
i++;
sleep(PRODUCER_SLEEP_TIME+(rand() % 5));
// Acquire input
getInput(*(int *)ithread, &msg);
// Store in ring buffer
pthread_mutex_lock(&m1);
while (!done) {
pthread_mutex_lock(&m1);
if (buf_head < 100) {
buffer[buf_head] = msg;
buf_head++;
done = 1;
}
pthread_mutex_unlock(&m1);
}
pthread_mutex_unlock(&m1);
}
printf("[acquisitionManager] %ld termination\n", gettid());
pthread_exit(NULL);
}

View file

@ -1,6 +0,0 @@
//C macro to active debug printf
#ifdef DEBUG
# define D(x) x
#else
# define D(x)
#endif

View file

@ -1,14 +0,0 @@
#include "iDisplay.h"
#include <stdlib.h>
#include <stdio.h>
#include "debug.h"
void messageDisplay(volatile MSG_BLOCK* mBlock){
unsigned int i;
messageCheck(mBlock);
printf("Message\n");
D(printf("["));
for(i=0;i < DATA_SIZE;i++)
D(printf("%u ",mBlock->mData[i]));
D(printf("]\n"));
}

View file

@ -1,39 +0,0 @@
#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 "mySoftware.h"
#include "debug.h"
// DisplayManager thread.
pthread_t displayThread;
/**
* Display manager entry point.
*/
static void *display( void *parameters );
void displayManagerInit(void){
pthread_create(&displayThread, NULL, display, NULL);
}
void displayManagerJoin(void){
pthread_join(displayThread, NULL);
}
static void *display( void *parameters )
{
D(printf("[displayManager] Thread created for display with id %d\n", gettid()));
unsigned int diffCount = 0;
while(diffCount < DISPLAY_LOOP_LIMIT){
sleep(DISPLAY_SLEEP_TIME);
// TODO
}
printf("[displayManager] %ld termination\n", gettid());
pthread_exit(NULL);
}

View file

@ -1,14 +0,0 @@
#ifndef MESSAGE_DISPLAY_H
#define MESSAGE_DISPLAY_H
/**
* Initializes display manager
*/
void displayManagerInit(void);
/**
* Waits that display manager terminates
*/
void displayManagerJoin(void);
#endif

View file

@ -1,8 +0,0 @@
#ifndef I_ACQUISITION_MANAGER_H
#define I_ACQUISITION_MANAGER_H
#include "msg.h"
//TODO create accessors prototype here.
#endif

View file

@ -1,12 +0,0 @@
#ifndef I_DISPLAY_H
#define I_DISPLAY_H
#include "msg.h"
/**
* Displays the message content
* @param mBlock the message pointer
*/
void messageDisplay(volatile MSG_BLOCK* mBlock);
#endif

View file

@ -1,9 +0,0 @@
#ifndef I_MESSAGE_ADDER_H
#define I_MESSAGE_ADDER_H
#include "msg.h"
//TODO create accessors prototype here.
#endif

View file

@ -1,13 +0,0 @@
#ifndef I_SENSOR_H
#define I_SENSOR_H
#include "msg.h"
/**
* Gets the input message.
* @param input the input number
* @param mBlock the message pointer returned
*/
void getInput(const unsigned int input, volatile MSG_BLOCK* mBlock);
#endif

View file

@ -1,58 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <semaphore.h>
#include <unistd.h>
#include <pthread.h>
#include "messageAdder.h"
#include "msg.h"
#include "iMessageAdder.h"
#include "mySoftware.h"
#include "iAcquisitionManager.h"
#include "debug.h"
//consumer thread
pthread_t consumer;
//Message computed
volatile MSG_BLOCK out;
//Consumer count storage
volatile unsigned int consumeCount = 0;
/**
* Increments the consume count.
*/
static void incrementConsumeCount(void);
/**
* Consumer entry point.
*/
static void *sum( void *parameters );
//TODO create accessors to limit semaphore and mutex usage outside of this C module.
void messageAdderInit(void){
out.checksum = 0;
for (size_t i = 0; i < DATA_SIZE; i++)
{
out.mData[i] = 0;
pthread_create(&consumer, NULL, sum, NULL);
}
}
void messageAdderJoin(void){
pthread_join(consumer, NULL);
}
static void *sum( void *parameters )
{
D(printf("[messageAdder] Thread created for sum with id %ld\n", gettid()));
unsigned int i = 0;
while(i<ADDER_LOOP_LIMIT){
i++;
sleep(ADDER_SLEEP_TIME);
//TODO
}
printf("[messageAdder] %ld termination\n", gettid());
pthread_exit(NULL);
}

View file

@ -1,14 +0,0 @@
#ifndef MESSAGE_ADDER_H
#define MESSAGE_ADDER_H
/**
* Initializes message adder module
*/
void messageAdderInit(void);
/**
* Waits that message adder terminates
*/
void messageAdderJoin(void);
#endif

View file

@ -1,42 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include "msg.h"
#include "debug.h"
#include <sys/syscall.h>
/**
* Add to the src message the content of add message
* @param src the message pointer
* @param add the message to add
*/
void messageAdd(volatile MSG_BLOCK* src, volatile MSG_BLOCK* add){
unsigned int i;
src->checksum = 0;
for(i=0;i < DATA_SIZE;i++){
src->mData[i] += add->mData[i];
src->checksum ^= src->mData[i];
}
D(printf("[msg]....Sum done...\n"));
}
/**
* Display the message content
* @param mBlock the message pointer
*/
unsigned int messageCheck(volatile MSG_BLOCK* mBlock){
unsigned int i, tcheck=0;
for(i=0;i < DATA_SIZE;i++)
tcheck ^= mBlock->mData[i];
if(tcheck == mBlock->checksum){
printf("[OK ] Checksum validated\n");
return 1;
}else{
printf("[ FAILED] Checksum failed, message corrupted\n");
return 0;
}
}
long gettid(void){
return syscall(SYS_gettid);
}

View file

@ -1,31 +0,0 @@
#ifndef MSG_H
#define MSG_H
//Message data size
#define DATA_SIZE 256
//message type definition
typedef struct MSG_BLOCK_TAG
{
unsigned int checksum;
unsigned int mData[DATA_SIZE];
} MSG_BLOCK;
/**
* Displays the message content
* @param mBlock the message pointer
* @return 1 if the checksum is ok, 0 otherwise
*/
unsigned int messageCheck(volatile MSG_BLOCK* mBlock);
/**
* Adds to the src message the content of add message
* @param src the message pointer
* @param add the message to add
*/
void messageAdd(volatile MSG_BLOCK* src, volatile MSG_BLOCK* add);
long gettid(void);
#endif

View file

@ -1,34 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <semaphore.h>
#include "mySoftware.h"
#include "acquisitionManager.h"
#include "displayManager.h"
#include "messageAdder.h"
#include "displayManager.h"
#include "debug.h"
//The entry point of the process
int main( void )
{
printf("[mySoftware]Software initialization in progress...\n");
acquisitionManagerInit();
messageAdderInit();
displayManagerInit();
printf("[mySoftware]Task initialization done.\n");
printf("[mySoftware]Scheduling in progress...\n");
displayManagerJoin();
messageAdderJoin();
acquisitionManagerJoin();
printf("[mySoftware]Threads terminated\n");
exit(EXIT_SUCCESS);
}

View file

@ -1,24 +0,0 @@
#ifndef MY_SOFTWARE_H
#define MY_SOFTWARE_H
#include "msg.h"
//The application return code
#define ERROR_INIT 1
#define ERROR_SUCCESS 0
//The number of producers
#define PRODUCER_COUNT 4
//The number of second the producer shall sleep
#define PRODUCER_SLEEP_TIME 1
//The number producer iterations
#define PRODUCER_LOOP_LIMIT 2
//The number of second the display shall sleep
#define DISPLAY_SLEEP_TIME 3
//The number display iterations
#define DISPLAY_LOOP_LIMIT 2
//The number of second the adder shall sleep
#define ADDER_SLEEP_TIME 2
//The number adder iterations
#define ADDER_LOOP_LIMIT PRODUCER_LOOP_LIMIT * PRODUCER_COUNT * PRODUCER_SLEEP_TIME
#endif

View file

@ -1,52 +0,0 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <semaphore.h>
#include <fcntl.h>
#define ERROR_INIT 1
#define ERROR_SUCCESS 0
#define SEMAPHORE_INITIAL_VALUE 0
#define SEM_NAME "/preambule_sem"
pthread_t thread_1;
sem_t *semaphore;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *produce(void *params)
{
printf("Trying to own the mutex\n");
pthread_mutex_lock(&mutex);
printf("Owns the mutex\n");
pthread_mutex_unlock(&mutex);
printf("Mutex released\n");
sem_post(semaphore);
printf("Semaphore posted\n");
printf("Trying to gets the semaphore\n");
sem_wait(semaphore);
printf("Semaphore taken\n");
printf("Thread ended\n");
pthread_exit(NULL);
}
int main()
{
sem_unlink(SEM_NAME);
semaphore = sem_open(SEM_NAME, O_CREAT, 0644, SEMAPHORE_INITIAL_VALUE);
if (semaphore == SEM_FAILED)
{
perror("[sem_open");
return ERROR_INIT;
}
printf("Creating the thread\n");
pthread_create(&thread_1, NULL, produce, NULL);
printf("Waiting the thread end\n");
pthread_join(thread_1, NULL);
printf("Deleting the semaphore\n");
sem_destroy(semaphore);
printf("Process ended\n");
return ERROR_SUCCESS;
}

View file

@ -1,17 +0,0 @@
#include "iSensor.h"
#include <stdio.h>
#include <stdlib.h>
#include "debug.h"
void getInput(const unsigned int input, volatile MSG_BLOCK* mBlock){
unsigned int i;
unsigned int j = input;
D(printf("Get message for input %u \n",j));
mBlock->checksum = 0;
for(i=0;i < DATA_SIZE;i++){
mBlock->mData[i] = rand();
mBlock->checksum ^= mBlock->mData[i];
}
return;
}