I'm trying to compare Inter Process Communication in Minix3 and Lubuntu, using c++. Is that possible considering different architectures and libraries needed for IPC, can someone give some tips how to achieve this? Thanks!
Related
I need to couple two codes ( one is in Fortran77 and the other in Fortran90 ) which have to be controlled by a daemon and being able to pass information between them.
I have been searching and two possible options are PVM or MPI. The problem is that I need to compile them separately, any ideas?
MPI is well adapted to the SPMD paradigm (Single Program / Multiple data). If you want to couple 2 different binaries, MPI is probably not the best tool. Inter-process communication is more like what you want to do. In Linux, if you stay on the same machine, you can use named pipes (see man mkfifo) and you can transfer your data using Fortran I/O calls. Another possibility if you want to communicate between different machines is to use ZeroMQ for example, and there exists a Fortran binding.
The simplest way is using POSIX sockets - but you will need to do data serialization/deserialization and it is pretty slow in general. So I would not recommend using sockets.
Technically MPI can work. If you can use MPI 2.0 compliant library then you can use the client-server mechanism implemented there. Look at the documentation for MPI_Open_port and MPI_Comm_connect. The first one will give you the port name that you will need to pass this name to the client somehow. One option is to use name publishing but it may not work with any MPI library. The other option is to share it using some other mechanism (socket connection, file system or anything else).
But, in fact, I still do not see the reason why you should compile these two apps separately (unless there is a licensing issue) - you can just compile them into one package (I anticipate some code change but it is minor) and then run them as one app.
We have two applications: one uses C/Fortran, and the other one is using C++.
We want the two applications to exchange data preferably without a buffer file,
and we want to ensure synchronization between the two applications as they have two different time steps.
Any helpful ideas are deeply appreciated.
Simplest way would be to use message passing via sockets, TCP or UDP depending on your needs.
How to pass data using sockets in C
There are several ways of Inter-process communication, see this link comparison of IPC methods.
The choice here depends on several variables, such as: Are these applications running on different machines vs one, are they on different operating systems, how fast, and how reliable, and the complexity of the implementation.
My favorite in this case is Named Pipes, it is easy to implement and it is reliable Named Pipes:
I am not sure what is your OS and requirements but if both applications run on the same Linux machine you could also take a look at DBUS.
Another way to go is to use webservices like gSOAP. You can use it together with Eclipse to edit the WSDL and maybe SoaMoa for testing the webservice.
Both of these options are quite high level so you don't have to work directly with the sockets and serialization/deserialization.
What should be very easy to use would be zeromq for your case. Also a plus would be the great documentation.
I have some programming experience (mid-2nd year of 4 year program, and some personal experience) writing programs in Java, C, Javascript, PHP, etc... And now I want to learn more on my own about writing executables that pass information between eachother and remain "idle", but active in the meantime. This has not been covered yet, but I'll need it for a personal project.
Can anyone tell me what that concept is called, and perhaps where to begin, so I can start learning about it?
Read tutorial's on Multithreading c/c++ program development , also for passing msg's b/w different process you can use Socket API or Inter Process Communication (IPC) . You can refer book http://www.wrox.com/WileyCDA/WroxTitle/productCd-0470147628.html which include all these stuffs ( Specific to linux , for cross platform u can use QT http://qt.nokia.com/ )
There are several ways to communicate between processes. For Windows there is always the WCF in .NET
The most useful and easy way I find is using sockets for IPC, it works both Unix and Windows platforms.
The next best thing is a local DB, like SQLite.
I did not understand the second part of your question.
http://www.tutorialspoint.com/unix_sockets/index.htm
http://msdn.microsoft.com/en-us/library/ms735119(v=vs.90).aspx
Who are "each other"? Depending on this, you might want to learn client-server or peer-to-peer architecture concepts. You will need to get knowledge of network communication and multithreading.
I'm writing a C++ project to solve the Travelling salesman problem using genetic algorithms. Naturally, I'd like to make it faster using a bunch (about 40) computers in the same LAN. The computers are all running Windows XP... So, the question is what are the ways to parallelize it using the given equipment
Update:
You've helped me to narrow my choices down to mpich an Open MPI, so the only question left is should I use boost MPI wrappers for them? Also, can you recommend a tutorial for mpich/OpenMPI?
You'll need to use some form of communication to synchronize the processes between the systems. A common API for this type of application is to use Message Passing Interface (MPI). There are quite a few implementations for MPI/MPI-2 that work on Windows XP.
MPI is one of the most used standards for such kind of projects. There are many implementations of this standard from different vendors. I think you should consider two of them:
mpich http://www.mcs.anl.gov/research/projects/mpich2/
Intel MPI http://www.intel.com/go/mpi/
Another interesting way is to use OpenMP. There are Cluster OpenMP implementations. This solution could be easier to implement, but not so scalable as MPI in some cases.
Are there any c++ networking libs that are very useful and robust? and libs to help them be run better? something like automatically endian conversion when using <<, blocking reads until the struct or w/e your reading completely transfers, something to help debug your protocol, etc
Have you had a look at Boost.Asio? It's a networking library supporting both asynchronous and synchronous operation. I've made some experiments with it in the past, and found it quite useful.
I like the ADAPTIVE Communication Environment. It has built in constructs for just about all the networking patterns. I particullarly like ACE_Task. It makes message passing SO much easier.
I'd recommend sockets... its quite easy to make cross-platform code for Win32/*nix if you use it, although it is quite low level it does provide blocking functionality (i.e. halts execution until message is recieved). There are a ton of tutorials for sockets programming available... just google for "sockets" or "WinSock" (the Win32 flavour).
http://www.google.co.uk/search?q=sockets+programming
It won't deal with endian-ness for you, but there are a number of simple ways around this problem, like using a signature byte/word (e.g. 0xC1 (11000001b), 0x00C1) at the start of a message to determine the endian-ness.