La fonction "semctl" avec "GETALL" ( Semaphores) sous Linux
assia_nor
Messages postés
8
Date d'inscription
Statut
Membre
Dernière intervention
-
assia_nor Messages postés 8 Date d'inscription Statut Membre Dernière intervention -
assia_nor Messages postés 8 Date d'inscription Statut Membre Dernière intervention -
bonjour tous le monde :)
je suis une étudiante en Informatique , je face un problème dans la fonction "semctl" avec la commande "GETALL"
l'enoncé de l'exercice :

mon essay :
le resultat que j'obtient :

le resultat correcte:

je veut savoir où est le problème :(
merci d'avance
je suis une étudiante en Informatique , je face un problème dans la fonction "semctl" avec la commande "GETALL"
l'enoncé de l'exercice :
mon essay :
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/sem.h> #include <sys/ipc.h> #include <string.h> #include <sys/types.h> #include <time.h> #include <errno.h> union semun { int val; struct semid_ds *buf; unsigned short *array; struct seminfo *__buf; }; union semun S; unsigned short t[100] ; int main( int argc , char* argv[] ) { if ( argc < 2 ) printf("Erreur : entrez l' id du semaphore \n" ); else{ int id = atoi( argv[1] ); char tm[80] ; int nsems ; S.array = t ; semctl ( id , 0 , GETALL , S ); printf("Semaphore Array \n"); printf("ID ==> %d\n", id ); printf("uid =%d \tgid = %d \tcuid = %d \tcgid = %d \n",((S.buf)->sem_perm).uid , ((S.buf)->sem_perm).gid , ((S.buf)->sem_perm).cuid , ((S.buf)->sem_perm).cgid ); printf("mode = %i\tacces_perms = %i \n", ((S.buf)->sem_perm).mode , ((S.buf)->sem_perm).__seq ); printf("nsems = %d \n", (S.buf)->sem_nsems ); time ( &(S.buf)->sem_otime ); strftime ( tm , 80 , "%c" , localtime(&(S.buf)->sem_otime) ); printf("otime = %s \n", tm ); time ( &(S.buf)->sem_ctime ); strftime ( tm , 80 , "%c" , localtime(&(S.buf)->sem_ctime) ); printf("ctime = %s \n", tm ); printf("semnum = %d \n", 0 ); printf("\t value = %s \n", semctl ( id , 0 , GETVAL ) ); printf("\t ncount = %s \n", semctl ( id , 0 , GETNCNT ) ); printf("\t zcount = %s \n", semctl ( id , 0 , GETZCNT ) ); printf("\t pid = %s \n", semctl ( id , 0 , GETPID ) ); } }
le resultat que j'obtient :
le resultat correcte:
je veut savoir où est le problème :(
merci d'avance
A voir également:
- La fonction "semctl" avec "GETALL" ( Semaphores) sous Linux
- Fonction si et - Guide
- Linux reader - Télécharger - Stockage
- Toutou linux - Télécharger - Systèmes d'exploitation
- Backtrack linux - Télécharger - Sécurité
- Fonction miroir - Guide