version 1.2, 2010/01/27 22:22:15
|
version 1.22, 2011/04/11 12:10:10
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.10 |
RPL/2 (R) version 4.1.0.prerelease.0 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 20
|
Line 20
|
*/ |
*/ |
|
|
|
|
#include "rpl.conv.h" |
#include "rpl-conv.h" |
|
|
|
|
/* |
/* |
Line 846 instruction_poke(struct_processus *s_eta
|
Line 846 instruction_poke(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
# ifndef SEMAPHORES_NOMMES |
!= 0) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
|
# else |
|
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
# endif |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
while((longueur_ecriture = write_atomic(s_etat_processus, |
(*(*((struct_processus_fils *) |
(*(*((struct_processus_fils *) |
Line 859 instruction_poke(struct_processus *s_eta
|
Line 866 instruction_poke(struct_processus *s_eta
|
.pipe_nombre_injections[1], "-", |
.pipe_nombre_injections[1], "-", |
sizeof(unsigned char))) != sizeof(unsigned char)) |
sizeof(unsigned char))) != sizeof(unsigned char)) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) == -1) |
.semaphore_fork)) == -1) |
|
# else |
|
while(sem_wait((*s_etat_processus) |
|
.semaphore_fork) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 907 instruction_poke(struct_processus *s_eta
|
Line 919 instruction_poke(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus) |
if (sem_post(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
|
# else |
|
if (sem_post((*s_etat_processus) |
|
.semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 929 instruction_poke(struct_processus *s_eta
|
Line 946 instruction_poke(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) |
# ifndef SEMAPHORES_NOMMES |
== -1) |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) == -1) |
|
# endif |
{ |
{ |
if (errno == EINTR) |
if (errno == EINTR) |
{ |
{ |
Line 1076 instruction_poke(struct_processus *s_eta
|
Line 1096 instruction_poke(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
# ifndef SEMAPHORES_NOMMES |
!= 0) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1089 instruction_poke(struct_processus *s_eta
|
Line 1112 instruction_poke(struct_processus *s_eta
|
.pipe_nombre_injections[1], "-", |
.pipe_nombre_injections[1], "-", |
sizeof(unsigned char))) != sizeof(unsigned char)) |
sizeof(unsigned char))) != sizeof(unsigned char)) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) == -1) |
.semaphore_fork)) == -1) |
|
# else |
|
while(sem_wait((*s_etat_processus) |
|
.semaphore_fork) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 1137 instruction_poke(struct_processus *s_eta
|
Line 1165 instruction_poke(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus) |
if (sem_post(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
|
# else |
|
if (sem_post((*s_etat_processus) |
|
.semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1159 instruction_poke(struct_processus *s_eta
|
Line 1192 instruction_poke(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) == -1) |
.semaphore_fork)) == -1) |
|
# else |
|
while(sem_wait((*s_etat_processus) |
|
.semaphore_fork) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 1687 instruction_plot(struct_processus *s_eta
|
Line 1725 instruction_plot(struct_processus *s_eta
|
|
|
return; |
return; |
} |
} |
|
|
|
|
|
/* |
|
================================================================================ |
|
Fonction 'procid' |
|
================================================================================ |
|
Entrées : pointeur sur une structure struct_processus |
|
-------------------------------------------------------------------------------- |
|
Sorties : |
|
-------------------------------------------------------------------------------- |
|
Effets de bord : néant |
|
================================================================================ |
|
*/ |
|
|
|
void |
|
instruction_procid(struct_processus *s_etat_processus) |
|
{ |
|
pthread_mutexattr_t attributs_mutex; |
|
|
|
struct_objet *s_objet; |
|
|
|
(*s_etat_processus).erreur_execution = d_ex; |
|
|
|
if ((*s_etat_processus).affichage_arguments == 'Y') |
|
{ |
|
printf("\n PROCID "); |
|
|
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("(identifiant du processus)\n\n"); |
|
} |
|
else |
|
{ |
|
printf("(process identifier)\n\n"); |
|
} |
|
|
|
printf("-> 1: %s\n", d_PRC); |
|
|
|
return; |
|
} |
|
else if ((*s_etat_processus).test_instruction == 'Y') |
|
{ |
|
(*s_etat_processus).nombre_arguments = -1; |
|
return; |
|
} |
|
|
|
if (test_cfsf(s_etat_processus, 31) == d_vrai) |
|
{ |
|
if (empilement_pile_last(s_etat_processus, 0) == d_erreur) |
|
{ |
|
return; |
|
} |
|
} |
|
|
|
if ((s_objet = allocation(s_etat_processus, PRC)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (((*((struct_processus_fils *) (*s_objet).objet)).thread = |
|
malloc(sizeof(struct_descripteur_thread))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
(*(*((struct_processus_fils *) (*s_objet).objet)).thread) |
|
.nombre_references = 1; |
|
(*(*((struct_processus_fils *) (*s_objet).objet)).thread) |
|
.pid = getpid(); |
|
(*(*((struct_processus_fils *) (*s_objet).objet)).thread) |
|
.tid = pthread_self(); |
|
(*(*((struct_processus_fils *) (*s_objet).objet)).thread) |
|
.processus_detache = (*s_etat_processus).processus_detache; |
|
(*(*((struct_processus_fils *) (*s_objet).objet)).thread) |
|
.argument = NULL; |
|
|
|
pthread_mutexattr_init(&attributs_mutex); |
|
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE); |
|
pthread_mutex_init(&((*(*((struct_processus_fils *) |
|
(*s_objet).objet)).thread).mutex), &attributs_mutex); |
|
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
pthread_mutexattr_init(&attributs_mutex); |
|
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE); |
|
pthread_mutex_init(&((*(*((struct_processus_fils *) |
|
(*s_objet).objet)).thread).mutex_nombre_references), |
|
&attributs_mutex); |
|
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
|
s_objet) == d_erreur) |
|
{ |
|
return; |
|
} |
|
|
|
return; |
|
} |
|
|
// vim: ts=4 |
// vim: ts=4 |