All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: POSIX message queues
@ 2003-10-07  7:50 Peter Waechtler
  2003-10-07  8:11 ` Jakub Jelinek
  0 siblings, 1 reply; 27+ messages in thread
From: Peter Waechtler @ 2003-10-07  7:50 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Jamie Lokier, Ulrich Drepper, Krzysztof Benedyczak, linux-kernel,
	Manfred Spraul, Michal Wronski

 
On Sunday, October 05, 2003, at 08:32PM, Jakub Jelinek <jakub@redhat.com> wrote:

>> Speaking of librt - I should not have to link in pthreads and the
>> run-time overhead associated with it (locking stdio etc.) just so I
>> can use shm_open().  Any chance of fixing this?
>
>That overhead is mostly gone in current glibcs (when using NPTL):
>a) e.g. locking is done unconditionally even when libpthread is not present
>   (it is just lock cmpxchgl, inlined)


a "lock cmpxchg" is > 100 cycles (according to a recent Linux Journal article
from Paul McKenney: 107ns on 700MHz PentiumIII)

But I think you will have benchmarked the alternatives?
BTW, what are they?

you suggested naming the syscall number symbols NR_mq_open instead of
NR_sys_mq_open. In the stub I want to overload some syscalls (e.g. mq_open)
but others not (e.g. mq_timedsend).

How to deal with that?


^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: POSIX Message Queues
@ 2010-09-02  9:51 Ardhan Madras
  0 siblings, 0 replies; 27+ messages in thread
From: Ardhan Madras @ 2010-09-02  9:51 UTC (permalink / raw)
  To: Glynn Clements; +Cc: linux-c-programming

Hi all,

        I use message queue to exchange data between 2 unrelated process, as shown below

Program A:
while (1) {
    mq_receive(); /* wait and receive request */
    /* process request */
    mq_send(); /* reply the request result */
}

Program B:
mq_send(); /* send request */
mq_receive(); /* process result */

        How it's possible to process A that call mq_send() receive it's *own* send data using mq_receive(), so process B that intended to read the message (mq_receive()) could not read it?, the problem is *sometime* happen, at most program A reply what program B requested. Did I miss something here?

        Ardhan



--- glynn@gclements.plus.com wrote:

From: Glynn Clements <glynn@gclements.plus.com>
To: <ajhwb@knac.com>
Cc: <linux-c-programming@vger.kernel.org>
Subject: Re: POSIX Message Queues
Date: Tue, 15 Jun 2010 16:33:25 +0100


Ardhan Madras wrote:

> It was mq_open(), sorry my bad ;p
> 
> I did umask(0001) before creating the queue, it's works now. 'Program
> A' that requested O_RDWR flag to the queue can send and receive
> message as 'Program B' did. I also try to demonstrating this problem
> with another machine (Linux of course), as result i can O_RDWR'ed
> program A queue flag without have to call umask() first. Is this
> behavior can be set through system configuration?

A process' umask is inherited from its parent. For interactive
sessions, you can set it in your ~/.profile or similar. For daemons
started by init, you can set it in the rc script which starts the
daemon.

> fchmod() also works here, sorry, but what do you mean with 'not
> portable'?, do you mean fchmod() intended to be used only for file, in
> other words "not every system support fchmod() with message queue
> descriptor" right?

Yes.

-- 
Glynn Clements <glynn@gclements.plus.com>




_____________________________________________________________
Listen to KNAC, Hit the Home page and Tune In Live! ---> http://www.knac.com

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: POSIX Message Queues
@ 2010-06-15  3:34 Ardhan Madras
  2010-06-15 15:33 ` Glynn Clements
  0 siblings, 1 reply; 27+ messages in thread
From: Ardhan Madras @ 2010-06-15  3:34 UTC (permalink / raw)
  To: Glynn Clements; +Cc: linux-c-programming

It was mq_open(), sorry my bad ;p

I did umask(0001) before creating the queue, it's works now. 'Program A' that requested O_RDWR flag to the queue can send and receive message as 'Program B' did. I also try to demonstrating this problem with another machine (Linux of course), as result i can O_RDWR'ed program A queue flag without have to call umask() first. Is this behavior can be set through system configuration?

fchmod() also works here, sorry, but what do you mean with 'not portable'?, do you mean fchmod() intended to be used only for file, in other words "not every system support fchmod() with message queue descriptor" right?

               Ardhan,


--- glynn@gclements.plus.com wrote:

