⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 开发于Linux下的多线程实例,于Kdevelop下用c++开发,模拟十字路口的车辆与交通灯.
💻 CPP
字号:
/*************************************************************************                          main.cpp  -  description                             -------------------    d閎ut                : mer mar  3 15:04:20 CET 2004    copyright            : (C) 2004 par Xin ZHOU & Robin WETZEL    e-mail               : rwetzel@mail.insa-lyon.fr*************************************************************************///---------- R閍lisation de la t鈉he m鑢e (fichier main.cpp) -------------////////////////////////////////////////////////////////////////// INCLUDE//-------------------------------------------------------- Include syst鑝e#include <config.h>#include <unistd.h>#include <sys/wait.h>#include <sys/types.h>#include <sys/msg.h>#include <sys/ipc.h>#include <sys/shm.h>#include <sys/sem.h>//------------------------------------------------------ Include personnel#ifdef HAVE_CONFIG_H#include "/public/tp/tp-multitache/Outils.h"#include "/public/tp/tp-multitache/Heure.h"#include "/public/tp/tp-multitache/Generateur.h"#include "Clavier.h"#include "Voie.h"#include "Feux.h"#endif//////////////////////////////////////////////////////////////////// PRIVE//------------------------------------------------------------- Constantes//------------------------------------------------------------------ Types//------------------------------------------------------ Variables priv閑s//------------------------------------------------------ Fonctions priv閑s//static type nom ( liste de param鑤res )// Mode d'emploi ://// Contrat :////{//} //----- fin de nom/////////////////////////////////////////////////////////////////// PUBLIC//---------------------------------------------------- Fonctions publiques//type Nom ( liste de param鑤res )// Mode d'emploi ://// Contrat :////{//} //----- fin de Nom#define DROITS 0770 // Droits d'acc鑣 aux ressources syst鑝e cr殚estypedef struct{  bool voie1_3Libre;  bool voie2_4Libre;}FormatetatFeux;FormatetatFeux * zoneFeux;int main( ){  pid_t noClavier;  pid_t noHeure;  pid_t noFeux;  pid_t noVoie1;  pid_t noVoie2;  pid_t noVoie3;  pid_t noVoie4;  pid_t noGenerateur;  int idFile;  int semEtatFeux;  int etatFeux;  InitialiserApplication( VT220 );  // Cr閍tion de la boite aux lettres (file de voitures)  idFile = msgget ( IPC_PRIVATE, DROITS | IPC_CREAT );  // Cr閍tion du s閙aphore associ

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -