Hi, i need flowchart for this code (C++) please, THANX

Hi, i need flowchart for this code (C++) please, THANX

#include <iostream>
#include <thread>
#include <unistd.h>
#include <semaphore.h>
#include <pthread.h>
using namespace std;
#define NRO 6 // Número de coches
//Puente declarado con matriz y valor entero
void Puente(string array, int value);
// Variable global
int Norte = 1;
int Sur = 1;
sem_t mutex1;
//Coche al norte
void* NorteC(void* arg){
sem_wait(&mutex1);
string array = “En el lado Norte “; // Norte
cout<<array<<“del puente, el coche #”<<Norte<<” puede cruzar el puente\n”;
Puente(array, Norte);
cout<<array<<“del puente, el coche #”<<Norte<<” ha dejado el puente\n\n”;
Norte++;
sem_post(&mutex1);
pthread_exit(0);
}
//Coche al sur
void* SurC(void* arg){
sem_wait(&mutex1);
string array = “En el lado Sur “;
cout<<array<<“del puente, el coche #”<<Sur<<” puede cruzar el puente\n”;
Puente(array, Sur);
cout<<array<<“del puente, el coche #”<<Sur<<” ha dejado el puente\n\n”;
Sur++;
sem_post(&mutex1);
pthread_exit(0);

Don't use plagiarized sources. Get Your Custom Essay on
Hi, i need flowchart for this code (C++) please, THANX
Just from $8 /Page 0r 300 words
Order Now

}
//Método void para el puente
void Puente(string array, int value){
cout<<array<<“del puente, el coche #”<<value<<” esta viajando por el puente…\n”;
this_thread::sleep_for(chrono::milliseconds(600));
}
//Programa principal
int main(){
pthread_t Sur[NRO];
pthread_t Norte[NRO];
sem_init(&mutex1,0,1);
for(int i = 0; i < NRO; i++){
int C1 = pthread_create(&Norte[i],NULL,&NorteC,NULL);
int C2 = pthread_create(&Sur[i],NULL,SurC,NULL);
if(C1 != 0 || C2 != 0){
return 1;
}
}
for(int i = 0; i < NRO; i++){
int E1 = pthread_join(Norte[i],NULL);
int E2 = pthread_join(Sur[i],NULL);
if(E1 != 0 || E2 != 0){
return 1;
}
}
return 0;
}

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

 

In: Computer Science

Looking for a similar assignment? Get help from our qualified experts!

Order Now