From:	Glynn Clements <glynn@gclements.plus.com>
To:	<ajhwb@knac.com>
Cc:	<linux-c-programming@vger.kernel.org>
Subject: Re: POSIX Message Queues
Date:	Sat, 12 Jun 2010 14:40:07 +0100


Ardhan Madras wrote:

> I'm using POSIX message queue to exchange data as follow:
> 
> struct data {
>     unsigned char cmd;
>     long value;
> };
> 
> Creating a queue in program B:
> 
> struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = sizeof(struct data) };
> mqd_t mqd = open("/somename", O_RDWR | O_CREAT, 0777, &attr);
> 
> Open that queue in program A:
> 
> mqd_t mqd = open("/somename", O_RDWR); /* O_RDONLY should works here */

I presume that you mean mq_open() rather than open(), right?

> With given queue, i can't open this queue in program A with O_RDWR or
> O_WRONLY flag (O_RDONLY should works), no matter how i set the flag
> mode in program B's mq_open() i got EACCESS, i need both program can
> send and receive queues.
> 
> Did i miss something here?

The requested permissions have the process' umask subtracted from
them. Unless you've changed it, the umask probably removes at least
world-write permission, and possibly others. Either clear the umask
before calling mq_open(), or set the permissions afterwards with
fchmod() (although I don't know whether the latter is portable).

Also, if the queue already exists, mq_open(O_CREAT) will open the
existing queue; it won't replace it or change the permissions. Add
O_EXCL if you want it to fail if a queue with the same name already
exists.

-- 
Glynn Clements <glynn@gclements.plus.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




_____________________________________________________________
Listen to KNAC, Hit the Home page and Tune In Live! ---> http://www.knac.com

^ permalink raw reply	[flat|nested] 27+ messages in thread
* POSIX Message Queues
@ 2010-06-12  9:10 Ardhan Madras
  2010-06-12 13:40 ` Glynn Clements
  0 siblings, 1 reply; 27+ messages in thread
From: Ardhan Madras @ 2010-06-12  9:10 UTC (permalink / raw)
  To: linux-c-programming

    I'm hacking a program that need to do several *privileged* tasks, such as getting ethernet's link status (ioctl's SIOCETHTOOL command), setting and saving system time, and many more, this program must run in regular user mode (unprivileged), let's call this program as 'A'. I created another program (program 'B') as service than run in privileged mode to do privileged tasks above. I'm using POSIX message queue to exchange data as follow:

struct data {
    unsigned char cmd;
    long value;
};

Creating a queue in program B:

struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = sizeof(struct data) };
mqd_t mqd = open("/somename", O_RDWR | O_CREAT, 0777, &attr);

Open that queue in program A:

mqd_t mqd = open("/somename", O_RDWR); /* O_RDONLY should works here */

With given queue, i can't open this queue in program A with O_RDWR or O_WRONLY flag (O_RDONLY should works), no matter how i set the flag mode in program B's mq_open() i got EACCESS, i need both program can send and receive queues.

Did i miss something here?

                            Ardhan,


_____________________________________________________________
Listen to KNAC, Hit the Home page and Tune In Live! ---> http://www.knac.com

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: posix message queues
@ 2004-04-08 22:22 Arnd Bergmann
  0 siblings, 0 replies; 27+ messages in thread
From: Arnd Bergmann @ 2004-04-08 22:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Arnd Bergmann, manfred, linux-arch


Andrew Morton <akpm@osdl.org> schrieb am 08.04.2004, 22:24:28:
> 
> It broke ppc64.   Please check other architectures for the same pattern.
> 
> In file included from arch/ppc64/kernel/signal.c:29:
> include/asm/ppc32.h:144: redefinition of `struct compat_sigevent'
> include/asm/ppc32.h:156: redefinition of `compat_sigevent_t'
> include/linux/compat.h:107: `compat_sigevent_t' previously declared here

D'oh! I remember thinking that would break but forgot to fix it. On the 
other architectures, the existing structure is called sigevent_t32 or
similar, so it does not conflict but should still be changed to use
the common definition.

      Arnd <><

^ permalink raw reply	[flat|nested] 27+ messages in thread
* posix message queues
@ 2004-04-07 19:07 Andrew Morton
  2004-04-07 19:15 ` Manfred Spraul
  0 siblings, 1 reply; 27+ messages in thread
From: Andrew Morton @ 2004-04-07 19:07 UTC (permalink / raw)
  To: Manfred Spraul; +Cc: linux-arch


Manfred, if/when this gets merged up the long-suffering arch maintainers
might appreciate a little test app to exercise the syscalls which must be
added.  Do you have something suitable at hand?


Also, before we go too far the 64-bit guys may like to comment on the
syscall interface.   For example, this:

struct mq_attr {
	long	mq_flags;	/* message queue flags			*/
	long	mq_maxmsg;	/* maximum number of messages		*/
	long	mq_msgsize;	/* maximum message size			*/
	long	mq_curmsgs;	/* number of messages currently queued	*/
	long	__reserved[4];	/* ignored for input, zeroed for output */
};

looks like it will require emulation for 32-bit apps.  But if we were to
make these __u32 perhaps that could be avoided?

The patches are at

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mc2/broken-out/mq-01-codemove.patch
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mc2/broken-out/mq-02-syscalls.patch
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mc2/broken-out/mq-03-core-update.patch
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mc2/broken-out/mq-03-core.patch
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mc2/broken-out/mq-04-linuxext-poll.patch
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mc2/broken-out/mq-05-linuxext-mount.patch
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mc2/broken-out/mq-security-fix.patch
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mc2/broken-out/mq-update-01.patch

^ permalink raw reply	[flat|nested] 27+ messages in thread
* POSIX message queues
@ 2003-10-05  9:13 Krzysztof Benedyczak
  2003-10-05 10:11 ` Manfred Spraul
  2003-10-05 16:35 ` Ulrich Drepper
  0 siblings, 2 replies; 27+ messages in thread
From: Krzysztof Benedyczak @ 2003-10-05  9:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Manfred Spraul, pwaechtler, Michal Wronski

Hello

For quite a long time there are two implementations of posix mqueues
around. I think it is time to decide at least if both of them have
chances of beeing applied to official kernel. So I would
like to know if Peter Waechtler's implementations is considered superior
or there is possible some discussion and further work on our
implementation is worthwhile.

There are a lot of differencies but if the most important one is use of
ioctl vs syscalls it can be changed (in fact our implementation loong time
ago used syscalls).

In another words: is our implementation in the position
of NGPT or better? ;-)

Regards
Krzysiek

^ permalink raw reply	[flat|nested] 27+ messages in thread
* POSIX message queues
@ 2002-10-02 10:35 Krzysztof Benedyczak
  0 siblings, 0 replies; 27+ messages in thread
From: Krzysztof Benedyczak @ 2002-10-02 10:35 UTC (permalink / raw)
  To: linux-kernel

 Hello

After getting some response from lkml we are ready for
work on new version of POSIX message queues.

Main difference (as Christoph Hellwig suggested) would be
implementing it as a virtual filesystem (based on tmpfs and
parts of Jakub Jelinek code).
I think that we can agree that idea of moving whole stuff to
user space isn't good. There is still a problem with SIGEV_THREAD
version of notification but after (brief) looking into NPTL it
should be possible to implement (in difference to NGPT)


So our question is:
Is above version acceptable for Linux kernel?

Main advantages of such approach are: no need for new
system call and no mess in fork/exit.


 Krzysztof Benedyczak


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2010-09-02  9:51 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-07  7:50 POSIX message queues Peter Waechtler
2003-10-07  8:11 ` Jakub Jelinek
  -- strict thread matches above, loose matches on Subject: below --
2010-09-02  9:51 POSIX Message Queues Ardhan Madras
2010-06-15  3:34 Ardhan Madras
2010-06-15 15:33 ` Glynn Clements
2010-06-12  9:10 Ardhan Madras
2010-06-12 13:40 ` Glynn Clements
2004-04-08 22:22 posix message queues Arnd Bergmann
2004-04-07 19:07 Andrew Morton
2004-04-07 19:15 ` Manfred Spraul
2004-04-08  8:17   ` Arnd Bergmann
2004-04-08  8:49     ` Andrew Morton
2004-04-08 14:08     ` Manfred Spraul
2004-04-08 20:24     ` Andrew Morton
2004-04-09 23:45   ` David S. Miller
2004-04-10 11:19     ` Manfred Spraul
2004-04-10 11:53       ` Manfred Spraul
2004-04-10 20:43         ` Arnd Bergmann
2003-10-05  9:13 POSIX " Krzysztof Benedyczak
2003-10-05 10:11 ` Manfred Spraul
2003-10-06 19:04   ` Krzysztof Benedyczak
2003-10-05 16:35 ` Ulrich Drepper
2003-10-05 18:16   ` Jamie Lokier
2003-10-05 18:32     ` Jakub Jelinek
2003-10-05 19:18       ` Jamie Lokier
2003-10-05 21:52         ` Ulrich Drepper
2002-10-02 10:35 Krzysztof Benedyczak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.