Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Jun 2010 15:02:35 -0700
From:      Garrett Cooper <yanefbsd@gmail.com>
To:        FreeBSD-Hackers <freebsd-hackers@freebsd.org>
Cc:        standards@freebsd.org
Subject:   Are POSIX mqueues supposed to be functional on FreeBSD?
Message-ID:  <AANLkTilHaP5K-NpRDG41yZimK9bJbO4nPlSF6Egqt5Rm@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
    Err... I ran an mqueue test and it popped up with ENOSYS. Which
makes me wonder, are POSIX mqueues implemented 100% on FreeBSD? I
looked into sys/kern/uip_mqueue.c and it _appears_ functional, but I
could be misreading the code. Another test written which tests mqueue
appears to be broken as well (I'll include that in a later email if
interested). I also attached the truss output and the relative code
blurb for a little more analysis.
Thanks,
-Garrett

PS I'm not guaranteeing that the code below doesn't have bugs in it as
I'm not the original author and the tests were originally written and
targeted towards Linux.

$ uname -a
FreeBSD bayonetta.local 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r206173M:
Mon Apr 26 22:45:06 PDT 2010
root@bayonetta.local:/usr/obj/usr/src/sys/BAYONETTA.ata  amd64
$ truss functional/mqueues/send_rev_2.test
__sysctl(0x7fffffffe130,0x2,0x7fffffffe14c,0x7fffffffe140,0x0,0x0) =3D 0 (0=
x0)
mmap(0x0,672,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) =3D 34365173760 (0x80052=
f000)
munmap(0x80052f000,672)                          =3D 0 (0x0)
__sysctl(0x7fffffffe1a0,0x2,0x800639848,0x7fffffffe198,0x0,0x0) =3D 0 (0x0)
mmap(0x0,32768,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) =3D
34365173760 (0x80052f000)
issetugid(0x800530015,0x80052a524,0x800645f50,0x800645f20,0x5af1,0x0) =3D 0=
 (0x0)
open("/etc/libmap.conf",O_RDONLY,0666)           ERR#2 'No such file
or directory'
open("/var/run/ld-elf.so.hints",O_RDONLY,057)    =3D 2 (0x2)
read(2,"Ehnt\^A\0\0\0\M^@\0\0\0j\0\0\0\0"...,128) =3D 128 (0x80)
lseek(2,0x80,SEEK_SET)                           =3D 128 (0x80)
read(2,"/lib:/usr/lib:/usr/lib/compat:/u"...,106) =3D 106 (0x6a)
close(2)                                         =3D 0 (0x0)
access("/lib/libthr.so.3",0)                     =3D 0 (0x0)
open("/lib/libthr.so.3",O_RDONLY,030713440)      =3D 2 (0x2)
fstat(2,{ mode=3D-r--r--r-- ,inode=3D400430,size=3D85264,blksize=3D16384 })=
 =3D 0 (0x0)
