Skip to content
Snippets Groups Projects
Commit da78c7b7 authored by ismail.abloua's avatar ismail.abloua
Browse files

base code

parent 148e5c87
Branches
No related tags found
No related merge requests found
a.out
\ No newline at end of file
main.c 0 → 100644
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <semaphore.h>
#include <pthread.h>
#include <unistd.h>
#define NB_SITES 10
#define NB_BORNES 10
#define NB_HABITANT 100 // sera le nb threads
#define NB_TRAJET 10
// chaque site a NB_BORNES - 2 velos au debut
// boucle M (nb trajet)
// random delay for each transaction 1000-1999 microseconds
// tournée camion, distribution vélos sur la carte
// routine camion
// délai chargement 100-199 microsecondes
// 2-4 velos
// #ifdef DISABLE_SLEEP
// #define uspleep(x) // does nothing when disabled
// #else
// #define uspleep(x) usleep(x) // normal delay otherwise
// #endif
typedef struct _site_t
{
int habitant;
int velo;
} site_t;
int routine_habitant(){
return 0;
}
int routine_camion(){
return 0;
}
int main(){
int camion = 2;
site_t sites[NB_SITES];
for (int i = 0; i < NB_SITES; i++)
{
sites[i].habitant = 0;
sites[i].velo = NB_BORNES - 2;
}
for (int i = 0; i < NB_HABITANT; i++)
{
int random_site = rand() % NB_SITES;
sites[random_site].habitant++;
}
// test if 100 habitants
int test = 0;
for (int i = 0; i < NB_SITES; i++)
{
test += sites[i].habitant;
}
printf("test: %d\n", test);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment