SystemVIPC is a Ruby 1.8  module for System V Inter-Process Communication: message queues, semaphores, and shared memory.

eSpace Has released a version from SystemVIPC-0.8 RC1 that is compatible and works fine for Ruby 1.8 and Ruby 1.9

It’s really nice to work with SysVIPC with its simple used APIs , Here I’ll provide a simple tutorial for using SysVIPC Shared Memory.

Downloading and Installing

  • Download SysVIPC  Compatible Release for Ruby 1.8 , Ruby 1.9 at :  http://github.com/espace/sysvipc-0.8-rc1.git
  • Extract the Source , then run : ruby1.9 extconf.rb ( note : run with the ruby version you want ) then :  make install Makefile
  • You will have the sysvipc.so file appearing now
  • In all cases you have to put these lines of code :

require ‘sysvipc.so’

include SystemVIPC

Shared Memroy Example

## Testing Shared Memory

  1. $key = ftok ‘/tmp/shm’ , IPC_CREAT
  2. $sh = SharedMemory.new($key, 33554432, IPC_CREAT | 0660)
  3. $sh.attach
  4. child = open(“|-“,”w+”)
  5. if child.nil?
  6. $sh.write(‘In Shared Memory’)
  7. sleep 2
  8. $sh.write(‘now showing you the world!’)
  9. else
  10. sleep 1
  11. puts $sh.read(100)
  12. sleep 3
  13. puts $sh.read(100)
  14. end

Lines 1 ,  2 , 3  we convert the path name into as SysVIPC key , then we initiate if necessary 8 MegaBytes shared Memory Segment associated with key , then finally we attach the shared memory segment.

lines 4 , 5 we for a child for the process

At lines 6 , 8 we use the SharedMemory method write to write two data items to the shared memory segment

lines 11 , 13 the forked child process reads the data written by the parent process in the shared Memory segment and prints it.

sleep call is used for synchronizing the events..

Hope this is helpful….

View The SystemVIPC documentation at : http://sysvipc.rubyforge.org/

Advertisements

Facing problems while configuring anything in linux is a normal thing .. may be its boring and tiring .. but its really interesting when you solve them..

As a linux  starter i face some problems while configuring ruby on rails environment for linux .. Here they are

Note : Sure before any thing you need to get ruby and rails installed

  • sudo apt-get install ruby
  • sudo apt-get install rubygems
  • gem install rails –include-dependencies

1.Problem :Any Gem that lets you choose between mswin32 and ruby ( and of course you choose ruby ) is installed

  • Solution : Simply this happens because these gems require compilation so just give them the tool
    • sudo apt-get install g++ ( Now you are done and can work )

2.  Problem : While Installing A gem it tells you this: Could not create Makefile due to        some necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

  • Solution : This Happens because the ruby1.8-dev required library is not installed so simply
    • sudo apt-get install ruby1.8-dev Done

3. Problem : Always installing rmagick gem is a problem but i think its solution in linux is more simple than windows

  • Solution : 3 Steps ( Download imagicmagick , The Lib Magick library , Then the Gem )

    • sudo apt-get install imagemagick
    • sudo apt-get install libmagick9-dev
    • gem install rmagick

4. Problem : The great Problem of the file ( /tmp/mysql.sock ) which makes you not able to use rake db:migrate or any other access to the mysql databases

  • Solution : This Problem arises as the mysql.sock file location and a name has changed during newer versions to be installed in this silly location ( /var/run/mysqld/mysqld.sock) . Really Boring… So now we have to make a symbolic link and also change the name so do this
    • ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock

These Problems were very annoying and tiring for me and i hope it helps

When i First Installed Ubuntu 8.04 i was really happy , but i got shocked when i found that my intel wireless card is not working , The system appears to see it  but i cant connect nor search for networks .

After a lot of search in the ubuntu , I found that this was a formal ubuntu 8.04 Bug… Here It is

So I found a Solution Here   , I tried making it more usable , Here it is , Open up your lovely Terminal

  • sudo bash ( Just to make it more easy )
  • modprobe -r iwl3945
  • Navigate to /etc/modprobe.d   command :::  cd /etc/modprobe.d
  • Create file named iwl3945     command  :::  touch  iwl3945
  • Open The File     command : gedit iwl3945
  • Add The Following To the File
    • alias wlan0 iwl3945
    • options iwl3945 disable_hw_scan=1
  • Save The File and exit
  • modprobe iwl3945
  • sudo ifconfig wlan0 up

Now You will find networks jumping into your wireless networks list