pread(0x2,0x800638700,0x1000,0x0,0x101010101010101,0x8080808080808080)
=3D 4096 (0x1000)
mmap(0x0,1142784,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) =3D
34366316544 (0x800646000)
mmap(0x800646000,73728,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE=
,2,0x0)
=3D 34366316544 (0x800646000)
mmap(0x800757000,12288,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,2,0x11000=
)
=3D 34367434752 (0x800757000)
mprotect(0x80075a000,12288,PROT_READ|PROT_WRITE) =3D 0 (0x0)
close(2)                                         =3D 0 (0x0)
access("/lib/librt.so.1",0)                      ERR#2 'No such file
or directory'
access("/usr/lib/librt.so.1",0)                  =3D 0 (0x0)
open("/usr/lib/librt.so.1",O_RDONLY,030713440)   =3D 2 (0x2)
fstat(2,{ mode=3D-r--r--r-- ,inode=3D2567883,size=3D21424,blksize=3D16384 }=
) =3D 0 (0x0)
pread(0x2,0x800638700,0x1000,0x0,0x101010101010101,0x8080808080808080)
=3D 4096 (0x1000)
mmap(0x0,1069056,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) =3D
34367459328 (0x80075d000)
mmap(0x80075d000,20480,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE=
,2,0x0)
=3D 34367459328 (0x80075d000)
mmap(0x800861000,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,2,0x4000)
=3D 34368524288 (0x800861000)
close(2)                                         =3D 0 (0x0)
access("/lib/libc.so.7",0)                       =3D 0 (0x0)
open("/lib/libc.so.7",O_RDONLY,030713440)        =3D 2 (0x2)
fstat(2,{ mode=3D-r--r--r-- ,inode=3D400388,size=3D1156744,blksize=3D16384 =
}) =3D 0 (0x0)
pread(0x2,0x800638700,0x1000,0x0,0x101010101010101,0x8080808080808080)
=3D 4096 (0x1000)
mmap(0x0,2281472,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) =3D
34368528384 (0x800862000)
mmap(0x800862000,995328,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCOR=
E,2,0x0)
=3D 34368528384 (0x800862000)
mmap(0x800a54000,131072,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,2,0xf200=
0)
=3D 34370568192 (0x800a54000)
mprotect(0x800a74000,110592,PROT_READ|PROT_WRITE) =3D 0 (0x0)
close(2)                                         =3D 0 (0x0)
sysarch(0x81,0x7fffffffe220,0x800534188,0x0,0xffffffffffad9550,0x8080808080=
808080)
=3D 0 (0x0)
mmap(0x0,416,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) =3D 34365206528 (0x80053=
7000)
munmap(0x800537000,416)                          =3D 0 (0x0)
mmap(0x0,8064,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) =3D 34365206528 (0x8005=
37000)
munmap(0x800537000,8064)                         =3D 0 (0x0)
mmap(0x0,2944,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) =3D 34365206528 (0x8005=
37000)
munmap(0x800537000,2944)                         =3D 0 (0x0)
mmap(0x0,43296,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) =3D 34365206528 (0x800=
537000)
munmap(0x800537000,43296)                        =3D 0 (0x0)
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM=
|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXF=
SZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
=3D 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 =3D 0 (0x0)
__sysctl(0x7fffffffe1c0,0x2,0x800a7ab40,0x7fffffffe1b8,0x0,0x0) =3D 0 (0x0)
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM=
|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXF=
SZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
=3D 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 =3D 0 (0x0)
getpid()                                         =3D 45130 (0xb04a)
__sysctl(0x7fffffffe1b0,0x2,0x80075c3f0,0x7fffffffe1b8,0x0,0x0) =3D 0 (0x0)
__sysctl(0x7fffffffe0d0,0x2,0x7fffffffe0f0,0x7fffffffe158,0x800656dc8,0xd)
=3D 0 (0x0)
__sysctl(0x7fffffffe0f0,0x3,0x80075b2e8,0x7fffffffe1b8,0x0,0x0) =3D 0 (0x0)
__sysctl(0x7fffffffe170,0x2,0x800a7a628,0x7fffffffe168,0x0,0x0) =3D 0 (0x0)
__sysctl(0x7fffffffdc60,0x2,0x7fffffffdc8c,0x7fffffffdc80,0x0,0x0) =3D 0 (0=
x0)
__sysctl(0x7fffffffdb50,0x2,0x7fffffffdb70,0x7fffffffdbd8,0x80094d340,0xc)
=3D 0 (0x0)
__sysctl(0x7fffffffdb70,0x2,0x800a7a2f0,0x7fffffffdc20,0x0,0x0) =3D 0 (0x0)
readlink("/etc/malloc.conf",0x7fffffffdc90,1024) ERR#2 'No such file
or directory'
issetugid(0x80094bf4f,0x7fffffffdc90,0x0,0x0,0x2,0x0) =3D 0 (0x0)
break(0x800000)                                  =3D 0 (0x0)
__sysctl(0x7fffffffdcb0,0x2,0x7fffffffdccc,0x7fffffffdcc0,0x0,0x0) =3D 0 (0=
x0)
mmap(0x0,4194304,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) =3D
34370809856 (0x800a8f000)
mmap(0x800e8f000,1511424,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0)
=3D 34375004160 (0x800e8f000)
munmap(0x800a8f000,1511424)                      =3D 0 (0x0)
thr_self(0x800c071c0,0x0,0x0,0x0,0x188,0x5018a8) =3D 0 (0x0)
mmap(0x7fffffbff000,4096,PROT_NONE,MAP_ANON,-1,0x0) =3D 140737484156928
(0x7fffffbff000)
thr_set_name(0x18a7f,0x800656e10,0x0,0x1000,0xffffffff,0x0) =3D 0 (0x0)
rtprio_thread(0x0,0x18a7f,0x7fffffffe160,0x1000,0xffffffff,0x0) =3D 0 (0x0)
sysarch(0x81,0x7fffffffe180,0x80075aec0,0x80075b248,0xffffffff,0x0) =3D 0 (=
0x0)
sigprocmask(SIG_SETMASK,SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGABRT|SIGEMT|SIGFPE|=
SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTST=
P|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|S=
IGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
=3D 0 (0x0)
sigaction(32,{ 0x8006511dc SA_RESTART|SA_SIGINFO ss_t },0x0) =3D 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 =3D 0 (0x0)
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM=
|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXF=
SZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
=3D 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 =3D 0 (0x0)
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM=
|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXF=
SZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
=3D 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 =3D 0 (0x0)
kmq_open(0x401089,0x206,0x1ff,0x7fffffffe6a0,0x10,0x5018a8) ERR#78
'Function not implemented'
SIGNAL 12 (SIGSYS)
process exit, rval =3D 0

/*
 * Copyright (c) 2002, Intel Corporation. All rights reserved.
 * Created by:  crystal.xiong REMOVE-THIS AT intel DOT com
 * This file is licensed under the GPL license.  For the full content
 * of this license, see the COPYING file at the top level of this
 * source tree.
 *
 * 1. Two threads sending/receiving on different message queue.
 * 2. Set different Priority to the messages in the message queue, to
 * see whether the highest priority is received first.
 */

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <string.h>
#include <getopt.h>
#include <pthread.h>
#include <limits.h>
#include <mqueue.h>

#include "posixtest.h"

#define MQ_NAME_1       "/testmsg1"
#define MQ_NAME_2       "/testmsg2"
#define MSG_SIZE	128
#define MAX_MSG		3

const char *s_msg_ptr[] =3D {"msg test 1", "msg test 2", "msg test 3"};
char r_msg_ptr_1[MAX_MSG][MSG_SIZE];
char r_msg_ptr_2[MAX_MSG][MSG_SIZE];
pthread_t send1, send2, rev1, rev2;

int * send_1(void * mq)
{
	int i;
	mqd_t mq1 =3D *(mqd_t *)mq;

	printf("Enter into send_1 \n");
	for (i =3D 0; i < MAX_MSG; i++ ) {
		if ( -1 =3D=3D mq_send(mq1, s_msg_ptr[i], MSG_SIZE, i)) {
			perror("mq_send doesn't return success \n");
			pthread_exit((void *)1);
		}
		printf("[%d] send '%s' in thread send_1. \n", i+1, s_msg_ptr[i]);
	}
	pthread_exit((void *)0);

}
int * send_2(void * mq)
{
	int i;
 	mqd_t mq2 =3D *(mqd_t *)mq;

	printf("Enter into send_2 \n");
	for (i =3D 0; i < MAX_MSG; i++ ) {
		if ( -1 =3D=3D mq_send(mq2, s_msg_ptr[i], MSG_SIZE, i)) {
			perror("mq_send doesn't return success \n");
			pthread_exit((void *)1);
		}
		printf("[%d] send '%s' in thread send_2. \n", i+1, s_msg_ptr[i]);
	}
	pthread_exit((void *)0);
}
int * receive_1(void * mq)
{
	int i;
	mqd_t mq1 =3D *(mqd_t *)mq;

	printf("Enter into receive_1 \n");
	for (i =3D 0; i< MAX_MSG; i++) {
		if ( -1 =3D=3D mq_receive(mq1, r_msg_ptr_1[i], MSG_SIZE, NULL) ) {
			perror("mq_receive doesn't return success \n");
			pthread_exit((void *)1);
		}
		printf("[%d] receive '%s' in thread receive_1. \n", i+1, r_msg_ptr_1[i]);
	}
	pthread_exit((void *)0);
}
int * receive_2(void * mq)
{
	int i;
	mqd_t mq2 =3D *(mqd_t *)mq;

	printf("Enter into receive_2 \n");
	for (i =3D 0; i< MAX_MSG; i++) {
		if ( -1 =3D=3D mq_receive(mq2, r_msg_ptr_2[i], MSG_SIZE, NULL) ) {
			perror("mq_receive doesn't return success \n");
			pthread_exit((void *)1);
		}
		printf("[%d] receive '%s' in thread receive_2. \n", i+1, r_msg_ptr_2[i]);
	}
	pthread_exit((void *)0);
}
int main(int argc, char *argv[])
{
=09
 	mqd_t mq1 =3D 0, mq2 =3D 0;=09
	struct mq_attr mqstat;
	int oflag =3D O_CREAT|O_NONBLOCK|O_RDWR;

	memset(&mqstat, 0, sizeof(mqstat));
	mqstat.mq_maxmsg =3D MAX_MSG;
	mqstat.mq_msgsize =3D MSG_SIZE;
	mqstat.mq_flags =3D 0;

  	if( ((mqd_t) -1) =3D=3D (mq1 =3D mq_open(MQ_NAME_1,oflag,0777, &mqstat))=
 ) {
		printf("mq_open doesn't return success \n");
		return PTS_UNRESOLVED;
	}
  	if( ((mqd_t) -1) =3D=3D (mq2 =3D mq_open(MQ_NAME_2,oflag,0777, &mqstat))=
 ) {
		printf("mq_open doesn't return success \n");
		return PTS_UNRESOLVED;
	}
	pthread_create(&send1, NULL, (void *)send_1, (void *)&mq1);
	pthread_create(&send2, NULL, (void *)send_2, (void *)&mq2);
        pthread_create(&rev1, NULL, (void *)receive_1, (void *)&mq1);=09
        pthread_create(&rev2, NULL, (void *)receive_2, (void *)&mq2);=09
	pthread_join(send1, NULL);
	pthread_join(send2, NULL);
	pthread_join(rev1, NULL);
	pthread_join(rev2, NULL);
	=09
	mq_close(mq1);
	mq_close(mq2);
	mq_unlink(MQ_NAME_1);
	mq_unlink(MQ_NAME_2);
	return PTS_PASS;
}



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