Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Sep 2001 01:58:54 -0700 (PDT)
From:      Choi@FreeBSD.org, Dong-won <dwchoe@naver.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/30781: msgrcv call blocks other pthread's jobs
Message-ID:  <200109240858.f8O8wsM18213@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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 <stdio.h> 
#include <stdlib.h> 
#include <unistd.h> 
#include <pthread.h> 
#include <sys/ipc.h> 
#include <sys/msg.h> 

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109240858.f8O8wsM18213>