From owner-freebsd-bugs Mon Sep 24 2: 0:16 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 1F0D537B414 for ; Mon, 24 Sep 2001 02:00:03 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8O903r18348; Mon, 24 Sep 2001 02:00:03 -0700 (PDT) (envelope-from gnats) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 1881F37B415 for ; Mon, 24 Sep 2001 01:58:54 -0700 (PDT) Received: (from nobody@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8O8wsM18213; Mon, 24 Sep 2001 01:58:54 -0700 (PDT) (envelope-from nobody) Message-Id: <200109240858.f8O8wsM18213@freefall.freebsd.org> Date: Mon, 24 Sep 2001 01:58:54 -0700 (PDT) From: Choi@FreeBSD.org, Dong-won To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: kern/30781: msgrcv call blocks other pthread's jobs Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 30781 >Category: kern >Synopsis: msgrcv call blocks other pthread's jobs >Confidential: no >Severity: critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Sep 24 02:00:02 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Choi, Dong-won >Release: FreeBSD 4.2-20010108-STABLE >Organization: Naver.COM >Environment: FreeBSD 4.2-20010108-STABLE #0: Thu Jan 11 09:23:26 KST 2001 /usr/src/sys/compile/MYKERNEL i386 >Description: A program using msgrcv call and pthread do not run as expected. One thread calls msgrcv and wait until some messages are arrived. Other thread does its given jobs. And some other threads can call msgsnd to send messages. All threads need to run concurruntly. It's just ok under Linux or SunOS. >How-To-Repeat: ----- test.c ------------- #include #include #include #include #include #include void *Thread(void *vArg); struct stmq { long id; }; struct stmq mqSt; main(int argc, char *argv[]) { int i; int mqid; pthread_t thSelect; pthread_attr_t taAttr; if( (mqid = msgget(0x20, 0666 | IPC_CREAT)) == -1 ) exit(0); pthread_attr_init (&taAttr); pthread_attr_setscope (&taAttr, PTHREAD_SCOPE_SYSTEM); pthread_attr_setdetachstate(&taAttr, PTHREAD_CREATE_DETACHED); for(i=0; i<2; i++) { if(pthread_create(&thSelect, &taAttr, Thread, NULL) != 0) exit(0); } while(1) { printf("Main...\n"); fflush(stdout); msgrcv(mqid, &mqSt, sizeof(mqSt)-sizeof(long), 0, 0); } } void *Thread(void *vArg) { printf("Thread...\n"); fflush(stdout); while(1); } ------- End of test.c Under FreeBSD $ gcc test.c -pthread $ a.out Main... Under Linux or SunOS $ a.out Main... Thread... Thread... >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message