[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Semafor-arrays



Jeg arbejder med et array af semaforer oprettet med

semId = semget(key_t)1234, X, 0666 | IPC_CREAT);

hvor X repræsenterer antallet af semaforer under det pågældende semId.

Mit problem er nu, hvordan jeg i én atomisk proces kan sætte værdien for
to (eller evt. flere) af X semaforer.
For at sætte værdien på ét semafor bruger jeg kommandoen semop således:

struct sembuf semaphore;

semaphore.sem_num = X;    //X = semafor-nummeret
semaphore.sem_op = -1;
semaphore.sem_flg = SEM_UNDO;

semop(semId, &semaphore, 1);

Er der nogen der ved hvordan man tilgår flere semaforer ad gangen med ét
kald af semop eller måske vha. semctl.
MAN-siderne giver ikke meget svar på arbejdet med semafor-arrays, f.eks.
heller ikke hvordan man modtager arrayet med de enkelte semaforers
værdier med semctl(semId, X, GETALL, arg), hvor arg er af typen:

union semun {
    int val;
    struct semid_ds *buf;
    unsigned short *array;
} arg;

ligesom det heller ikke er muligt at få en forklaring af de enkelte
medlemmer af semun.

Jeg håber nogen kan overskue mit problem og hjælpe!
Mvh.
Claus


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *