System function "select( )" and IPC Message Queue

System function "select( )" and IPC Message Queue

Post by Brian Tha » Sat, 04 Jan 1997 04:00:00



Does anyone know the function "select( )" is not support UNIX System V
IPC's "Message Queue" ? When I pass message queue ID into this function, it
always return -1. Anyone one can tell me the answer ?

 
 
 

System function "select( )" and IPC Message Queue

Post by Patri » Sat, 04 Jan 1997 04:00:00




Quote:> Does anyone know the function "select( )" is not support UNIX System V
> IPC's "Message Queue" ? When I pass message queue ID into this function, it
> always return -1. Anyone one can tell me the answer ?

I am not sure am i really right, I am using only my memory
Told me if I am wrong if any one read!
Actually the System V IPC has hook off with the basic idea under unix
(everything is file). So System V IPC can use read(), Write() or
select().
If you want to seek if there any thing in the message queue, one of the
attributes of the structure will state the number of Items left.
Patrick Leung
Hong Kong Techical College

 
 
 

System function "select( )" and IPC Message Queue

Post by Michael Marxmeie » Sat, 04 Jan 1997 04:00:00



> Does anyone know the function "select( )" is not support UNIX System V
> IPC's "Message Queue" ? When I pass message queue ID into this function, it
> always return -1. Anyone one can tell me the answer ?

Very simple: select() requires file descriptors and SYSV IPC
identifiers are none. So you probably get a EBADF error.

While a lot of UNIX APIs follow the "all is a file" paradigm,
the SYSV IPC objects are a bit alien.

Hope this helps
Michael

--
Michael Marxmeier           Marxmeier Software Entwicklung GmbH

Voice : +49 202 2431440     42119 Wuppertal, Germany

 
 
 

System function "select( )" and IPC Message Queue

Post by GMacdon6 » Sun, 05 Jan 1997 04:00:00



> > Does anyone know the function "select( )" is not support UNIX System V
> > IPC's "Message Queue" ? When I pass message queue ID into this
function, it
> > always return -1. Anyone one can tell me the answer ?
> Very simple: select() requires file descriptors and SYSV IPC
> identifiers are none. So you probably get a EBADF error.
> While a lot of UNIX APIs follow the "all is a file" paradigm,
> the SYSV IPC objects are a bit alien.

The select() system call is part of the Berkeley network communication
package. It was nicely generalized on top of the existing file descriptor
interface allowing all input streams( pipes, files, network I/O, local
I/O) to
be nicely multiplexed and manipulated.

The System V IPC package implements (Semaphores, message queues
and shared memory). This package provides some excellent communications
mechanisms on a single computer. It is NOT network based.

As internetworking of computers became popular, the system V branch of
Unix
added a network interface called Streams. This package performs similar
 functions as the BSD network package(also frequently called sockets).
Many people preferred the socket interface and as a result it was also
ported to System V first as ass on packages and then eventually as
part of the Merged System V/BSD.

So, what to do about select() and message queues?

Well it's more portable to simple develop to the socket interface. Sockets
are also quite usable on a single processor, implementations are
reliable and performance is good. The advantage to using sockets in
this case are that porting to BSD is easier and making your app network
based is also easier. The socket interface also exists on many other
systems(i.e. Novell Netware, MS Windows/95/NT, VMS ...).

If for some reason you must use IPC message queues, then try not to
mix the implementation with sockets.

If you must use both, then you will have to use the IPC routines to get
IPC messages and the select() routine to get socket data. You will
need to decide which of the two input streams will get precedence.
The one which does will become the interface to "block" on. Call that
interface and either block on it, or set a short timeout. You would
then have to determine some kind of input handling "scheduling"
i.e. round robin, priority ... This can become quite complicated
and will determine the character of your application.

It's best to pick one or the other, preferably sockets. If you have
the option, you may also want to look at RPC/XDR which makes
some things easier to implement.

Hope this helps.

Oh, ceck out Unix Network Programming, by Stevens.

 
 
 

System function "select( )" and IPC Message Queue

Post by Loren Cai » Sun, 05 Jan 1997 04:00:00




> > Does anyone know the function "select( )" is not support UNIX System V
> > IPC's "Message Queue" ? When I pass message queue ID into this function, it
> > always return -1. Anyone one can tell me the answer ?

