Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jan 2001 19:13:39 +0100
From:      Jakub Kruszona-Zawadzki <acid@g-em.pl>
To:        freebsd-bugs@FreeBSD.ORG
Subject:   semop locks all threads in multi-thread application
Message-ID:  <3A5CA653.802B0B66@g-em.pl>

next in thread | raw e-mail | index | archive | help
When in multi-thread application I call function semop and it locks, it
locks all threads (not only the current thread). It's my test program:

#include <pthread.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>

void* testowyfred(void* par)
{
    int i=0;
    while (1)
        printf("%d\n",i++);
}

int main(void) {
    pthread_t watek;
    long i=7;
    struct sembuf buf;
    int t;

    pthread_create(&watek,NULL,testowyfred,(void*)&i);
    sleep(1);    //it's for test that thread is working
    buf.sem_num = 0;
    buf.sem_op = -1;
    buf.sem_flg = 0;
    t = semget(0xBACA,1,IPC_CREAT | 0777);
    semop(t,&buf,1);

    return 1;
}



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A5CA653.802B0B66>