SlideShare a Scribd company logo
1 of 37
Projeto1617_FaseFinal/Makefile
all: simulador monitor
monitor: monitor.o
gcc -Wall -g monitor.o -o monitor -lpthread
monitor.o: monitor.c util.h unix.h
gcc -c monitor.c
simulador: simulador.o
gcc -Wall -g simulador.o -o simulador -lpthread
simulador.o: simulador.c util.h unix.h
gcc -c simulador.c
clean:
rm *.o
Projeto1617_FaseFinal/monitor.c
#include <pthread.h>
#include <string.h>
#include "unix.h"
#include "util.h"
//apontador para o ficheiro onde será escrito o relatório da
simulação
FILE *relatorio;
//variáveis globais para a estatística
int num_fila_Piscina=0, num_fila_Toboga=0,
num_Total_Clientes_Normais=0, num_Total_cli_Idoso_Crianca
= 0, num_cli_normal=0, num_cli_Idoso_Crianca=0,
desiste_espera=0, desiste_medo=0, num_utilizacoes_tbg1=0,
num_utilizacoes_tbg2=0, num_utilizacoes_tbg3=0,
num_utilizacoes_tbg4=0, num_utilizacoes_piscina=0,
inicio_simulacao=0, fim_simulacao=0, soma_espera_normal=0,
soma_espera_prio = 0, esperou_prio=0, esperou_normal=0;
//variáveis globais para controlo de execução
int corre=0, pausa=0;
void mostra_estatistica()
{
if(corre && !pausa)
printf(" 1. Estado atual: Simulacao a decorrer.n");
else
{
if(pausa)
printf(" 1. Estado atual: Simulação em
pausa.n");
else
printf(" 1. Estado atual: Simulação
terminada.n");
}
printf(" 2. Tamanho atual da fila de espera Tobogães:
%dn", num_fila_Toboga);
printf(" 2. Tamanho atual da fila de espera Piscina: %dn",
num_fila_Piscina);
//printf(" 3. Tamanho atual da fila de espera para Clientes
Prioritários: %dn", num_fila_crianca_idoso);
//printf(" 4. Número atual de Carros: %dn", num_carros);
printf(" 5. Clientes Normais: %dn",
num_Total_Clientes_Normais);
printf(" 6. Clientes Idosos/Criança: %dn",
num_Total_cli_Idoso_Crianca);
printf(" 7. Total de Clientes: %dn",
num_Total_Clientes_Normais + num_Total_cli_Idoso_Crianca);
printf(" 8. Desistências na Fila de espera: %dn",
desiste_espera);
printf(" 9. Desistências Por medo: %dn", desiste_medo);
printf("10. Total de desistências: %dn", desiste_espera +
desiste_medo);
printf("11. Número de Clientes que foram ao Tobogã 1:
%dn", num_utilizacoes_tbg1);
printf("11. Número de Clientes que foram ao Tobogã 2:
%dn", num_utilizacoes_tbg2);
printf("11. Número de Clientes que foram ao Tobogã 3:
%dn", num_utilizacoes_tbg3);
printf("11. Número de Clientes que foram ao Tobogã 4:
%dn", num_utilizacoes_tbg4);
printf("11. Número de Clientes que foram á piscina:
%dn", num_utilizacoes_piscina);
if(esperou_normal)
printf("12. Tempo médio de espera de Clientes
Normais: %f
minutosn",(float)soma_espera_normal/(float)esperou_normal);
else
printf("12. Tempo médio de espera de Clientes
Normais: 0 minutosn");
if(esperou_prio)
printf("13. Tempo médio de espera de Clientes
Prioritários: %f
minutosn",(float)(soma_espera_prio/esperou_prio));
else
printf("13. Tempo médio de espera de Clientes
Prioritários: 0 minutosn");
}
//função que fica à escuta das mensagens do simulador
void *escuta_comunicacao(void *arg)
{
int sockfd=*((int *) arg);
int msg, tempo=0, num_comandos, id, tipo_cliente;
char buffer[256],comando[20],
atracao[20];//,utilizador[5],timestamp[11],;
//ciclo que fica à espera de mensagens do simulador
while(1)
{
if((msg=recv(sockfd, buffer, sizeof(buffer), 0)) <= 0)
{
if(msg < 0)
perror("recv");
}
else
{
buffer[msg]='0';
fprintf(relatorio,"%s", buffer);
num_comandos = sscanf(buffer,"%d %s %d %d",
&tempo, comando, &id, &tipo_cliente);
if(num_comandos>0)
{
if(!strcmp(comando,"INICIO"))
{
inicio_simulacao = tempo;
}
else
if(!strcmp(comando,"CHEGADA_PISCINA"))
{
num_fila_Piscina++;
if(tipo_cliente)
num_Total_cli_Idoso_Crianca++;
else
num_Total_Clientes_Normais++;
}
else
if(!strcmp(comando,"CHEGADA_TOBOGA"))
{
num_fila_Toboga++;
num_Total_Clientes_Normais++;
}
else
if(!strcmp(comando,"DESISTE_FILA_TOBOGA"))
{
desiste_espera++;
num_fila_Toboga--;
}
else
if(!strcmp(comando,"DESISTE_FILA_PISCINA"))
{
desiste_espera++;
num_fila_Piscina--;
}
else if(!strcmp(comando,"EMBARQUE"))
{
switch(tipo_cliente){
case 1:
num_utilizacoes_tbg1++;
num_fila_Toboga--;
break;
case 2:
num_utilizacoes_tbg2++;
num_fila_Toboga--;
break;
case 3:
num_utilizacoes_tbg3++;
num_fila_Toboga--;
break;
case 4:
num_utilizacoes_tbg4++;
num_fila_Toboga--;
break;
}
if(tipo_cliente)
{
soma_espera_prio += tempo;
esperou_prio++;
}
else
{
soma_espera_normal += tempo;
esperou_normal++;
}
}
else
if(!strcmp(comando,"EMBARQUE_PISCINA"))
{
num_utilizacoes_piscina++;
num_fila_Piscina--;
soma_espera_prio += tempo;
esperou_prio++;
}
/*else
if(!strcmp(comando,"ENTRA_EMBARQUE"))
{
if(tipo_cliente)
{
soma_espera_prio += tempo;
esperou_prio++;
}
else
{
soma_espera_normal += tempo;
esperou_normal++;
}
}*/
else
if(!strcmp(comando,"DESISTE_EMBARQUE"))
{
desiste_medo++;
}
}
}
}
return NULL;
}
//função principal do monitor
int main(int argc, char *argv[])
{
struct sockaddr_un serv_addr, cli_addr;
int sockfd, servlen, newsockfd;
int clilen=sizeof(cli_addr);
char buffer[256];
char menu[512] = "----------------------------------n|
comandos disponiveis no monitor|n---------------------------------
-n| inicio - Comecar simulacao |n| pausa - Pausar simulacao
|n| retomar - Retomar simulacao |n| estado - Estado da
simulacao |n| sair - Sair do monitor |n---------------------
-------------n";
//Criacao do socket UNIX
if((sockfd=socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
perror("cant open socket stream");
serv_addr.sun_family=AF_UNIX;
strcpy(serv_addr.sun_path, UNIXSTR_PATH);
servlen=strlen(serv_addr.sun_path)+sizeof(serv_addr.sun_f
amily);
unlink(UNIXSTR_PATH);
if(bind(sockfd, (struct sockaddr *) &serv_addr, servlen) <
0)
perror("cant bind local address");
listen(sockfd, 1);
if((newsockfd=accept(sockfd, (struct sockaddr *)
&cli_addr, &clilen)) < 0)
perror("accept error");
//criacao da tarefa que ira tratar da comunicação
tipo_cliente o simulador
pthread_t thread;
pthread_create(&thread, NULL, &escuta_comunicacao,
&newsockfd);
//Ciclo que espera pela informacao vinda da consola
printf("%s",menu);
unlink("relatorio.log");
relatorio=fopen("relatorio.log", "a");
do
{
fgets(buffer, sizeof(buffer), stdin);
if(send(newsockfd, buffer, sizeof(buffer), 0) == -1)
{
perror("send");
exit(1);
}
if(!strcmp (buffer, "inicion"))
{
corre=1;
pausa=0;
}
if(!strcmp (buffer, "pausan"))
{
pausa=1;
printf("Simulacao em pausa - "retomar" para
continuarn");
}
if(!strcmp (buffer, "retomarn"))
{
pausa=0;
}
if(!strcmp (buffer, "estadon"))
{
mostra_estatistica();
}
}
while(strcmp (buffer, "sairn"));
corre = 0;
pausa = 0;
printf("nExecução terminou.nn");
mostra_estatistica();
fclose(relatorio);
close(sockfd);
return 0;
}
Projeto1617_FaseFinal/sim.conf
INICIO_FINAL=0
TEMPO_SIMULACAO=3
TEMPO_MEDIO_CHEGADA_CLIENTES=1
PROB_DESISTE_ESPERA=10
PROB_DESISTE-ESPERA_IDOSO_CRIANCA=5
PROB_DESISTE_MEDO=5
PROB_DESISTE_MEDO_IDOSO_CRIANCA=2
TEMPO_VIAGEM=10
NUMERO_TOBOGAS=4
CAPACIDADE_UM_TOBOGA=1
Projeto1617_FaseFinal/simulador.c
/****************************************************
*****************************************************
***
Sistemas Operativos - Projeto Pratico 2016/2017 - Simulacao de
um Parque Aquático
Docentes: Eduardo Marques, Luís Gaspar
Alunos:
*****************************************************
*****************************************************
**/
#include <time.h>
#include <stdlib.h>
#include <semaphore.h>
#include <string.h>
#include <pthread.h>
#include <signal.h>
#include "unix.h"
#include "util.h"
/****************************************************
*****************************************************
***
* variaveis globais
* descricao: podem ser acedidas em qualquer momento e
local durante a execucao do simulador
*****************************************************
*****************************************************
**/
sem_t zona_embarqueToboga_prio;
sem_t zona_embarqueToboga;
sem_t lugares_Piscina;
sem_t tobogas_livres;
sem_t sai_atracao;
sem_t filaEsperaPiscina;
sem_t sai_piscina;
sem_t controla_toboga;
sem_t pode_entrar_toboga;
pthread_mutex_t mutex;
int num_cliente, num_toboga_ocupados, fila_prio,
carros_em_servico, num_toboga;
int tempoEntra;
int nr_toboga;
char atracao [20];
time_t start;
struct sockaddr_un serv_addr;
int sockfd, servlen;
//variaveis com informacao da configuracao
int INICIO_FINAL, TEMPO_SIMULACAO,
TEMPO_MEDIO_CHEGADA_CLIENTES,
PROB_DESISTE_ESPERA, PROB_DESISTE_ESPERA_PRIO,
PROB_DESISTE_MEDO, PROB_DESISTE_MEDO_PRIO,
TEMPO_VIAGEM, NUMERO_TOBOGAS,
CAPACIDADE_UM_TOBOGA;
int corre=0,pausa=0,controlo_pausa;
char printA[20] = "Toboga 1";
char printB[20] = "Toboga 2";
char printC[20] = "Toboga 3";
char printD[20] = "Toboga 4";
char printE[20] = "Piscina";
/****************************************************
*****************************************************
***
* funcao: tarefa_cliente_IdosoCrianca
* argumentos: ponteiro do tipo void
* devolve: ponteiro do tipo void
* descricao: comportamento de uma thread que representa
um cliente idoso ou criança
*****************************************************
*****************************************************
**/
void *tarefa_cliente_IdosoCrianca(void *ptr)
{
pthread_detach(pthread_self()); //detach para devolver os
recursos ao sistema -- pthread_self() retorna o id da tarefa
int g, entra_espera;
char ImprimeAtracao[20];
time_t temp_i;
int tem_esp = rand()%10; // entre 0 e 10 minutos de espera
char buffer_c[256];
sem_wait(&filaEsperaPiscina); //Se tiver lugar na fila de
espera entra nesta, senão não faz nada
pthread_mutex_lock(&mutex); //só uma tarefa é que pode
entrar aqui, reserva os recuros - mais ngm pode aceder
int num_cli_Idoso_Crianca = num_cliente++;
fila_prio++;
printf("O cliente %d chegou a fila de espera da piscina.n",
num_cli_Idoso_Crianca);
sprintf(buffer_c, "%d CHEGADA_PISCINA %d 1n",
(int)time(0), num_cli_Idoso_Crianca);
send(sockfd,buffer_c,sizeof(buffer_c),0);
temp_i = time(0);
if((int)(time(0) - temp_i) > tem_esp)
{
g = rand()%100;
if(g <= PROB_DESISTE_ESPERA_PRIO)
{
if(tem_esp == 1)
printf("O cliente %d desistiu da fila
de espera da piscina ao fim de %d minuto a espera.n",
num_cli_Idoso_Crianca, tem_esp);
else
printf("O cliente %d desistiu da fila de
espera da piscina ao fim de %d minutos a espera.n",
num_cli_Idoso_Crianca, tem_esp);
sprintf(buffer_c, "%d DESISTE_FILA_PISCINA
%d 1n", (int)time(0), num_cli_Idoso_Crianca);
send(sockfd,buffer_c,sizeof(buffer_c),0);
fila_prio--;
sem_post(&filaEsperaPiscina);
pthread_mutex_unlock(&mutex);
return NULL;
}
}
//desistencia
g = rand()%100;
if(g <= PROB_DESISTE_MEDO_PRIO)
{
printf("O cliente %d desistiu porque ficou com
medo.n", num_cli_Idoso_Crianca);
sprintf(buffer_c, "%d DESISTE_EMBARQUEn",
(int)time(0));
send(sockfd,buffer_c,sizeof(buffer_c),0);
sem_post(&filaEsperaPiscina);
pthread_mutex_unlock(&mutex);
return NULL;
}
pthread_mutex_unlock(&mutex); //liberta os recursos, o
cliente não desistiu da fila de espera - quer entrar
sem_wait(&lugares_Piscina); //vericar se existe ou não
lugares disponíveis na piscian (50)
sem_post(&filaEsperaPiscina); //se existir sai da fila de
espera da piscina e entra nesta
pthread_mutex_lock(&mutex);
// strcpy(ImprimeAtracao, atracao);
printf("O cliente %d entrou na piscina.n",
num_cli_Idoso_Crianca);
sprintf(buffer_c, "%d EMBARQUE_PISCINA %d %dn",
(int)(time(0)-temp_i), num_cli_Idoso_Crianca);
send(sockfd,buffer_c,sizeof(buffer_c),0);
pthread_mutex_unlock(&mutex);
sem_wait(&sai_piscina); //semáforo para ver se o cliente
quer ou não sair da piscina. Se não quiser fica aqui à espera
pthread_mutex_lock(&mutex);
printf("O cliente %d saiu da piscina.n",
num_cli_Idoso_Crianca);
sprintf(buffer_c, "%d DESEMBARQUE %d %dn",
(int)time(0), num_cli_Idoso_Crianca);
send(sockfd,buffer_c,sizeof(buffer_c),0);
sem_post(&lugares_Piscina);
pthread_mutex_unlock(&mutex);
return NULL;
}
/****************************************************
*****************************************************
***
* funcao: tarefa_cliente
* argumentos: ponteiro do tipo void
* devolve: ponteiro do tipo void
* descricao: comportamento de uma thread que representa
um cliente nao prioritario
*****************************************************
*****************************************************
**/
void *tarefa_cliente(void *ptr)
{
pthread_detach(pthread_self());
int g;
char ImprimeAtracao[20];
time_t temp_i;
char buffer_c[256];
int tempo_piscina = rand()%100;
int tem_esp = rand()%10; // entre 0 e 10 minutos de espera
int prob_ir_atracao = rand()%100;
//para tratar da saida do cliente da piscina, assinala que ele
quer sair da piscina
if (tempo_piscina>=1 && tempo_piscina <= 15){
sem_post(&sai_piscina);
}else{
if(prob_ir_atracao<= 80){
pthread_mutex_lock(&mutex);
int num_cli = num_cliente++;
printf("O cliente %d chegou a fila de espera dos
tobogãs.n", num_cli);
sprintf(buffer_c, "%d CHEGADA_TOBOGA %d 0n",
(int)time(0), num_cli);
send(sockfd,buffer_c,sizeof(buffer_c),0);
pthread_mutex_unlock(&mutex);
sem_wait(&zona_embarqueToboga);
pthread_mutex_lock(&mutex);
//desistencia por tempo
if((int)(time(0) - temp_i) > tem_esp)
{
g = rand()%100;
if(g <= PROB_DESISTE_ESPERA)
{
if(tem_esp == 1)
printf("O cliente %d desistiu da fila de
espera dos tobogãs ao fim de %d minuto a espera.n", num_cli,
tem_esp);
else
printf("O cliente %d desistiu da fila de
espera dos tobogãs ao fim de %d minutos a espera.n", num_cli,
tem_esp);
sprintf(buffer_c, "%d
DESISTE_FILA_TOBOGA %d 0n", (int)time(0), num_cli);
send(sockfd,buffer_c,sizeof(buffer_c),0);
sem_post(&zona_embarqueToboga);
pthread_mutex_unlock(&mutex);
return NULL;
}
}
printf("O cliente %d entrou na zona de embarque dos
tobogãs.n",num_cli);
sprintf(buffer_c, "%d ENTRA_EMBARQUE %d 0n",
time(0), num_cli);
send(sockfd,buffer_c,sizeof(buffer_c),0);
//desistencia por medo
g = rand()%100;
if(g <= PROB_DESISTE_MEDO)
{
printf("O cliente %d desistiu da fila de espera dos
tobogãs porque ficou com medo.n", num_cli);
sprintf(buffer_c, "%d DESISTE_EMBARQUEn",
(int)time(0));
send(sockfd,buffer_c,sizeof(buffer_c),0);
sem_post(&zona_embarqueToboga);
pthread_mutex_unlock(&mutex);
return NULL;
}
pthread_mutex_unlock(&mutex);
sem_wait(&tobogas_livres);
sem_post(&zona_embarqueToboga); //assinala que ficou
um lugar vago na zona de embarque dos tobogas
pthread_mutex_lock(&mutex);
// if(nr_toboga >=0 && nr_toboga<4)
// nr_toboga++;
// strcpy(ImprimeAtracao, atracao);
printf("O cliente %d entrou no tobogã %d.n", num_cli,
nr_toboga); //O cliente entrou no tobogã X
sprintf(buffer_c, "%d EMBARQUE %d %dn",
(int)(time(0)-temp_i), num_cli, nr_toboga);
send(sockfd,buffer_c,sizeof(buffer_c),0);
num_toboga_ocupados++;
pthread_mutex_unlock(&mutex);
sem_wait(&sai_atracao); //para já ver se todos sairam
pthread_mutex_lock(&mutex);
printf("O cliente %d saiu da zona de tobogãs.n",
num_cli);
sprintf(buffer_c, "%d DESEMBARQUE %d %dn",
(int)time(0), num_cli, nr_toboga);
send(sockfd,buffer_c,sizeof(buffer_c),0);
pthread_mutex_unlock(&mutex);
}
else{
sem_wait(&filaEsperaPiscina); //Se tiver lugar na fila
de espera entra nesta, senão não faz nada
pthread_mutex_lock(&mutex); //só uma tarefa é que pode
entrar aqui, reserva os recuros - mais ngm pode aceder
int num_cli_Idoso_Crianca = num_cliente++;
fila_prio++;
printf("O cliente %d chegou a fila de espera da piscina.n",
num_cli_Idoso_Crianca);
sprintf(buffer_c, "%d CHEGADA_PISCINA %d 1n",
(int)time(0), num_cli_Idoso_Crianca);
send(sockfd,buffer_c,sizeof(buffer_c),0);
//temp_i = time(0);
if((int)(time(0) - temp_i) > tem_esp)
{
g = rand()%100;
if(g <= PROB_DESISTE_ESPERA_PRIO)
{
if(tem_esp == 1)
printf("O cliente %d desistiu da fila
de espera da piscina ao fim de %d minuto a espera.n",
num_cli_Idoso_Crianca, tem_esp);
else
printf("O cliente %d desistiu da fila de
espera da piscina ao fim de %d minutos a espera.n",
num_cli_Idoso_Crianca, tem_esp);
sprintf(buffer_c, "%d DESISTE_FILA_PISCINA
%d 1n", (int)time(0), num_cli_Idoso_Crianca);
send(sockfd,buffer_c,sizeof(buffer_c),0);
fila_prio--;
sem_post(&filaEsperaPiscina);
pthread_mutex_unlock(&mutex);
return NULL;
}
}
//desistencia
g = rand()%100;
if(g <= PROB_DESISTE_MEDO_PRIO)
{
printf("O cliente %d desistiu porque ficou com
medo.n", num_cli_Idoso_Crianca);
sprintf(buffer_c, "%d DESISTE_EMBARQUEn",
(int)time(0));
send(sockfd,buffer_c,sizeof(buffer_c),0);
sem_post(&filaEsperaPiscina);
pthread_mutex_unlock(&mutex);
return NULL;
}
pthread_mutex_unlock(&mutex); //liberta os recursos, o
cliente não desistiu da fila de espera - quer entrar
sem_wait(&lugares_Piscina); //vericar se existe ou não
lugares disponíveis na piscian (50)
sem_post(&filaEsperaPiscina); //se existir sai da fila de
espera da piscina e entra nesta
pthread_mutex_lock(&mutex);
// strcpy(ImprimeAtracao, atracao);
printf("O cliente %d entrou na piscina.n",
num_cli_Idoso_Crianca);
sprintf(buffer_c, "%d EMBARQUE_PISCINA %d %dn",
(int)(time(0)-temp_i), num_cli_Idoso_Crianca);
send(sockfd,buffer_c,sizeof(buffer_c),0);
pthread_mutex_unlock(&mutex);
sem_wait(&sai_piscina); //semáforo para ver se o cliente
quer ou não sair da piscina. Se não quiser fica aqui à espera
pthread_mutex_lock(&mutex);
printf("O cliente %d saiu da piscina.n",
num_cli_Idoso_Crianca);
sprintf(buffer_c, "%d DESEMBARQUE %d %dn",
(int)time(0), num_cli_Idoso_Crianca);
send(sockfd,buffer_c,sizeof(buffer_c),0);
sem_post(&lugares_Piscina);
pthread_mutex_unlock(&mutex);
return NULL;
}
}
return NULL;
}
/****************************************************
*****************************************************
***
* funcao: tarefa_atracao
* argumentos: ponteiro do tipo void
* devolve: ponteiro do tipo void
* descricao: comportamento de uma thread que representa
um cliente prioritario
*****************************************************
*****************************************************
**/
void *tarefa_atracao(void *ptr)
{
pthread_detach(pthread_self());
int i;
char printAtracao[20];
char buffer_c[256];
time_t hora_partida, hora_i;
char variavel[20] = "atracao";
nr_toboga ++;
void inicia_viagem()
{
printf("O tobogã %d começou.n", nr_toboga);
sprintf(buffer_c, "%d ARRANQUE %dn",
(int)time(0), nr_toboga);
send(sockfd,buffer_c,sizeof(buffer_c),0);
hora_partida = time(0);
pthread_mutex_unlock(&mutex);
while((int)(time(0) - hora_partida) <
TEMPO_VIAGEM); // tempo de viagem
pthread_mutex_lock(&mutex);
printf("O tobogã %d terminou e está disponível aos
proximos utilizadores.n", nr_toboga);
sprintf(buffer_c, "%d FINAL_VIAGEM %dn",
(int)time(0), nr_toboga);
send(sockfd,buffer_c,sizeof(buffer_c),0);
sem_post(&sai_atracao); //diz que todos os
clientes sairam (1)
num_toboga_ocupados= 0;
// for(i=0;i<NUMERO_TOBOGAS; i++){
// sem_post(&tobogas_livres); //indica que
os tobogãs vão estar vazios
// }
nr_toboga = 0;
}
while(1)
{
pthread_mutex_lock(&mutex);
printf("O tobogã %d está disponível.n",
nr_toboga);
sprintf(buffer_c, "%d DISPONIVEL %dn",
(int)time(0), nr_toboga);
send(sockfd,buffer_c,sizeof(buffer_c),0);
sem_post(&tobogas_livres);
pthread_mutex_unlock(&mutex);
int i;
//sem_getvalue(&zona_embarqueToboga, &i);
hora_i = time(0);
if(time(0) > start + TEMPO_SIMULACAO)
{
usleep(100000);
pthread_mutex_lock(&mutex);
if(num_toboga_ocupados == 0)
{
printf("O parque ja fechou e nao tem
clientes em espera.n");
printf("O tobogã %d vai ser limpo.n",
nr_toboga);
carros_em_servico--;
pthread_mutex_unlock(&mutex);
return NULL;
}
printf("O tobogã %d comecou.n", nr_toboga);
sprintf(buffer_c, "%d ARRANQUE %dn",
(int)time(0), nr_toboga);
send(sockfd,buffer_c,sizeof(buffer_c),0);
hora_partida = time(0);
pthread_mutex_unlock(&mutex);
while((int)(time(0) - hora_partida) <
TEMPO_VIAGEM); // tempo de viagem
pthread_mutex_lock(&mutex);
printf("O tobogã %d fechou.n", nr_toboga);
sprintf(buffer_c, "%d FINAL_VIAGEM %dn",
(int)time(0), nr_toboga);
send(sockfd,buffer_c,sizeof(buffer_c),0);
for(i = 0; i < NUMERO_TOBOGAS; i++)
sem_post(&sai_atracao);
}
else
{
while(num_toboga_ocupados <
NUMERO_TOBOGAS && time(0) < start +
TEMPO_SIMULACAO); //enquanto todos os tobogãs não
estiverem ocupados não vai iniciar a sua atividade
//é incrementado na tarefa clienteNormal
pthread_mutex_lock(&mutex);
if(num_toboga_ocupados ==
NUMERO_TOBOGAS) //se todos os tobogãs estiverem
atualmente ocupados, vai iniciar a sua atividade (de todos)
{
pthread_mutex_unlock(&mutex);
usleep(100000);
pthread_mutex_lock(&mutex);
inicia_viagem();
}
else
{
pthread_mutex_unlock(&mutex);
usleep(100000);
pthread_mutex_lock(&mutex);
if(num_toboga_ocupados == 0)
{
printf("O parque ja fechou e nao
tem clientes em espera.n");
printf("O tobogã %d vai ser
arrumado.n", nr_toboga);
carros_em_servico--;
pthread_mutex_unlock(&mutex);
return NULL;
}
inicia_viagem();
}
}
pthread_mutex_unlock(&mutex);
}
return NULL;
}
//Funcao que trata dos pedidos vindos do Monitor
void *recebe_comandos_monitor(void *arg)
{
struct sockaddr_un cli_addr;
int done, n, id;
int sockfd=*((int *) arg), clilen=sizeof(cli_addr);
char buffer[256];
//Ciclo que fica a espera dos pedidos dos Monitor, para lhe
dar resposta adequada
while(1)
{
done=0;
if((n=recv(sockfd, buffer, sizeof(buffer), 0)) <= 0)
{
if(n < 0)
perror("recv error");
done=1;
}
buffer[n]='0';
if(!strcmp(buffer, "terminan"))
{
corre=0;
exit(1);
}
else
{
if(!strcmp(buffer, "inicion"))
corre = 1;
if(!strcmp(buffer, "pausan"))
pausa = 1;
if(!strcmp(buffer, "retomarn"))
pausa = 0;
}
}
return NULL;
}
int main(int argc, char *argv[])
{
srand(time(NULL));
num_cliente=1;
//atracao = 1;
num_toboga_ocupados = 0;
fila_prio = 0;
if(argc<2)
{
printf("Falta o ficheiro de configuração. Não é
possível continuar.");
return 1;
}
else
{
//interpretacao do ficheiro de configuraçao
int *conf = leitura_configuracao(argv[1]);
INICIO_FINAL = conf[0];
TEMPO_SIMULACAO =
conf[1];
TEMPO_MEDIO_CHEGADA_CLIENTES =
conf[2];
PROB_DESISTE_ESPERA =
conf[3];
PROB_DESISTE_ESPERA_PRIO = conf[4];
PROB_DESISTE_MEDO = conf[5];
PROB_DESISTE_MEDO_PRIO =
conf[6];
TEMPO_VIAGEM = conf[7];
NUMERO_TOBOGAS = conf[8];
CAPACIDADE_UM_TOBOGA
= conf[9];
// Inicializar semáforos
sem_init (&zona_embarqueToboga, 0, 10);
sem_init (&pode_entrar_toboga, 0, 0);
sem_init (&lugares_Piscina, 0, 50);
sem_init (&sai_atracao, 0, 0);
sem_init (&tobogas_livres, 0, 0); //semáforo para
indicar se os tobogãs estão (0) ou não vazios (1)
sem_init (&filaEsperaPiscina,0,10);
sem_init (&sai_piscina,0,0);
sem_init (&controla_toboga,0,1);
//criacao do socket e ligação
if((sockfd=socket(AF_UNIX, SOCK_STREAM, 0)) <
0)
perror("Simulador: cant open socket stream");
serv_addr.sun_family=AF_UNIX;
strcpy(serv_addr.sun_path, UNIXSTR_PATH);
servlen=strlen(serv_addr.sun_path)+sizeof(serv_addr.sun_f
amily);
if(connect(sockfd, (struct sockaddr *) &serv_addr,
servlen) < 0)
perror("connect error");
//Criacao da tarefa que ira tratar dos pedidos enviados
pelo Monitor
pthread_t thread;
pthread_create(&thread, NULL,
&recebe_comandos_monitor, &sockfd);
while(!corre);
int i, r, h;
char buffer[256];
carros_em_servico = CAPACIDADE_UM_TOBOGA;
start = time(0);
sprintf(buffer, "%d INICIOn", (int)start);
send(sockfd,buffer,sizeof(buffer),0);
TEMPO_SIMULACAO *= 60;
//thread atracao
for(i = 0; i < 4; i++)
{
num_toboga=1;
pthread_create(&thread, NULL,
&tarefa_atracao, &sockfd);
//usleep(10000);
}
while((int)(time(0) - start) < TEMPO_SIMULACAO)
{
r = rand()%100;
if (r <= 50)
{
//Criacao da tarefa de um cliente prioritário
pthread_create(&thread, NULL,
&tarefa_cliente_IdosoCrianca, &sockfd);
}
else
{
//Criacao da tarefa de um cliente normal
pthread_create(&thread, NULL,
&tarefa_cliente, &sockfd);
}
r = rand()%1;
h = rand()%3;
h = h * 100000;
if(r == 0)
h = 0 - h;
usleep((TEMPO_MEDIO_CHEGADA_CLIENTES*100000
0) + h);
if(pausa)
{
pthread_mutex_lock(&mutex);
controlo_pausa = 1;
}
while(pausa);
if(controlo_pausa)
{
pthread_mutex_unlock(&mutex);
controlo_pausa = 0;
}
}
while(carros_em_servico>0);
printf("nO parque já fechou e não existem mais
clientes em espera.n");
printf("nSimulação terminada.n");
sprintf(buffer,"%d FIM n",(int) time(0));
send(sockfd,buffer,sizeof(buffer),0);
while(corre);
close(sockfd);
}
return 0;
}
Projeto1617_FaseFinal/unix.h
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#define UNIXSTR_PATH "./s.unixstr"
#define UNIXDG_PATH "/tmp/s.unixdgx"
#define UNIXDG_TMP "/tmp/dgXXXXsdsXX"
Projeto1617_FaseFinal/util.h
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
//#define MAXLINE 512
int *leitura_configuracao(char *file)
{
int *a = (int *)malloc(sizeof(int) * 10);
FILE *fp = fopen (file, "r");
if(fp == NULL )
{
printf("Nao e possivel abrir o ficheiro de
configuracao.n");
abort();
}
int num, i=0;
char name[100], buff[500];
while (fgets( buff, sizeof buff, fp) != NULL)
{
if(sscanf(buff, "%[^=]=%d", name, &num) == 2)
a[i++]=num;
}
fclose(fp);
return a;
}
Running head: ATHLETICS SUPREME COMPANY
1
ATHLETICS SUPREME COMPANY
2
Athletics supreme company
Name
Institution
Overview of athletics supreme
Athletics supreme has majored in providing equipments
designed for use by the amateur athlete. The company produces
quality and safe equipments even if the consumers’ are
amatures.this equipments prove to express devolution in the
amateur respective sports which has enabled athletic supreme
capture the market share through its way of branding when it
comes to amateur adult team sport. In most cases, a large
market opportunity share is neglected when it comes to
adolescent sport which is the very core of athletic supreme and
ventured into the manufacture of safety helmets for the kids and
other smaller equipments used by kids only which has lead the
company to building of brands which are entertaining while
providing safety to the users (Smith, Watts, & Dagneau, 2015).
For companies like puma and adidas for instance these brands
were sold primarily in departmental stores but now its evident
that outlet malls provide sportswear to companies and even
creation of competition is upcoming and from different
companies and even stores.
Market Research Strategies
When it comes to market, the company needs to analyze and
compare brands selling and products that these companies are
selling. The company also needs to find that consumer needs
that is not met and also identify gaps in order for it to further
understand the market and placement of the pricing strategies. It
also needs to perform qualitative and quantitative examinations
of the target market details.sttrategies needed to pull data from
all available sources to further identify their strong competitors
and also data analysis will help athletic supreme company to
locate new small companies emerging and reviews of their
profit and losses to use the data to the companies advantage to
gain insight not only into market potential but also in terms of
the consumer wants too.unsuccessfull and successfulness trials
in competition allows the athletic supreme to further identify
what they want their sportswear and brands to convey to any
customer keeping in mind that the customer needs and wants are
not necessarily the same (LeRoy, 2015).
Product Strategies
Athletics supreme company being already an established
manufacturer of new sportswear lines needed and safe sport
gears to be marketed and create a new link between safety and
attire, advertisement could accomplish this but it seems
complicated since the company is emerging in adolescent sport
arena. Its best to markets these attires which are similar to the
big name brands kids associate and this is done through the
colour and design creation that is appealing to the youthful eye
in the solid market. Mature adult sport simply needs to display
new attires and gears they are already familiar with which will
be able to be used easily with no complications in the event of
use or competition. Safety being a much harder area when it
comes to trust, attire is based on design demand in maintaining
the companies safety quality through attire purchase which
eventually becomes the second habit of the customer (Smith,
Watts, & Dagneau, 2015).
Place Strategies
Being that the athletics supreme company unwillingness to
compromise its core base, the gear and quality of safety remains
in their original state with no interference the company’s
product line should not be located togherether instead they
should be broken down into smaller gear facilities which will be
the premier supplier of attires while the main facility will be
able to accommodate any additional order without
compromising quality through unnecessary shifting from one
facility to the other in search of accommodation location.
Maintaining of staff at the new attire facility will enable a
structure and historical knowledge base. The company needs
additional software components to its ordering system in order
to allow gears and attires to be ordered and shipped on time and
in their complete state (LeRoy, 2015).
Pricing Strategies
In order for athletics supreme company to promote the new
attire lines, it should include sample dialogues in the
equipments orders shipped including giving the customers
discounts on the attires purchased initially even though the
equipment prices will need to be left at their original price so as
to reflect the unchanged product (Smith, Watts, & Dagneau,
2015). Customers who are likely to combine products and bring
customers need to be given discounts as a way of appreciation.
Pricing should be competitive with similar companies but
should not exceed the competition price mark set up by the
Deutsche Bahn (DB) caps.
since caps are all money-makers mechanisms, the products
needs to be prised accordingly with no problem since no
companies products wants to be victims when it comes to
prizing. Products cannot be under prized since they have the
potential to make profit to the company. In order to get the
consumers attention, sleeved shirts should be at least or just
below the competitors pricing in order to give athletics supreme
company a slight advantage. Through capitalizing on the
companies sport equipments and its safety in the larger market
like the baseball for instance is the leading market and the
company should gain attention through offering lower priced
shirts and suggest complimenting caps (LeRoy, 2015).
Promotional Strategies
With regards to advancement, the organization needs to utilize a
specialist to decide the necessities of the encompassing markets
and how they can best address these issues with advancement as
a forceful deal limited time procedure. Through people group
mindfulness and writing the organization can run battles on
radios stations to concentrate on the regular games furthermore
take the items to the general population enthusiastically as a
method for advancing the organization and additionally the
client. This ought to be done to illuminate the clients of the new
market items and their constrained ecological effects. Being that
most adolescent are presently via web-based networking media,
the organization can utilize this to advance the organization's
items through posting them via web-based networking media
furthermore commercials through televisions, posters, flyers,
newspapers and magazines.
Competitive advantage
Games finest necessities to accumulate knowledge in rivalry
with the goal for them to have the capacity to contend as
required. They initially need to recognize their objective and be
inventive in discovering the opposition sections they are in,
what the clients purchase from the contenders, what advantages
are there in rivalry, and any data they can discover on
evaluating, administrations offered, rivalry, and limited time
procedures. This should effortlessly be possible through going
to the stores or locales, converse with the contenders’ clients
and merchants to get data and utilize them further bolstering
your good fortune (Smith, Watts, and Dagneau, 2015).
Being that games incomparable has an officially settled market
it likewise needs to put measures to guarantee that it remains in
the market and even progress globally. In order to build up its
clothing market all around, the organization needs to
comprehend the market conduct by doing research in the areas
in inquiries and set up work systems which are probably going
to work in those local markets and in addition the worldwide
markets which have a tendency to contrast much of the time.
This could be as far as framework which may influence the
generation of items and shipment which has its focal points and
burdens.
Conclusion
It is important to keep an eye on what the people like to wear or
what keeps the customers comfortable. Being a producer you
need to keep more emphasis on the product you are producing
because the product may be eye catching but to tight to fit the
intended customer or even to big to fit the responsible party’s
when it comes to attire one should now the condition which is
likely to make the customer buy and wear the companies
products. Research is a key factor when it comes to decision
making at the last stages before the production process starts.
References
Smith, P. B., Watts, N. A., & Dagneau, F. O. (2015). U.S.
Patent No. 9,174,111. Washington, DC: U.S. Patent and
Trademark Office.
LeRoy, M. H. (2015). Courts and the Future of Athletic Labour
in College Sports. Ariz. L. Rev., 57, 475.

More Related Content

Similar to Projeto1617_FaseFinalMakefileall simulador monitormoni.docx

Password protected personal diary report
Password protected personal diary reportPassword protected personal diary report
Password protected personal diary reportMoueed Ahmed
 
httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxadampcarr67227
 
Help Needed!UNIX Shell and History Feature This project consists.pdf
Help Needed!UNIX Shell and History Feature This project consists.pdfHelp Needed!UNIX Shell and History Feature This project consists.pdf
Help Needed!UNIX Shell and History Feature This project consists.pdfmohdjakirfb
 
TYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkTYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkChristian Trabold
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15종인 전
 
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...Mr. Vengineer
 
Cell processor lab
Cell processor labCell processor lab
Cell processor labcoolmirza143
 
ood evening people. Ive been working on this code that sends a bur.pdf
ood evening people. Ive been working on this code that sends a bur.pdfood evening people. Ive been working on this code that sends a bur.pdf
ood evening people. Ive been working on this code that sends a bur.pdfaroramobiles1
 
The Ring programming language version 1.7 book - Part 86 of 196
The Ring programming language version 1.7 book - Part 86 of 196The Ring programming language version 1.7 book - Part 86 of 196
The Ring programming language version 1.7 book - Part 86 of 196Mahmoud Samir Fayed
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104swena_gupta
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104swena_gupta
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104swena_gupta
 
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...doughellmann
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScriptJens Siebert
 
Tool sdl2pml
Tool sdl2pmlTool sdl2pml
Tool sdl2pmlS56WBV
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfclarityvision
 

Similar to Projeto1617_FaseFinalMakefileall simulador monitormoni.docx (20)

Supermarket
SupermarketSupermarket
Supermarket
 
Programa en ccs compiller
Programa en ccs compillerPrograma en ccs compiller
Programa en ccs compiller
 
Password protected personal diary report
Password protected personal diary reportPassword protected personal diary report
Password protected personal diary report
 
httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docx
 
Help Needed!UNIX Shell and History Feature This project consists.pdf
Help Needed!UNIX Shell and History Feature This project consists.pdfHelp Needed!UNIX Shell and History Feature This project consists.pdf
Help Needed!UNIX Shell and History Feature This project consists.pdf
 
TYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkTYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase framework
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
 
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
 
Cell processor lab
Cell processor labCell processor lab
Cell processor lab
 
ood evening people. Ive been working on this code that sends a bur.pdf
ood evening people. Ive been working on this code that sends a bur.pdfood evening people. Ive been working on this code that sends a bur.pdf
ood evening people. Ive been working on this code that sends a bur.pdf
 
The Ring programming language version 1.7 book - Part 86 of 196
The Ring programming language version 1.7 book - Part 86 of 196The Ring programming language version 1.7 book - Part 86 of 196
The Ring programming language version 1.7 book - Part 86 of 196
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 
Tool sdl2pml
Tool sdl2pmlTool sdl2pml
Tool sdl2pml
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdf
 
Cpp11 sample linux
Cpp11 sample linuxCpp11 sample linux
Cpp11 sample linux
 
FIFOPt
FIFOPtFIFOPt
FIFOPt
 

More from briancrawford30935

You have collected the following documents (unstructured) and pl.docx
You have collected the following documents (unstructured) and pl.docxYou have collected the following documents (unstructured) and pl.docx
You have collected the following documents (unstructured) and pl.docxbriancrawford30935
 
You have been working as a technology associate the information .docx
You have been working as a technology associate the information .docxYou have been working as a technology associate the information .docx
You have been working as a technology associate the information .docxbriancrawford30935
 
You have chosen to join WHO. They are particularly interested in.docx
You have chosen to join WHO. They are particularly interested in.docxYou have chosen to join WHO. They are particularly interested in.docx
You have chosen to join WHO. They are particularly interested in.docxbriancrawford30935
 
You have been tasked to present at a town hall meeting in your local.docx
You have been tasked to present at a town hall meeting in your local.docxYou have been tasked to present at a town hall meeting in your local.docx
You have been tasked to present at a town hall meeting in your local.docxbriancrawford30935
 
You have been tasked as the health care administrator of a major hos.docx
You have been tasked as the health care administrator of a major hos.docxYou have been tasked as the health care administrator of a major hos.docx
You have been tasked as the health care administrator of a major hos.docxbriancrawford30935
 
You have been tasked to devise a program to address the needs of.docx
You have been tasked to devise a program to address the needs of.docxYou have been tasked to devise a program to address the needs of.docx
You have been tasked to devise a program to address the needs of.docxbriancrawford30935
 
You have been successful in your application for the position be.docx
You have been successful in your application for the position be.docxYou have been successful in your application for the position be.docx
You have been successful in your application for the position be.docxbriancrawford30935
 
You have been hired as a project management consultant by compan.docx
You have been hired as a project management consultant by compan.docxYou have been hired as a project management consultant by compan.docx
You have been hired as a project management consultant by compan.docxbriancrawford30935
 
You have been hired to manage a particular aspect of the new ad.docx
You have been hired to manage a particular aspect of the new ad.docxYou have been hired to manage a particular aspect of the new ad.docx
You have been hired to manage a particular aspect of the new ad.docxbriancrawford30935
 
You have been hired by Red Didgeridoo Technologies. They know th.docx
You have been hired by Red Didgeridoo Technologies. They know th.docxYou have been hired by Red Didgeridoo Technologies. They know th.docx
You have been hired by Red Didgeridoo Technologies. They know th.docxbriancrawford30935
 
You have been hired by TMI to design an application using shell scri.docx
You have been hired by TMI to design an application using shell scri.docxYou have been hired by TMI to design an application using shell scri.docx
You have been hired by TMI to design an application using shell scri.docxbriancrawford30935
 
You have been hired as the CSO (Chief Security Officer) for an org.docx
You have been hired as the CSO (Chief Security Officer) for an org.docxYou have been hired as the CSO (Chief Security Officer) for an org.docx
You have been hired as the CSO (Chief Security Officer) for an org.docxbriancrawford30935
 
You have been hired to evaluate the volcanic hazards associated .docx
You have been hired to evaluate the volcanic hazards associated .docxYou have been hired to evaluate the volcanic hazards associated .docx
You have been hired to evaluate the volcanic hazards associated .docxbriancrawford30935
 
You have been hired as an assistant to the public health officer for.docx
You have been hired as an assistant to the public health officer for.docxYou have been hired as an assistant to the public health officer for.docx
You have been hired as an assistant to the public health officer for.docxbriancrawford30935
 
You have been engaged to develop a special calculator program. T.docx
You have been engaged to develop a special calculator program. T.docxYou have been engaged to develop a special calculator program. T.docx
You have been engaged to develop a special calculator program. T.docxbriancrawford30935
 
You have now delivered the project to your customer ahead of schedul.docx
You have now delivered the project to your customer ahead of schedul.docxYou have now delivered the project to your customer ahead of schedul.docx
You have now delivered the project to your customer ahead of schedul.docxbriancrawford30935
 
You have now delivered the project to your customer. The project was.docx
You have now delivered the project to your customer. The project was.docxYou have now delivered the project to your customer. The project was.docx
You have now delivered the project to your customer. The project was.docxbriancrawford30935
 
You have now experienced the work of various scholars, artists and m.docx
You have now experienced the work of various scholars, artists and m.docxYou have now experienced the work of various scholars, artists and m.docx
You have now experienced the work of various scholars, artists and m.docxbriancrawford30935
 
You have learned that Mr. Moore does not drink alcohol in the mornin.docx
You have learned that Mr. Moore does not drink alcohol in the mornin.docxYou have learned that Mr. Moore does not drink alcohol in the mornin.docx
You have learned that Mr. Moore does not drink alcohol in the mornin.docxbriancrawford30935
 
You have been hired by a large hospitality firm (e.g., Marriot.docx
You have been hired by a large hospitality firm (e.g., Marriot.docxYou have been hired by a large hospitality firm (e.g., Marriot.docx
You have been hired by a large hospitality firm (e.g., Marriot.docxbriancrawford30935
 

More from briancrawford30935 (20)

You have collected the following documents (unstructured) and pl.docx
You have collected the following documents (unstructured) and pl.docxYou have collected the following documents (unstructured) and pl.docx
You have collected the following documents (unstructured) and pl.docx
 
You have been working as a technology associate the information .docx
You have been working as a technology associate the information .docxYou have been working as a technology associate the information .docx
You have been working as a technology associate the information .docx
 
You have chosen to join WHO. They are particularly interested in.docx
You have chosen to join WHO. They are particularly interested in.docxYou have chosen to join WHO. They are particularly interested in.docx
You have chosen to join WHO. They are particularly interested in.docx
 
You have been tasked to present at a town hall meeting in your local.docx
You have been tasked to present at a town hall meeting in your local.docxYou have been tasked to present at a town hall meeting in your local.docx
You have been tasked to present at a town hall meeting in your local.docx
 
You have been tasked as the health care administrator of a major hos.docx
You have been tasked as the health care administrator of a major hos.docxYou have been tasked as the health care administrator of a major hos.docx
You have been tasked as the health care administrator of a major hos.docx
 
You have been tasked to devise a program to address the needs of.docx
You have been tasked to devise a program to address the needs of.docxYou have been tasked to devise a program to address the needs of.docx
You have been tasked to devise a program to address the needs of.docx
 
You have been successful in your application for the position be.docx
You have been successful in your application for the position be.docxYou have been successful in your application for the position be.docx
You have been successful in your application for the position be.docx
 
You have been hired as a project management consultant by compan.docx
You have been hired as a project management consultant by compan.docxYou have been hired as a project management consultant by compan.docx
You have been hired as a project management consultant by compan.docx
 
You have been hired to manage a particular aspect of the new ad.docx
You have been hired to manage a particular aspect of the new ad.docxYou have been hired to manage a particular aspect of the new ad.docx
You have been hired to manage a particular aspect of the new ad.docx
 
You have been hired by Red Didgeridoo Technologies. They know th.docx
You have been hired by Red Didgeridoo Technologies. They know th.docxYou have been hired by Red Didgeridoo Technologies. They know th.docx
You have been hired by Red Didgeridoo Technologies. They know th.docx
 
You have been hired by TMI to design an application using shell scri.docx
You have been hired by TMI to design an application using shell scri.docxYou have been hired by TMI to design an application using shell scri.docx
You have been hired by TMI to design an application using shell scri.docx
 
You have been hired as the CSO (Chief Security Officer) for an org.docx
You have been hired as the CSO (Chief Security Officer) for an org.docxYou have been hired as the CSO (Chief Security Officer) for an org.docx
You have been hired as the CSO (Chief Security Officer) for an org.docx
 
You have been hired to evaluate the volcanic hazards associated .docx
You have been hired to evaluate the volcanic hazards associated .docxYou have been hired to evaluate the volcanic hazards associated .docx
You have been hired to evaluate the volcanic hazards associated .docx
 
You have been hired as an assistant to the public health officer for.docx
You have been hired as an assistant to the public health officer for.docxYou have been hired as an assistant to the public health officer for.docx
You have been hired as an assistant to the public health officer for.docx
 
You have been engaged to develop a special calculator program. T.docx
You have been engaged to develop a special calculator program. T.docxYou have been engaged to develop a special calculator program. T.docx
You have been engaged to develop a special calculator program. T.docx
 
You have now delivered the project to your customer ahead of schedul.docx
You have now delivered the project to your customer ahead of schedul.docxYou have now delivered the project to your customer ahead of schedul.docx
You have now delivered the project to your customer ahead of schedul.docx
 
You have now delivered the project to your customer. The project was.docx
You have now delivered the project to your customer. The project was.docxYou have now delivered the project to your customer. The project was.docx
You have now delivered the project to your customer. The project was.docx
 
You have now experienced the work of various scholars, artists and m.docx
You have now experienced the work of various scholars, artists and m.docxYou have now experienced the work of various scholars, artists and m.docx
You have now experienced the work of various scholars, artists and m.docx
 
You have learned that Mr. Moore does not drink alcohol in the mornin.docx
You have learned that Mr. Moore does not drink alcohol in the mornin.docxYou have learned that Mr. Moore does not drink alcohol in the mornin.docx
You have learned that Mr. Moore does not drink alcohol in the mornin.docx
 
You have been hired by a large hospitality firm (e.g., Marriot.docx
You have been hired by a large hospitality firm (e.g., Marriot.docxYou have been hired by a large hospitality firm (e.g., Marriot.docx
You have been hired by a large hospitality firm (e.g., Marriot.docx
 

Recently uploaded

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 

Projeto1617_FaseFinalMakefileall simulador monitormoni.docx

  • 1. Projeto1617_FaseFinal/Makefile all: simulador monitor monitor: monitor.o gcc -Wall -g monitor.o -o monitor -lpthread monitor.o: monitor.c util.h unix.h gcc -c monitor.c simulador: simulador.o gcc -Wall -g simulador.o -o simulador -lpthread simulador.o: simulador.c util.h unix.h gcc -c simulador.c clean: rm *.o Projeto1617_FaseFinal/monitor.c #include <pthread.h> #include <string.h> #include "unix.h" #include "util.h" //apontador para o ficheiro onde será escrito o relatório da simulação FILE *relatorio; //variáveis globais para a estatística int num_fila_Piscina=0, num_fila_Toboga=0, num_Total_Clientes_Normais=0, num_Total_cli_Idoso_Crianca = 0, num_cli_normal=0, num_cli_Idoso_Crianca=0, desiste_espera=0, desiste_medo=0, num_utilizacoes_tbg1=0, num_utilizacoes_tbg2=0, num_utilizacoes_tbg3=0, num_utilizacoes_tbg4=0, num_utilizacoes_piscina=0,
  • 2. inicio_simulacao=0, fim_simulacao=0, soma_espera_normal=0, soma_espera_prio = 0, esperou_prio=0, esperou_normal=0; //variáveis globais para controlo de execução int corre=0, pausa=0; void mostra_estatistica() { if(corre && !pausa) printf(" 1. Estado atual: Simulacao a decorrer.n"); else { if(pausa) printf(" 1. Estado atual: Simulação em pausa.n"); else printf(" 1. Estado atual: Simulação terminada.n"); } printf(" 2. Tamanho atual da fila de espera Tobogães: %dn", num_fila_Toboga); printf(" 2. Tamanho atual da fila de espera Piscina: %dn", num_fila_Piscina); //printf(" 3. Tamanho atual da fila de espera para Clientes Prioritários: %dn", num_fila_crianca_idoso); //printf(" 4. Número atual de Carros: %dn", num_carros); printf(" 5. Clientes Normais: %dn", num_Total_Clientes_Normais); printf(" 6. Clientes Idosos/Criança: %dn", num_Total_cli_Idoso_Crianca); printf(" 7. Total de Clientes: %dn", num_Total_Clientes_Normais + num_Total_cli_Idoso_Crianca); printf(" 8. Desistências na Fila de espera: %dn", desiste_espera); printf(" 9. Desistências Por medo: %dn", desiste_medo);
  • 3. printf("10. Total de desistências: %dn", desiste_espera + desiste_medo); printf("11. Número de Clientes que foram ao Tobogã 1: %dn", num_utilizacoes_tbg1); printf("11. Número de Clientes que foram ao Tobogã 2: %dn", num_utilizacoes_tbg2); printf("11. Número de Clientes que foram ao Tobogã 3: %dn", num_utilizacoes_tbg3); printf("11. Número de Clientes que foram ao Tobogã 4: %dn", num_utilizacoes_tbg4); printf("11. Número de Clientes que foram á piscina: %dn", num_utilizacoes_piscina); if(esperou_normal) printf("12. Tempo médio de espera de Clientes Normais: %f minutosn",(float)soma_espera_normal/(float)esperou_normal); else printf("12. Tempo médio de espera de Clientes Normais: 0 minutosn"); if(esperou_prio) printf("13. Tempo médio de espera de Clientes Prioritários: %f minutosn",(float)(soma_espera_prio/esperou_prio)); else printf("13. Tempo médio de espera de Clientes Prioritários: 0 minutosn"); } //função que fica à escuta das mensagens do simulador void *escuta_comunicacao(void *arg) { int sockfd=*((int *) arg); int msg, tempo=0, num_comandos, id, tipo_cliente; char buffer[256],comando[20], atracao[20];//,utilizador[5],timestamp[11],;
  • 4. //ciclo que fica à espera de mensagens do simulador while(1) { if((msg=recv(sockfd, buffer, sizeof(buffer), 0)) <= 0) { if(msg < 0) perror("recv"); } else { buffer[msg]='0'; fprintf(relatorio,"%s", buffer); num_comandos = sscanf(buffer,"%d %s %d %d", &tempo, comando, &id, &tipo_cliente); if(num_comandos>0) { if(!strcmp(comando,"INICIO")) { inicio_simulacao = tempo; } else if(!strcmp(comando,"CHEGADA_PISCINA")) { num_fila_Piscina++; if(tipo_cliente) num_Total_cli_Idoso_Crianca++; else num_Total_Clientes_Normais++; } else if(!strcmp(comando,"CHEGADA_TOBOGA")) { num_fila_Toboga++;
  • 6. if(tipo_cliente) { soma_espera_prio += tempo; esperou_prio++; } else { soma_espera_normal += tempo; esperou_normal++; } } else if(!strcmp(comando,"EMBARQUE_PISCINA")) { num_utilizacoes_piscina++; num_fila_Piscina--; soma_espera_prio += tempo; esperou_prio++; } /*else if(!strcmp(comando,"ENTRA_EMBARQUE")) { if(tipo_cliente) { soma_espera_prio += tempo; esperou_prio++; } else { soma_espera_normal += tempo; esperou_normal++; } }*/ else if(!strcmp(comando,"DESISTE_EMBARQUE"))
  • 7. { desiste_medo++; } } } } return NULL; } //função principal do monitor int main(int argc, char *argv[]) { struct sockaddr_un serv_addr, cli_addr; int sockfd, servlen, newsockfd; int clilen=sizeof(cli_addr); char buffer[256]; char menu[512] = "----------------------------------n| comandos disponiveis no monitor|n--------------------------------- -n| inicio - Comecar simulacao |n| pausa - Pausar simulacao |n| retomar - Retomar simulacao |n| estado - Estado da simulacao |n| sair - Sair do monitor |n--------------------- -------------n"; //Criacao do socket UNIX if((sockfd=socket(AF_UNIX, SOCK_STREAM, 0)) < 0) perror("cant open socket stream"); serv_addr.sun_family=AF_UNIX; strcpy(serv_addr.sun_path, UNIXSTR_PATH); servlen=strlen(serv_addr.sun_path)+sizeof(serv_addr.sun_f amily); unlink(UNIXSTR_PATH); if(bind(sockfd, (struct sockaddr *) &serv_addr, servlen) < 0) perror("cant bind local address");
  • 8. listen(sockfd, 1); if((newsockfd=accept(sockfd, (struct sockaddr *) &cli_addr, &clilen)) < 0) perror("accept error"); //criacao da tarefa que ira tratar da comunicação tipo_cliente o simulador pthread_t thread; pthread_create(&thread, NULL, &escuta_comunicacao, &newsockfd); //Ciclo que espera pela informacao vinda da consola printf("%s",menu); unlink("relatorio.log"); relatorio=fopen("relatorio.log", "a"); do { fgets(buffer, sizeof(buffer), stdin); if(send(newsockfd, buffer, sizeof(buffer), 0) == -1) { perror("send"); exit(1); } if(!strcmp (buffer, "inicion")) { corre=1; pausa=0; } if(!strcmp (buffer, "pausan")) { pausa=1;
  • 9. printf("Simulacao em pausa - "retomar" para continuarn"); } if(!strcmp (buffer, "retomarn")) { pausa=0; } if(!strcmp (buffer, "estadon")) { mostra_estatistica(); } } while(strcmp (buffer, "sairn")); corre = 0; pausa = 0; printf("nExecução terminou.nn"); mostra_estatistica(); fclose(relatorio); close(sockfd); return 0; } Projeto1617_FaseFinal/sim.conf INICIO_FINAL=0 TEMPO_SIMULACAO=3 TEMPO_MEDIO_CHEGADA_CLIENTES=1 PROB_DESISTE_ESPERA=10 PROB_DESISTE-ESPERA_IDOSO_CRIANCA=5 PROB_DESISTE_MEDO=5 PROB_DESISTE_MEDO_IDOSO_CRIANCA=2 TEMPO_VIAGEM=10
  • 10. NUMERO_TOBOGAS=4 CAPACIDADE_UM_TOBOGA=1 Projeto1617_FaseFinal/simulador.c /**************************************************** ***************************************************** *** Sistemas Operativos - Projeto Pratico 2016/2017 - Simulacao de um Parque Aquático Docentes: Eduardo Marques, Luís Gaspar Alunos: ***************************************************** ***************************************************** **/ #include <time.h> #include <stdlib.h> #include <semaphore.h> #include <string.h> #include <pthread.h> #include <signal.h> #include "unix.h" #include "util.h" /**************************************************** ***************************************************** *** * variaveis globais * descricao: podem ser acedidas em qualquer momento e local durante a execucao do simulador *****************************************************
  • 11. ***************************************************** **/ sem_t zona_embarqueToboga_prio; sem_t zona_embarqueToboga; sem_t lugares_Piscina; sem_t tobogas_livres; sem_t sai_atracao; sem_t filaEsperaPiscina; sem_t sai_piscina; sem_t controla_toboga; sem_t pode_entrar_toboga; pthread_mutex_t mutex; int num_cliente, num_toboga_ocupados, fila_prio, carros_em_servico, num_toboga; int tempoEntra; int nr_toboga; char atracao [20]; time_t start; struct sockaddr_un serv_addr; int sockfd, servlen; //variaveis com informacao da configuracao int INICIO_FINAL, TEMPO_SIMULACAO, TEMPO_MEDIO_CHEGADA_CLIENTES, PROB_DESISTE_ESPERA, PROB_DESISTE_ESPERA_PRIO, PROB_DESISTE_MEDO, PROB_DESISTE_MEDO_PRIO, TEMPO_VIAGEM, NUMERO_TOBOGAS, CAPACIDADE_UM_TOBOGA; int corre=0,pausa=0,controlo_pausa;
  • 12. char printA[20] = "Toboga 1"; char printB[20] = "Toboga 2"; char printC[20] = "Toboga 3"; char printD[20] = "Toboga 4"; char printE[20] = "Piscina"; /**************************************************** ***************************************************** *** * funcao: tarefa_cliente_IdosoCrianca * argumentos: ponteiro do tipo void * devolve: ponteiro do tipo void * descricao: comportamento de uma thread que representa um cliente idoso ou criança ***************************************************** ***************************************************** **/ void *tarefa_cliente_IdosoCrianca(void *ptr) { pthread_detach(pthread_self()); //detach para devolver os recursos ao sistema -- pthread_self() retorna o id da tarefa int g, entra_espera; char ImprimeAtracao[20]; time_t temp_i; int tem_esp = rand()%10; // entre 0 e 10 minutos de espera char buffer_c[256]; sem_wait(&filaEsperaPiscina); //Se tiver lugar na fila de espera entra nesta, senão não faz nada pthread_mutex_lock(&mutex); //só uma tarefa é que pode entrar aqui, reserva os recuros - mais ngm pode aceder int num_cli_Idoso_Crianca = num_cliente++; fila_prio++; printf("O cliente %d chegou a fila de espera da piscina.n", num_cli_Idoso_Crianca);
  • 13. sprintf(buffer_c, "%d CHEGADA_PISCINA %d 1n", (int)time(0), num_cli_Idoso_Crianca); send(sockfd,buffer_c,sizeof(buffer_c),0); temp_i = time(0); if((int)(time(0) - temp_i) > tem_esp) { g = rand()%100; if(g <= PROB_DESISTE_ESPERA_PRIO) { if(tem_esp == 1) printf("O cliente %d desistiu da fila de espera da piscina ao fim de %d minuto a espera.n", num_cli_Idoso_Crianca, tem_esp); else printf("O cliente %d desistiu da fila de espera da piscina ao fim de %d minutos a espera.n", num_cli_Idoso_Crianca, tem_esp); sprintf(buffer_c, "%d DESISTE_FILA_PISCINA %d 1n", (int)time(0), num_cli_Idoso_Crianca); send(sockfd,buffer_c,sizeof(buffer_c),0); fila_prio--; sem_post(&filaEsperaPiscina); pthread_mutex_unlock(&mutex); return NULL; } } //desistencia g = rand()%100; if(g <= PROB_DESISTE_MEDO_PRIO) { printf("O cliente %d desistiu porque ficou com
  • 14. medo.n", num_cli_Idoso_Crianca); sprintf(buffer_c, "%d DESISTE_EMBARQUEn", (int)time(0)); send(sockfd,buffer_c,sizeof(buffer_c),0); sem_post(&filaEsperaPiscina); pthread_mutex_unlock(&mutex); return NULL; } pthread_mutex_unlock(&mutex); //liberta os recursos, o cliente não desistiu da fila de espera - quer entrar sem_wait(&lugares_Piscina); //vericar se existe ou não lugares disponíveis na piscian (50) sem_post(&filaEsperaPiscina); //se existir sai da fila de espera da piscina e entra nesta pthread_mutex_lock(&mutex); // strcpy(ImprimeAtracao, atracao); printf("O cliente %d entrou na piscina.n", num_cli_Idoso_Crianca); sprintf(buffer_c, "%d EMBARQUE_PISCINA %d %dn", (int)(time(0)-temp_i), num_cli_Idoso_Crianca); send(sockfd,buffer_c,sizeof(buffer_c),0); pthread_mutex_unlock(&mutex); sem_wait(&sai_piscina); //semáforo para ver se o cliente quer ou não sair da piscina. Se não quiser fica aqui à espera pthread_mutex_lock(&mutex); printf("O cliente %d saiu da piscina.n", num_cli_Idoso_Crianca); sprintf(buffer_c, "%d DESEMBARQUE %d %dn", (int)time(0), num_cli_Idoso_Crianca); send(sockfd,buffer_c,sizeof(buffer_c),0); sem_post(&lugares_Piscina);
  • 15. pthread_mutex_unlock(&mutex); return NULL; } /**************************************************** ***************************************************** *** * funcao: tarefa_cliente * argumentos: ponteiro do tipo void * devolve: ponteiro do tipo void * descricao: comportamento de uma thread que representa um cliente nao prioritario ***************************************************** ***************************************************** **/ void *tarefa_cliente(void *ptr) { pthread_detach(pthread_self()); int g; char ImprimeAtracao[20]; time_t temp_i; char buffer_c[256]; int tempo_piscina = rand()%100; int tem_esp = rand()%10; // entre 0 e 10 minutos de espera int prob_ir_atracao = rand()%100; //para tratar da saida do cliente da piscina, assinala que ele quer sair da piscina if (tempo_piscina>=1 && tempo_piscina <= 15){ sem_post(&sai_piscina); }else{ if(prob_ir_atracao<= 80){
  • 16. pthread_mutex_lock(&mutex); int num_cli = num_cliente++; printf("O cliente %d chegou a fila de espera dos tobogãs.n", num_cli); sprintf(buffer_c, "%d CHEGADA_TOBOGA %d 0n", (int)time(0), num_cli); send(sockfd,buffer_c,sizeof(buffer_c),0); pthread_mutex_unlock(&mutex); sem_wait(&zona_embarqueToboga); pthread_mutex_lock(&mutex); //desistencia por tempo if((int)(time(0) - temp_i) > tem_esp) { g = rand()%100; if(g <= PROB_DESISTE_ESPERA) { if(tem_esp == 1) printf("O cliente %d desistiu da fila de espera dos tobogãs ao fim de %d minuto a espera.n", num_cli, tem_esp); else printf("O cliente %d desistiu da fila de espera dos tobogãs ao fim de %d minutos a espera.n", num_cli, tem_esp); sprintf(buffer_c, "%d DESISTE_FILA_TOBOGA %d 0n", (int)time(0), num_cli); send(sockfd,buffer_c,sizeof(buffer_c),0); sem_post(&zona_embarqueToboga); pthread_mutex_unlock(&mutex);
  • 17. return NULL; } } printf("O cliente %d entrou na zona de embarque dos tobogãs.n",num_cli); sprintf(buffer_c, "%d ENTRA_EMBARQUE %d 0n", time(0), num_cli); send(sockfd,buffer_c,sizeof(buffer_c),0); //desistencia por medo g = rand()%100; if(g <= PROB_DESISTE_MEDO) { printf("O cliente %d desistiu da fila de espera dos tobogãs porque ficou com medo.n", num_cli); sprintf(buffer_c, "%d DESISTE_EMBARQUEn", (int)time(0)); send(sockfd,buffer_c,sizeof(buffer_c),0); sem_post(&zona_embarqueToboga); pthread_mutex_unlock(&mutex); return NULL; } pthread_mutex_unlock(&mutex); sem_wait(&tobogas_livres); sem_post(&zona_embarqueToboga); //assinala que ficou um lugar vago na zona de embarque dos tobogas pthread_mutex_lock(&mutex); // if(nr_toboga >=0 && nr_toboga<4) // nr_toboga++; // strcpy(ImprimeAtracao, atracao); printf("O cliente %d entrou no tobogã %d.n", num_cli,
  • 18. nr_toboga); //O cliente entrou no tobogã X sprintf(buffer_c, "%d EMBARQUE %d %dn", (int)(time(0)-temp_i), num_cli, nr_toboga); send(sockfd,buffer_c,sizeof(buffer_c),0); num_toboga_ocupados++; pthread_mutex_unlock(&mutex); sem_wait(&sai_atracao); //para já ver se todos sairam pthread_mutex_lock(&mutex); printf("O cliente %d saiu da zona de tobogãs.n", num_cli); sprintf(buffer_c, "%d DESEMBARQUE %d %dn", (int)time(0), num_cli, nr_toboga); send(sockfd,buffer_c,sizeof(buffer_c),0); pthread_mutex_unlock(&mutex); } else{ sem_wait(&filaEsperaPiscina); //Se tiver lugar na fila de espera entra nesta, senão não faz nada pthread_mutex_lock(&mutex); //só uma tarefa é que pode entrar aqui, reserva os recuros - mais ngm pode aceder int num_cli_Idoso_Crianca = num_cliente++; fila_prio++; printf("O cliente %d chegou a fila de espera da piscina.n", num_cli_Idoso_Crianca); sprintf(buffer_c, "%d CHEGADA_PISCINA %d 1n", (int)time(0), num_cli_Idoso_Crianca); send(sockfd,buffer_c,sizeof(buffer_c),0); //temp_i = time(0); if((int)(time(0) - temp_i) > tem_esp) { g = rand()%100;
  • 19. if(g <= PROB_DESISTE_ESPERA_PRIO) { if(tem_esp == 1) printf("O cliente %d desistiu da fila de espera da piscina ao fim de %d minuto a espera.n", num_cli_Idoso_Crianca, tem_esp); else printf("O cliente %d desistiu da fila de espera da piscina ao fim de %d minutos a espera.n", num_cli_Idoso_Crianca, tem_esp); sprintf(buffer_c, "%d DESISTE_FILA_PISCINA %d 1n", (int)time(0), num_cli_Idoso_Crianca); send(sockfd,buffer_c,sizeof(buffer_c),0); fila_prio--; sem_post(&filaEsperaPiscina); pthread_mutex_unlock(&mutex); return NULL; } } //desistencia g = rand()%100; if(g <= PROB_DESISTE_MEDO_PRIO) { printf("O cliente %d desistiu porque ficou com medo.n", num_cli_Idoso_Crianca); sprintf(buffer_c, "%d DESISTE_EMBARQUEn", (int)time(0)); send(sockfd,buffer_c,sizeof(buffer_c),0); sem_post(&filaEsperaPiscina); pthread_mutex_unlock(&mutex); return NULL; }
  • 20. pthread_mutex_unlock(&mutex); //liberta os recursos, o cliente não desistiu da fila de espera - quer entrar sem_wait(&lugares_Piscina); //vericar se existe ou não lugares disponíveis na piscian (50) sem_post(&filaEsperaPiscina); //se existir sai da fila de espera da piscina e entra nesta pthread_mutex_lock(&mutex); // strcpy(ImprimeAtracao, atracao); printf("O cliente %d entrou na piscina.n", num_cli_Idoso_Crianca); sprintf(buffer_c, "%d EMBARQUE_PISCINA %d %dn", (int)(time(0)-temp_i), num_cli_Idoso_Crianca); send(sockfd,buffer_c,sizeof(buffer_c),0); pthread_mutex_unlock(&mutex); sem_wait(&sai_piscina); //semáforo para ver se o cliente quer ou não sair da piscina. Se não quiser fica aqui à espera pthread_mutex_lock(&mutex); printf("O cliente %d saiu da piscina.n", num_cli_Idoso_Crianca); sprintf(buffer_c, "%d DESEMBARQUE %d %dn", (int)time(0), num_cli_Idoso_Crianca); send(sockfd,buffer_c,sizeof(buffer_c),0); sem_post(&lugares_Piscina); pthread_mutex_unlock(&mutex); return NULL; } } return NULL; } /**************************************************** ***************************************************** ***
  • 21. * funcao: tarefa_atracao * argumentos: ponteiro do tipo void * devolve: ponteiro do tipo void * descricao: comportamento de uma thread que representa um cliente prioritario ***************************************************** ***************************************************** **/ void *tarefa_atracao(void *ptr) { pthread_detach(pthread_self()); int i; char printAtracao[20]; char buffer_c[256]; time_t hora_partida, hora_i; char variavel[20] = "atracao"; nr_toboga ++; void inicia_viagem() { printf("O tobogã %d começou.n", nr_toboga); sprintf(buffer_c, "%d ARRANQUE %dn", (int)time(0), nr_toboga); send(sockfd,buffer_c,sizeof(buffer_c),0); hora_partida = time(0); pthread_mutex_unlock(&mutex); while((int)(time(0) - hora_partida) < TEMPO_VIAGEM); // tempo de viagem pthread_mutex_lock(&mutex); printf("O tobogã %d terminou e está disponível aos
  • 22. proximos utilizadores.n", nr_toboga); sprintf(buffer_c, "%d FINAL_VIAGEM %dn", (int)time(0), nr_toboga); send(sockfd,buffer_c,sizeof(buffer_c),0); sem_post(&sai_atracao); //diz que todos os clientes sairam (1) num_toboga_ocupados= 0; // for(i=0;i<NUMERO_TOBOGAS; i++){ // sem_post(&tobogas_livres); //indica que os tobogãs vão estar vazios // } nr_toboga = 0; } while(1) { pthread_mutex_lock(&mutex); printf("O tobogã %d está disponível.n", nr_toboga); sprintf(buffer_c, "%d DISPONIVEL %dn", (int)time(0), nr_toboga); send(sockfd,buffer_c,sizeof(buffer_c),0); sem_post(&tobogas_livres); pthread_mutex_unlock(&mutex); int i; //sem_getvalue(&zona_embarqueToboga, &i);
  • 23. hora_i = time(0); if(time(0) > start + TEMPO_SIMULACAO) { usleep(100000); pthread_mutex_lock(&mutex); if(num_toboga_ocupados == 0) { printf("O parque ja fechou e nao tem clientes em espera.n"); printf("O tobogã %d vai ser limpo.n", nr_toboga); carros_em_servico--; pthread_mutex_unlock(&mutex); return NULL; } printf("O tobogã %d comecou.n", nr_toboga); sprintf(buffer_c, "%d ARRANQUE %dn", (int)time(0), nr_toboga); send(sockfd,buffer_c,sizeof(buffer_c),0); hora_partida = time(0); pthread_mutex_unlock(&mutex); while((int)(time(0) - hora_partida) < TEMPO_VIAGEM); // tempo de viagem pthread_mutex_lock(&mutex); printf("O tobogã %d fechou.n", nr_toboga); sprintf(buffer_c, "%d FINAL_VIAGEM %dn", (int)time(0), nr_toboga); send(sockfd,buffer_c,sizeof(buffer_c),0); for(i = 0; i < NUMERO_TOBOGAS; i++)
  • 24. sem_post(&sai_atracao); } else { while(num_toboga_ocupados < NUMERO_TOBOGAS && time(0) < start + TEMPO_SIMULACAO); //enquanto todos os tobogãs não estiverem ocupados não vai iniciar a sua atividade //é incrementado na tarefa clienteNormal pthread_mutex_lock(&mutex); if(num_toboga_ocupados == NUMERO_TOBOGAS) //se todos os tobogãs estiverem atualmente ocupados, vai iniciar a sua atividade (de todos) { pthread_mutex_unlock(&mutex); usleep(100000); pthread_mutex_lock(&mutex); inicia_viagem(); } else { pthread_mutex_unlock(&mutex); usleep(100000); pthread_mutex_lock(&mutex); if(num_toboga_ocupados == 0) { printf("O parque ja fechou e nao tem clientes em espera.n"); printf("O tobogã %d vai ser arrumado.n", nr_toboga); carros_em_servico--; pthread_mutex_unlock(&mutex); return NULL;
  • 25. } inicia_viagem(); } } pthread_mutex_unlock(&mutex); } return NULL; } //Funcao que trata dos pedidos vindos do Monitor void *recebe_comandos_monitor(void *arg) { struct sockaddr_un cli_addr; int done, n, id; int sockfd=*((int *) arg), clilen=sizeof(cli_addr); char buffer[256]; //Ciclo que fica a espera dos pedidos dos Monitor, para lhe dar resposta adequada while(1) { done=0; if((n=recv(sockfd, buffer, sizeof(buffer), 0)) <= 0) { if(n < 0) perror("recv error"); done=1; } buffer[n]='0'; if(!strcmp(buffer, "terminan")) { corre=0;
  • 26. exit(1); } else { if(!strcmp(buffer, "inicion")) corre = 1; if(!strcmp(buffer, "pausan")) pausa = 1; if(!strcmp(buffer, "retomarn")) pausa = 0; } } return NULL; } int main(int argc, char *argv[]) { srand(time(NULL)); num_cliente=1; //atracao = 1; num_toboga_ocupados = 0; fila_prio = 0; if(argc<2) { printf("Falta o ficheiro de configuração. Não é possível continuar."); return 1; } else { //interpretacao do ficheiro de configuraçao
  • 27. int *conf = leitura_configuracao(argv[1]); INICIO_FINAL = conf[0]; TEMPO_SIMULACAO = conf[1]; TEMPO_MEDIO_CHEGADA_CLIENTES = conf[2]; PROB_DESISTE_ESPERA = conf[3]; PROB_DESISTE_ESPERA_PRIO = conf[4]; PROB_DESISTE_MEDO = conf[5]; PROB_DESISTE_MEDO_PRIO = conf[6]; TEMPO_VIAGEM = conf[7]; NUMERO_TOBOGAS = conf[8]; CAPACIDADE_UM_TOBOGA = conf[9]; // Inicializar semáforos sem_init (&zona_embarqueToboga, 0, 10); sem_init (&pode_entrar_toboga, 0, 0); sem_init (&lugares_Piscina, 0, 50); sem_init (&sai_atracao, 0, 0); sem_init (&tobogas_livres, 0, 0); //semáforo para indicar se os tobogãs estão (0) ou não vazios (1) sem_init (&filaEsperaPiscina,0,10); sem_init (&sai_piscina,0,0); sem_init (&controla_toboga,0,1); //criacao do socket e ligação if((sockfd=socket(AF_UNIX, SOCK_STREAM, 0)) < 0) perror("Simulador: cant open socket stream"); serv_addr.sun_family=AF_UNIX; strcpy(serv_addr.sun_path, UNIXSTR_PATH);
  • 28. servlen=strlen(serv_addr.sun_path)+sizeof(serv_addr.sun_f amily); if(connect(sockfd, (struct sockaddr *) &serv_addr, servlen) < 0) perror("connect error"); //Criacao da tarefa que ira tratar dos pedidos enviados pelo Monitor pthread_t thread; pthread_create(&thread, NULL, &recebe_comandos_monitor, &sockfd); while(!corre); int i, r, h; char buffer[256]; carros_em_servico = CAPACIDADE_UM_TOBOGA; start = time(0); sprintf(buffer, "%d INICIOn", (int)start); send(sockfd,buffer,sizeof(buffer),0); TEMPO_SIMULACAO *= 60; //thread atracao for(i = 0; i < 4; i++) { num_toboga=1; pthread_create(&thread, NULL, &tarefa_atracao, &sockfd); //usleep(10000); } while((int)(time(0) - start) < TEMPO_SIMULACAO) {
  • 29. r = rand()%100; if (r <= 50) { //Criacao da tarefa de um cliente prioritário pthread_create(&thread, NULL, &tarefa_cliente_IdosoCrianca, &sockfd); } else { //Criacao da tarefa de um cliente normal pthread_create(&thread, NULL, &tarefa_cliente, &sockfd); } r = rand()%1; h = rand()%3; h = h * 100000; if(r == 0) h = 0 - h; usleep((TEMPO_MEDIO_CHEGADA_CLIENTES*100000 0) + h); if(pausa) { pthread_mutex_lock(&mutex); controlo_pausa = 1; } while(pausa); if(controlo_pausa) { pthread_mutex_unlock(&mutex); controlo_pausa = 0; } }
  • 30. while(carros_em_servico>0); printf("nO parque já fechou e não existem mais clientes em espera.n"); printf("nSimulação terminada.n"); sprintf(buffer,"%d FIM n",(int) time(0)); send(sockfd,buffer,sizeof(buffer),0); while(corre); close(sockfd); } return 0; } Projeto1617_FaseFinal/unix.h #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #define UNIXSTR_PATH "./s.unixstr" #define UNIXDG_PATH "/tmp/s.unixdgx" #define UNIXDG_TMP "/tmp/dgXXXXsdsXX" Projeto1617_FaseFinal/util.h #include <stdio.h> #include <stdlib.h> #include <unistd.h>
  • 31. #include <time.h> //#define MAXLINE 512 int *leitura_configuracao(char *file) { int *a = (int *)malloc(sizeof(int) * 10); FILE *fp = fopen (file, "r"); if(fp == NULL ) { printf("Nao e possivel abrir o ficheiro de configuracao.n"); abort(); } int num, i=0; char name[100], buff[500]; while (fgets( buff, sizeof buff, fp) != NULL) {
  • 32. if(sscanf(buff, "%[^=]=%d", name, &num) == 2) a[i++]=num; } fclose(fp); return a; } Running head: ATHLETICS SUPREME COMPANY 1 ATHLETICS SUPREME COMPANY 2 Athletics supreme company Name Institution Overview of athletics supreme Athletics supreme has majored in providing equipments designed for use by the amateur athlete. The company produces quality and safe equipments even if the consumers’ are amatures.this equipments prove to express devolution in the amateur respective sports which has enabled athletic supreme
  • 33. capture the market share through its way of branding when it comes to amateur adult team sport. In most cases, a large market opportunity share is neglected when it comes to adolescent sport which is the very core of athletic supreme and ventured into the manufacture of safety helmets for the kids and other smaller equipments used by kids only which has lead the company to building of brands which are entertaining while providing safety to the users (Smith, Watts, & Dagneau, 2015). For companies like puma and adidas for instance these brands were sold primarily in departmental stores but now its evident that outlet malls provide sportswear to companies and even creation of competition is upcoming and from different companies and even stores. Market Research Strategies When it comes to market, the company needs to analyze and compare brands selling and products that these companies are selling. The company also needs to find that consumer needs that is not met and also identify gaps in order for it to further understand the market and placement of the pricing strategies. It also needs to perform qualitative and quantitative examinations of the target market details.sttrategies needed to pull data from all available sources to further identify their strong competitors and also data analysis will help athletic supreme company to locate new small companies emerging and reviews of their profit and losses to use the data to the companies advantage to gain insight not only into market potential but also in terms of the consumer wants too.unsuccessfull and successfulness trials in competition allows the athletic supreme to further identify what they want their sportswear and brands to convey to any customer keeping in mind that the customer needs and wants are not necessarily the same (LeRoy, 2015). Product Strategies Athletics supreme company being already an established manufacturer of new sportswear lines needed and safe sport
  • 34. gears to be marketed and create a new link between safety and attire, advertisement could accomplish this but it seems complicated since the company is emerging in adolescent sport arena. Its best to markets these attires which are similar to the big name brands kids associate and this is done through the colour and design creation that is appealing to the youthful eye in the solid market. Mature adult sport simply needs to display new attires and gears they are already familiar with which will be able to be used easily with no complications in the event of use or competition. Safety being a much harder area when it comes to trust, attire is based on design demand in maintaining the companies safety quality through attire purchase which eventually becomes the second habit of the customer (Smith, Watts, & Dagneau, 2015). Place Strategies Being that the athletics supreme company unwillingness to compromise its core base, the gear and quality of safety remains in their original state with no interference the company’s product line should not be located togherether instead they should be broken down into smaller gear facilities which will be the premier supplier of attires while the main facility will be able to accommodate any additional order without compromising quality through unnecessary shifting from one facility to the other in search of accommodation location. Maintaining of staff at the new attire facility will enable a structure and historical knowledge base. The company needs additional software components to its ordering system in order to allow gears and attires to be ordered and shipped on time and in their complete state (LeRoy, 2015). Pricing Strategies In order for athletics supreme company to promote the new attire lines, it should include sample dialogues in the equipments orders shipped including giving the customers discounts on the attires purchased initially even though the
  • 35. equipment prices will need to be left at their original price so as to reflect the unchanged product (Smith, Watts, & Dagneau, 2015). Customers who are likely to combine products and bring customers need to be given discounts as a way of appreciation. Pricing should be competitive with similar companies but should not exceed the competition price mark set up by the Deutsche Bahn (DB) caps. since caps are all money-makers mechanisms, the products needs to be prised accordingly with no problem since no companies products wants to be victims when it comes to prizing. Products cannot be under prized since they have the potential to make profit to the company. In order to get the consumers attention, sleeved shirts should be at least or just below the competitors pricing in order to give athletics supreme company a slight advantage. Through capitalizing on the companies sport equipments and its safety in the larger market like the baseball for instance is the leading market and the company should gain attention through offering lower priced shirts and suggest complimenting caps (LeRoy, 2015). Promotional Strategies With regards to advancement, the organization needs to utilize a specialist to decide the necessities of the encompassing markets and how they can best address these issues with advancement as a forceful deal limited time procedure. Through people group mindfulness and writing the organization can run battles on radios stations to concentrate on the regular games furthermore take the items to the general population enthusiastically as a method for advancing the organization and additionally the client. This ought to be done to illuminate the clients of the new market items and their constrained ecological effects. Being that most adolescent are presently via web-based networking media, the organization can utilize this to advance the organization's items through posting them via web-based networking media furthermore commercials through televisions, posters, flyers, newspapers and magazines.
  • 36. Competitive advantage Games finest necessities to accumulate knowledge in rivalry with the goal for them to have the capacity to contend as required. They initially need to recognize their objective and be inventive in discovering the opposition sections they are in, what the clients purchase from the contenders, what advantages are there in rivalry, and any data they can discover on evaluating, administrations offered, rivalry, and limited time procedures. This should effortlessly be possible through going to the stores or locales, converse with the contenders’ clients and merchants to get data and utilize them further bolstering your good fortune (Smith, Watts, and Dagneau, 2015). Being that games incomparable has an officially settled market it likewise needs to put measures to guarantee that it remains in the market and even progress globally. In order to build up its clothing market all around, the organization needs to comprehend the market conduct by doing research in the areas in inquiries and set up work systems which are probably going to work in those local markets and in addition the worldwide markets which have a tendency to contrast much of the time. This could be as far as framework which may influence the generation of items and shipment which has its focal points and burdens. Conclusion It is important to keep an eye on what the people like to wear or what keeps the customers comfortable. Being a producer you need to keep more emphasis on the product you are producing because the product may be eye catching but to tight to fit the intended customer or even to big to fit the responsible party’s when it comes to attire one should now the condition which is likely to make the customer buy and wear the companies products. Research is a key factor when it comes to decision making at the last stages before the production process starts.
  • 37. References Smith, P. B., Watts, N. A., & Dagneau, F. O. (2015). U.S. Patent No. 9,174,111. Washington, DC: U.S. Patent and Trademark Office. LeRoy, M. H. (2015). Courts and the Future of Athletic Labour in College Sports. Ariz. L. Rev., 57, 475.