> Very simple: select() requires file descriptors and SYSV IPC
> identifiers are none. So you probably get a EBADF error.

> While a lot of UNIX APIs follow the "all is a file" paradigm,
> the SYSV IPC objects are a bit alien.

I believe select() works for SysV message queues on AIX. From the
AIX 4.2 man page for select():  

"The select subroutine checks the specified file descriptor and message
queues to see if they are ready for reading (receiving) or writing
(sending), or if they have an exception condition pending."

I am told this feature is somewhat unique to AIX, however...

Loren Cain

 
 
 

System function "select( )" and IPC Message Queue

Post by Andrew Gier » Sun, 05 Jan 1997 04:00:00


 >> While a lot of UNIX APIs follow the "all is a file" paradigm,
 >> the SYSV IPC objects are a bit alien.

 GMacdon680> The select() system call is part of the Berkeley network
 GMacdon680> communication package. It was nicely generalized on top
 GMacdon680> of the existing file descriptor interface allowing all
 GMacdon680> input streams( pipes, files, network I/O, local I/O) to
 GMacdon680> be nicely multiplexed and manipulated.

 GMacdon680> The System V IPC package implements (Semaphores, message
 GMacdon680> queues and shared memory). This package provides some
 GMacdon680> excellent communications mechanisms on a single
 GMacdon680> computer. It is NOT network based.

Whether it is network based is irrelevent - *files* aren't network based
either. The designer of SysV IPC managed to break one of Unix's best
consistency features - the ability to handle lots of different types of
things through a common interface (file descriptors).

 [...]

 GMacdon680> So, what to do about select() and message queues?

There is one Unix flavour (AIX) that actually allows you to pass message
queues to select(), but that feature is a horrible hack (and has zero
portability).

In general, though, the answer usually is to design your app so that any
given process only ever waits for one kind of thing.

--

"Ceterum censeo Microsoftam delendam esse" - Alain Knaff in nanam

 
 
 

System function "select( )" and IPC Message Queue

Post by Guy Harr » Sun, 05 Jan 1997 04:00:00



>Actually the System V IPC has hook off with the basic idea under unix
>(everything is file). So System V IPC can use read(), Write() or
>select().

Nope - System V IPC (message queues, semaphores, shared memory) are
*not* implemented as files; you can't use "read()", "write()", or
"select()" on them, except on those UNIXes that happen to support that
(I've heard that AIX supports "select()" on SV IPC objects; I know of no
others that do).
 
 
 

System function "select( )" and IPC Message Queue

Post by Dave Plon » Mon, 06 Jan 1997 04:00:00



> Does anyone know the function "select( )" is not support UNIX System V
> IPC's "Message Queue" ? When I pass message queue ID into this function, it
> always return -1. Anyone one can tell me the answer ?

As someone indicated in a follow-up, select(2)ing using System V IPC
message queue ids is implemented under AIX, but no where else.

A good way to get around this is this:

fork(2) off a process to perform a msgrcv(2) for each queue in which
you are interested.  When a child has received a message, have it
write the message across a pipe (created with pipe(2)) to the parent.
Then the parent process will essentially be able to select(2) on
message queues.

Dave

--

 
 
 

1. Heritage of "gettimeofday", "gethostname", "select"?

I'm interested in finding out the heritage and associations of
the three system calls "gettimeofday", "gethostname", and "select".
Any historians out there?  I'm trying to figure out if they are
BSDism's, SysV'isms, SunOS'isms, or just what.

Bill

--

 Xerox Palo Alto Research Center, 3333 Coyote Hill Rd, Palo Alto, CA  94304
 URL:  ftp://parcftp.parc.xerox.com/pub/ilu/misc/janssen.html

2. IP Masq/LAN/DNS questions

3. How does select() function "select"?

4. Windows games on RedHat 8?

5. GETSERVBYNAME()????????????????????"""""""""""""

6. Allowing access to protected subdirectories via .htaccess

7. Is a bash function a "function" or a "subroutine"?

8. Interesting Little Problem

9. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

10. How to select "line-in" versus "mic"

11. Installs "Complete" when "Standard" selected

12. Does select return "read ready" or "won't block" status?

13. "Standard Journaled File System" vs "Large File Enabled Journaled File System"