There are two errors in your code, the first is that you should put a break at the end of evry case (or the program fall through), the second is that donneesVol
is unitialized, your corrected code is this:
#include <stdlib.h>
#include <stdio.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
pthread_mutex_t mutexPisteCourte = PTHREAD_MUTEX_INITIALIZER; //Short airplane landing strip mutex
pthread_mutex_t mutexPisteLongue = PTHREAD_MUTEX_INITIALIZER; //Long airplane landing strip mutex
#define tempsPiste 5 // Temps passé sur une piste (décoller et attérir) //Time on landing strip
#define tempsAeroport 5 // Temps max passé dans un aéroport // Time in a airport
#define tempsFrance 10 //Temps max de trajet en France // Time to travel through France
#define tempsEurope 25 //Temps max de trajet en Europe // Time to travel through Europe
#define nbAvionsLourd 5
#define nbAvionsLeger 2
#define BUF_SIZE 100
//Prototypes
void attente(); // Wait function
void depart(int, int); //departure function
void arrivee(int, int); //arrival function
void affichage(int, char*); //display function
void *Pilote(void *); //Pilot function
//Structure représentant les données de vol //Structure were data are stored (id flight, type, destination and so on)
typedef struct structureVol
{
long id;
long type;
long destination;
}structureVol;
/*----------------*/
/* -- Fonctions --*/
/*----------------*/
void depart(int i,int j) //departure function
{
printf("Depart pris en compte"); //Test
if (j==0)
{
pthread_mutex_lock(&mutexPisteCourte);
attente(tempsPiste);
pthread_mutex_unlock(&mutexPisteCourte);
}
if (j==1)
{
pthread_mutex_lock(&mutexPisteLongue);
attente(tempsPiste);
pthread_mutex_unlock(&mutexPisteLongue);
}
else
{
printf("Erreur sur l'attribution piste décollage");
}
/* TO DO
Indiquer la piste de départ
Indiquer l'itinéraire normalisé
Indiquer la route à suivre jusqu'à la sortie de l'espace controlé ou le premier
point de report
Donner l'heure de décolage et sa limite.
Départs réalisés dans l'ordre dans lequel les avions sont prêt à décoller
Dernière règle peut être déroger pour avoir un maximum de départs ainsi qu'un
retard moyen le plus faible
*/
}
void arrivee(int i,int j) //arrival function
{
printf("Arrivée prise en compte"); //test
if (j==0)
{
pthread_mutex_lock(&mutexPisteCourte);
attente(tempsPiste);
pthread_mutex_unlock(&mutexPisteCourte);
}
if (j==1)
{
pthread_mutex_lock(&mutexPisteLongue);
attente(tempsPiste);
pthread_mutex_unlock(&mutexPisteLongue);
}
else
{
printf("Erreur sur l'attribution piste arrivée");
}
/* TO DO
Indiquer l'itinéraire normalisé ou la description de la route à suivre
jusqu'au point d'approche initiale ou au repère d'attente, jusqu'à un point
significatif ou jusqu'à l'entrée du circuit d'aerodrome, indiquer l'heure
d'approche prévue en cas d'attente ou l'estimation de la durée d'attente prévue.
*/
}
void *Pilote (void *arg) //Pilot function
{
structureVol *donnees =(structureVol *) arg;
/* Depart de l'avion */
printf("Début du thread");
depart(donnees->id,donnees->type);
fprintf(stderr,"\033[91m le vol %ld de type %ld a démarer \033[0m\n",donnees->id,donnees->type);
/* Voyage de l'avion */
attente(tempsFrance); //Avion en vol vers France
attente(tempsAeroport); //Avion en stationnement dans un autre aéroport
attente(tempsFrance); //Avion sur le retour de France
/* Arrivé de l'avion */
arrivee(donnees->id,donnees->type);
fprintf(stderr,"\033[91m le vol %ld de type %ld s'est bien terminé \033[0m\n",donnees->id,donnees->type);
pthread_exit(NULL); //Fin thread
}
void attente(int i) /* Fonction permettant d'attendre un temps aléatoire entre 1 et i */ // Wait a time between i and 1 second
{
//Initialisation du générateur de nombres aléatoire utilisant le temps système comme référence
srand(time(NULL));
int temps=rand()%i+1;
printf("Attente de %d secondes \n", temps);
sleep(temps);
}
void affichage(int i, char* texte) //display function
{
#define COLONNE 10
int k, Espace;
Espace = i*COLONNE ;
for (k=0; k<Espace; k++)
{
putchar(' ');
}
printf("%s\n",texte);
fflush(stdout);
}
/*------------*/
/* -- Main -- */
/*------------*/
int main (void)
{
int i = 0;
int thr = 0;
//int nbAvionsTotal = nbAvionsLeger + nbAvionsLourd;
structureVol donneesVol[BUF_SIZE];
//char *s1, *s2;
int typeheavy;
int typelight;
pthread_t avionlourds[nbAvionsLourd];
pthread_t avionleger[nbAvionsLeger];
printf(" ----- Initialisation du programme ----- \n\n");
affichage(1," -- Piste légère -- -- Piste lourde --\n");
affichage(2,"Test 1");
affichage(4,"Test 2");
switch(typeheavy = fork())
{
case -1:
printf("Erreur dans la création processus avion lourd \n");
break;
case 0: /* Processus type l'avion lourd */
printf("test_");
printf("je suis le fils");
for (i=0; i<nbAvionsLourd; i++)
{
printf("test2_");
donneesVol-> id = i;
donneesVol->type = 1;
donneesVol->destination = 0;
/* --- Creation de un thread par avion --- */
thr=pthread_create(&avionlourds[i], NULL, Pilote, &donneesVol[i]);
/* Erreur de création thread */
if (thr)
{
printf("Erreur sur thread %d type avion lourd \n",i);
}
for (i=0; i<nbAvionsLourd; i++)
{
pthread_join(avionlourds[i],NULL);
}
}
exit(0);
default: /* Controleur (poursuit le programme) */
printf("Dans le default\n");
wait(0);
printf("wait passé\n");
}
printf("dans le main\n");
switch(typelight = fork())
{
case -1:
printf("Erreur dans la création processus avion léger \n");
break;
case 0: /* Processus fils type l'avion léger */
for (i=0; i<nbAvionsLeger; i++)
{
donneesVol->id = i;
donneesVol->type = 0;
donneesVol->destination = 0;
/* --- Creation de un thread par avion --- */
thr=pthread_create(&avionleger[i], NULL, Pilote, &donneesVol[i]);
/* Erreur de création thread */
if (thr)
{
printf("Erreur sur thread %d type avion léger \n",i);
}
for (i=0; i<nbAvionsLeger; i++)
{
pthread_join(avionleger[i],NULL);
}
exit(0);
}
break;
default: /* Controleur (poursuit le programme) */
wait(0);
printf("wait passé\n");
}
printf("\n ----- Fin du programme ----- \n");
return 0;
}
This tells you that \red
is not defined, this is simply wrong syntax
\documentclass{book}
%mwe_clisting2
%Rétablissement des polices vectorielles
%Pour retourner dans le droit chemin, vous pouvez passer par le package ae ou bien utiliser les fontes modernes, voire les deux :
\usepackage{ae,lmodern} % ou seulement l'un, ou l'autre, ou times etc.
\usepackage[english,french]{babel}
\usepackage[utf8]{inputenc}
%%% Note that this is font encoding (determines what kind of font is used), not input encoding.
\usepackage[T1]{fontenc}
\usepackage[cyr]{aeguill}
\usepackage{tikz}
\tikzset{coltria/.style={fill=red!15!white}}
\usepackage{tcolorbox}
\tcbuselibrary{listings,breakable,skins,documentation,xparse}
\lstdefinestyle{Clst}{
literate=
{á}{{\'a}}1
{à}{{\`a }}1
{ã}{{\~a}}1
{é}{{\'e}}1
{ê}{{\^e}}1
{î}{{\^i}}1
{oe}{{\oe}}1
{í}{{\'i}}1
{ó}{{\'o}}1
{õ}{{\~o}}1
{ú}{{\'u}}1
{ü}{{\"u}}1
{ç}{{\c{c}}}1,
numbers=left,
numberstyle=\small,
numbersep=8pt,
frame = none,
language=C,
framexleftmargin=5pt, % la marge à gauche du code
% test pour améliorer la présentation du code
upquote=true,
columns=flexible,
basicstyle=\ttfamily,
basicstyle=\small, % ==> semble optimal \tiny est vraiment trop petit
% provoque une erreur texcsstyle=*\color{blue},
commentstyle=\color{green}, % comment style
keywordstyle=\color{blue}, % keyword style
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showtabs=false, % show tabs within strings adding particular underscores
stringstyle=\color{cyan}, % string literal style
numbers=none,
tabsize=4,
% pour couper les lignes trop longues
breaklines,
breakindent=1.5em, %?indente?de?3?caracteres?vers?la?droite
escapechar=µ,% pour escape en latex
% pour l'encodage à l'intérieur des listing utf8 et latin1 ?????
% inputencoding=utf8/latin1,
morekeywords=[2]{ % j'ajoute une catégorie de mots-clés
%%% pour tri sur le 5ieme caractere
gtk_window_new,
gtk_window_set_title,
gtk_window_set_resizable,
gtk_window_get_resizable,
gtk_window_is_maximized,
gtk_window_maximize,
gtk_window_unmaximize,
gtk_window_fullscreen,
gtk_window_fullscreen_on_monitor,
gtk_window_unfullscreen,
%%%%%%%%%%%
gdk_rgba_parse,
gdk_rgba_parse,
gdk_rgba_parse,
gdk_rgba_parse,
% dernier sans la virgule
},
morekeywords=[3]{ %% j'ajoute une autre catégorie de mots-clés
%%% pour tri sur le 3ieme caractere
G_TYPE_NONE,
G_TYPE_INTERFACE,
G_TYPE_CHAR,
G_TYPE_UCHAR,
G_TYPE_BOOLEAN,
G_TYPE_INT,
G_TYPE_UINT,
G_TYPE_LONG,
% dernier sans la virgule
},
morekeywords=[4]{ %% j'ajoute une autre catégorie de mots-clés
%%% pour tri sur le 1er caractere
GtkSourceLanguageManager,
GtkSourceSmartHomeEndType,
GtkSourceMarkAttributes,
GtkSourceDrawSpacesFlags,
GtkSourceCompletion,
GtkSourceGutter,
GtkSourceBackgroundPatternType,
Container_set_border_width,
GtkSourceSearchContext,
GtkFileChooserAction,
gboolean,
%%%%%%
cairo_rectangle,
cairo_fill,
% dernier sans la virgule
},
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%Traitement des mots-clefs type gtk_xxxxx
keywordstyle=[2]\monstyleblue, %%%\color{blue}, % je leur donne une coloration spéciale ds le texte
%% Intégration dans l'index OK
moreindex={[1][keywords2]}, % ces mots-clés sont ajoutés à l'index?oui
%% gtk_xxxx trié par xxxx ca fonctionne sur tout l'index
indexstyle={[1]\indexgtk}, % par le biais de macro \indexgtk
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%Traitement des mots-clefs type g_xxxxx
keywordstyle=[3]\monstylegreen, %%%\color{green}, % je leur donne une coloration spéciale ds le texte
%% Intégration dans l'index OK
moreindex={[3][keywords3]}, % ces mots-clés sont ajoutés à l'index?oui
%% gtk_xxxx trié par xxxx ca fonctionne sur tout l'index
indexstyle={[3]\indexglib}, % par le biais de ma macro tri 3ieme
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%Traitement des mots-clefs type GtkSourceSmartHomeEndType
keywordstyle=[4]\monstylebrown, %%%\color{brown}, % je leur donne une coloration spéciale ds le texte
%% Intégration dans l'index OK
moreindex={[4][keywords4]}, % ces mots-clés sont ajoutés à l'index?oui
%% xxxx trié par xxxx ca fonctionne sur tout l'index
indexstyle={[4]\indextype}, % tri sur le mot entier
}
%---------------------------------------------------------------------------------------
%------------------------------ box dédié au code langage C ----------------------------
%---------------------------------------------------------------------------------------
\newtcblisting{Clisting}[2][]{empty,breakable,leftrule=5mm,left=2mm,
%frame style={fill,top color=red!75!black,bottom color=red!75!black,middle color=red},
frame style={fill,top color=green!75!black,bottom color=green!75!black,middle color=green},
listing only,
listing engine=listings,
listing options={style=Clst,tabsize=4,breaklines,
breakindent=1.5em,columns=fullflexible},
% keywordstyle=\color{red}},
colback=yellow!15!white,
% code for unbroken boxes:
frame code={\path[tcb fill frame] (frame.south west)--(frame.north west)
--([xshift=-5mm]frame.north east)--([yshift=-5mm]frame.north east)
--([yshift=5mm]frame.south east)--([xshift=-5mm]frame.south east)--cycle; },
interior code={\path[tcb fill interior] (interior.south west)--(interior.north west)
--([xshift=-4.8mm]interior.north east)--([yshift=-4.8mm]interior.north east)
--([yshift=4.8mm]interior.south east)--([xshift=-4.8mm]interior.south east)
--cycle; },
attach boxed title to top center={yshift=-2mm},
title=\fcolorbox{black}{black}{\color{red}{#2}},
% code for the first part of a break sequence:
skin first is subskin of={emptyfirst}{%
frame code={\path[tcb fill frame] (frame.south west)--(frame.north west)
--([xshift=-5mm]frame.north east)--([yshift=-5mm]frame.north east)
--(frame.south east)--cycle;
\path[coltria] ([xshift=2.5mm,yshift=1mm]frame.south west) -- +(120:2mm)
-- +(60:2mm)-- cycle; },
interior code={\path[tcb fill interior] (interior.south west|-frame.south)
--(interior.north west)--([xshift=-4.8mm]interior.north east)
--([yshift=-4.8mm]interior.north east)--(interior.south east|-frame.south)
--cycle; },
},%
% code for the middle part of a break sequence:
skin middle is subskin of={emptymiddle}{%
frame code={\path[tcb fill frame] (frame.south west)--(frame.north west)
--(frame.north east)--(frame.south east)--cycle;
\path[coltria] ([xshift=2.5mm,yshift=-1mm]frame.north west) -- +(240:2mm)
-- +(300:2mm) -- cycle;
\path[coltria] ([xshift=2.5mm,yshift=1mm]frame.south west) -- +(120:2mm)
-- +(60:2mm) -- cycle;
},
interior code={\path[tcb fill interior] (interior.south west|-frame.south)
--(interior.north west|-frame.north)--(interior.north east|-frame.north)
--(interior.south east|-frame.south)--cycle; },
},
% code for the last part of a break sequence:
skin last is subskin of={emptylast}{%
frame code={\path[tcb fill frame] (frame.south west)--(frame.north west)
--(frame.north east)--([yshift=5mm]frame.south east)
--([xshift=-5mm]frame.south east)--cycle;
\path[coltria] ([xshift=2.5mm,yshift=-1mm]frame.north west) -- +(240:2mm)
-- +(300:2mm) -- cycle;
},
interior code={\path[tcb fill interior] (interior.south west)
--(interior.north west|-frame.north)--(interior.north east|-frame.north)
--([yshift=4.8mm]interior.south east)--([xshift=-4.8mm]interior.south east)
--cycle; },#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% attention dans les 3 commandes ci-dessous l'activation simultanée de \marginpar{\scriptsize provoque une situation ingérable par latex
\newcommand{\monstylered}[1] % attention ici le 1 c'est un seul paramètre !!!!!
{\color{red}{\emph{#1}}
}
\newcommand{\monstyleblue}[1] % attention ici le 1 c'est un seul paramètre !!!!!
{\color{blue}{\emph{#1}}
}
\newcommand{\monstylebrown}[1] % attention ici le 1 c'est un seul paramètre !!!!!
{\color{brown}{\emph{#1}}
}
\newcommand{\monstylegreen}[1] % attention ici le 1 c'est un seul paramètre !!!!!
{\color{green}{\emph{#1}}
}
%----------------------- Fin Traitement des listing ------------------------------
% --------------------- Macros pour indexation des mots clefs --------------------
% macro pour fabriquer le fichier d'index
\usepackage{makeidx}
\makeindex
% fabrication de l'index
%makeindex mwe_clisting2.idx -s perso.ist
%---------------------------------------------------------------------------------
%%%%%% tri a partir du 5ieme element gtk_XXXX et couleur index blue
\makeatletter
\def\@indexgtk@i#1#2#3#4#5,{\index{#5@\monstyleblue{#1#2#3#4#5}}}
\def\indexgtk#1{\@indexgtk@i#1,}
\makeatother
%---------------------------------------------------------------------------------
%%%%% tri a partir du 3ieme element G_NONE et couleur index green
\makeatletter
\def\@indexglib@i#1#2#3,{\index{#3@\monstylegreen{#1#2#3}}}
\def\indexglib#1{\@indexglib@i#1,}
\makeatother
%%%%%% tri a partir du 1er element MANQUE MISE EN ITALIQUE et couleur index marron
\makeatletter
\def\@indextype@i#1,{\index{#1@\monstylebrown{#1}}}
\def\indextype#1{\@indextype@i#1,}
\makeatother
%---------------------------------------------------------------------------------------
\begin{document}
Voici l'étape qui a toute les chances de ne pas être lue au début mais plutôt quand on est dans une belle impasse. Croire qu'on va s'en sortir sans un minimum de méthode n'est pas viable dans le projet que je vous propose de suivre.
Aidez-moi à conjurer le mauvais sort, et lisez avec attention cette liste de recommandation qui relève du bon sens pratique du développeur expérimenté qu'il aurait aimé découvrir dès ses premiers pas.
\begin{Clisting} {fonction draw\_func}
void draw_func (GtkDrawingArea *da,
cairo_t *cr,
int width,
int height,
gpointer data)
{
GdkRGBA red, green, yellow, blue;
double w, h;
w = width / 2.0;
h = height / 2.0;
gdk_rgba_parse (&red, "red");
gdk_rgba_parse (&green, "green");
gdk_rgba_parse (&yellow, "yellow");
gdk_rgba_parse (&blue, "blue");
gdk_cairo_set_source_rgba (cr, &red);
cairo_rectangle (cr, 0, 0, w, h);
cairo_fill (cr);
gdk_cairo_set_source_rgba (cr, &green);
cairo_rectangle (cr, w, 0, w, h);
cairo_fill (cr);
gdk_cairo_set_source_rgba (cr, &yellow);
cairo_rectangle (cr, 0, h, w, h);
cairo_fill (cr);
gdk_cairo_set_source_rgba (cr, &blue);
cairo_rectangle (cr, w, h, w, h);
cairo_fill (cr);
}
...
gtk_drawing_area_set_draw_func (area, draw, NULL, NULL);
\end{Clisting}
\begin{Clisting}{here problem with accent}
gboolean TEST1 = TRUE
if (TEST1)
{
/** nouvel essai nouvelle méthode à tester **/
...
}
else
{
/** ancien bloc fonctionnel qui buggue **/
...
}
\end{Clisting}
\begin{Clisting}{Run ok with colorisation index}
gtk_window_new
gtk_window_set_title
gtk_window_set_resizable
gtk_window_get_resizable
gtk_window_is_maximized
gtk_window_maximize
gtk_window_unmaximize
gtk_window_fullscreen
gtk_window_fullscreen_on_monitor
gtk_window_unfullscreen
G_TYPE_NONE
G_TYPE_INTERFACE
G_TYPE_CHAR
G_TYPE_UCHAR
G_TYPE_BOOLEAN
G_TYPE_INT
G_TYPE_UINT
G_TYPE_LONG
GtkSourceLanguageManager
GtkSourceSmartHomeEndType
GtkSourceMarkAttributes
GtkSourceDrawSpacesFlags
GtkSourceCompletion
GtkSourceGutter
GtkSourceBackgroundPatternType
Container_set_border_width
GtkSourceSearchContext
GtkFileChooserAction
gboolean
\end{Clisting}
\printindex
\end{document}
Recommend
Filter enabled AD users from CSV file
Delete all files in a folder but skip files that cointain certain string
append lists using groupby? ValueError: Function does not reduce
Evaluation error (NoSuchMethodError) in Azure ApplicationTokenCredentials when trying to start a VM
Creating a dynamic table in JS, Cannot read property 'addEventListener' of null
Set bitmap background the same pixels as the bitmap behind it - Windows API
TypeError: message.guild.members.filter is not a function
sort a Pandas pivot table but keep totals at end of table
log in from a single page react app to Laravel 7.x on another domain?
Why isn't my Pygame colliderect() working?
The semi-empirical mass formula
Google Script JSON nested Arrays to cell
Button inside Mapbox popup not executing function
Spring batch app does not process all items
Use Like operator on a loop on dropdown menu
SwiftUI ObservedObject not updating the view
Hugo page isn't rendering correctly
Group by and find means of all numeric varables
Creating a one-way binding for buttons
Add column to dataframe based on other columns
Transpositions and Permutations - Runtime error
JLabel text bigger than JLabel size and turning to ...
Google Drive create new folder in shared drive
use onSuccess() when form submitted successfully?
Creating view with fields depending on logged user permissions
ReactJS Using setState() for an array of objects
get just links of articles in list using BeautifulSoup
Separate delimited string values in array into boolean variables
Discord.py how to invoke another command inside another one?
Return the highest count record
select rows with a certain value in r?
break scanner for certain statements and run for others
Why is MVVM pattern not working for ChartValues?
Make a link list component of a link component in Vue
SQL Get sum of a column from another table by ID
I would like to concatenate the name of a state in react native
Return type of GROUP BY statement in Room Database
using math.pow in the middle of a function
variable within regex_findall in ansible
Loading custom fonts in React Native is giving error
TypeORM foreign key not showing on a find call
Unable to load Vuejs application on Azure after deployment
Prevent Default of a component in React
Xamarin - Delete item from CollectionView, Command does not get called
retrieve the url from background image using Selenium and Javascript
Puppeteer keeps getting TimeoutError: Navigation timeout of 80000 ms exceeded
Processing JSON into new format in JS
call component Leaflet few times in Angular 8?
find drivers avaliable during selected interval? MYSQL
C pointer to a const and non-const types pointers
Flutter: Excess space on multiline Text widgets
Can R do the equivalent of an HLOOKUP nested within a VLOOKUP?
Creating a udf in bigquery to match array inputs
SQL select medications only during covid infection
get the count of rows prior a specific date with some conditions
Use CMAKE_PREFIX_PATH for multi-configuration builds
Frequency in pandas timeseries index and statsmodel
make a GTK 2 list with multiple selection?
How use rails wikedpdf gem with ajax
Bash wait terminates immediately?
I am new to python and i am trying to create a leaderboard
Django trying to add an existing field when making a model managed
Do not insert comments when pressing O or [Return] in vim
Receiving stale element error even after defining the elements a second time
Comparing two state arrays in react will not return a boolean (True) if they are equal
Error on type Props in react flow, converting create-react app to webpack
check if an object of one list contains any object of another list
react native state not changing
use tidyselect where in a custom package?
Custom Toolbar Options using Android Kotlin is not working
In React js from App.js how to call another javascript file (service) method to consume API calls
QNetworkInterface returns duplicate addresses
Entity Framework: Passing String Parameter to FromSql Statement in Version 2.2
np.reshape() with padding if there are not enough elements
Updating Functional Component Local State Using Data From Redux State
Getting different outcome than teacher
pass selected checkbox values into childcomponent with PrimeNg without using NgModel? Angular
send a model in POST REST call from Chrome developer tools?
Kotlin Generics, correct syntax for type parameters
Why is powershell converting simply arithmetic on Integers to double?
Spreading an iterable ...obj[Symbol.iterator](...)
Kotlin - Retrofit - rxjava3 - setImage using databinding [SOLVED]
Correct Usage of uiwait and uiresume in MATLAB App Designer
Recursive directory iterator lists dots, but not directories?