El Viernes, 15 de Enero de 2010, Seebs escribi=F3:
> On 2010-01-14, I=F1aki Baz Castillo <ibc / aliax.net> wrote:
> > Hi, is there a reliable way under Ruby to know the OS architecture (32 =
or
> > 64 bits)?
>=20
> Probably not.
>=20
> Could you explain what you're trying to do?  Without knowing why you think
> you need to know this, it's hard to give you good advice.  I couldn't tell
> you off the top of my head whether the machine I'm working on right now is
> 32-bit or 64-bit.  I've been doing software development on it for two yea=
rs
> and I've never needed to know.

The application I'm developing uses Posix Queue Messages thanks to posix_mq=
=20
gem:
  http://bogomips.org/ruby_posix_mq/README.html

When the app runs it tries to create a posix mqueue with maxmsg=3D5000 and=
=20
msgsize=3D1024. The user running the application could have not permissions=
 to=20
create such posix mqueue due to system limits ("ulimit -q").

In that case the creation of the posix mqueue raises a  Errno::ENOMEM and I=
=20
want to tell the user the exact amount of bytes required.

The algorimth to know such amount of required bytes is:

  queue.attr.mq_maxmsg * sizeof(struct msg_msg *) +
  queue.attr.mq_maxmsg * queue.attr.mq_msgsize

In 32 bits sizeof(struct msg_msg *) is 4 bytes while in 64 it's 8 bytes, so=
=20
the total ammount of bytes changes. This means that "ulimit -q" must be=20
different depending on the system architecture (32/64 bits).


=2D-=20
I=F1aki Baz Castillo <ibc / aliax.net>