ipc

What's the difference between shared memory for IPCs and threads' shared memory?

耗尽温柔 提交于 2019-12-14 01:33:43
问题 Let's use POSIX shared memory like shmget() - a common call to coordinate inter-process communication. How is calling shmget() and coordinating communication on the shared memory segment any different than how Linux implements shared memory and synchronization between threads in a single process. Is one of them more light-weight? 回答1: SHM is for IPC in multiple processes. In modern OS, each process cannot see each others' memory space. Using common key for shmget() to get the share memory and

(How) Can I determine the socket family from the socket file descriptor

放肆的年华 提交于 2019-12-14 00:14:43
问题 I am writing an API which includes IPC functions which send data to another process which may be local or on another host. I'd really like the send function to be as simple as: int mySendFunc(myDataThing_t* thing, int sd); without the caller having to know -- in the immediate context of the mySendFunc() call -- whether sd leads to a local or remote process. It seems to me that if I could so something like: switch (socketFamily(sd)) { case AF_UNIX: case AF_LOCAL: // Send without byteswapping

Find number of tasks blocking on a POSIX semaphore

时光毁灭记忆、已成空白 提交于 2019-12-13 21:34:39
问题 Is there any way by which I can know the number of processes or threads waiting on a particular semaphore? Like a API to check the value. Sem_getvalue() only returns 0 and not a negative number whose absolute value is the number of tasks blocking on the semaphore as mentioned on a few sites. Any help would be great. Thanks in advance!! 回答1: There is no way to do this in the POSIX API other than sem_getvalue , which semantics, as you have seen, are optional. That said, Linux implements named

Reading continuous data from a named pipe

僤鯓⒐⒋嵵緔 提交于 2019-12-13 19:11:36
问题 I have been trying to read continuous data from a named pipe. But for some reason if I don't put a delay, the receiver will just stop reading and only a blank screen is shown after a few samples. I need to send continuous data that might change in milliseconds, so that's why putting a delay wouldn't work. I am trying to simulate it first using a while loop (the real script will be reading financial data). This is my first attempt: This is the sender, a python script: import os import time try

Proper inter process communication method between Opencv C++ webcam program and C server

早过忘川 提交于 2019-12-13 18:37:03
问题 Consider a simple OpenCV program that captures webcam frames: #ifndef __OPENCV__ #define __OPENCV__ #include "opencv2/opencv.hpp" #endif #include <iostream> #include "utils.hpp" #include "constants.hpp" #include <unistd.h> #include <vector> #include "InputStateContext.hpp" #include <SDL.h> #include <SDL_events.h> #include "MiddlewareConnector.hpp" using namespace cv; using namespace std; void onTrackbar_changed(int, void* data); //void onThreshold_changed(int, void* data); void onMouse(int

Communication between service and application And also to trigger the application with GUI

天涯浪子 提交于 2019-12-13 17:17:13
问题 I have developed an application which does periodical jobs. It runs as windows service in background and manages jobs. I want to trigger another application with GUI from service application when any error notification needs to be given to user. So after seeing err message user will give some response. So now service application (running as service) should do some work based on user response in GUI application (with interface). User response should be communicated to the service application.

How to realize communication between Cordova App and Native WatchKit Extension

百般思念 提交于 2019-12-13 15:23:00
问题 I would like to extend a ionic / Cordova IOS App by a WatchKit App (native written in swift). I am wondering which is the best way for communication between both. I checked the plugin: github.com/leecrossley/cordova-plugin-apple-watch which allows me to make basic communication, after changing to: MMWormholeTransitingTypeSessionMessage transition type on both sides. (Using Xcode9 and watchOS 4.0). Now I am asking myself if this MMWormhole is the best choice, as development stopped 2-3 years

NamedPipe multiple servers

余生颓废 提交于 2019-12-13 14:08:59
问题 For simple IPC I have chosen NamedPipes to communicate between process (local). Due to changing requirements there shall be multiple instances of the server, which leads to multiple "listeners" on the same pipename. But there seems to be a problem. Only one of those listeners gets the message, every other instance does not. Is there some way of "broadcasting" messages? I already have seen this question, which is basically the same question, but it has no answer. CODE: Right now I use the

C pass void pointer using shared memory

夙愿已清 提交于 2019-12-13 14:07:55
问题 I need to pass void handler to another application, To replicate the scenario I have created one small program using shared memory and try to pass the void pointer to another application and print the value, I can get the void pointer address in another application, but when I try to dereference the pointer second application crash. Here are the sample application wire.c . #include <sys/ipc.h> #include <sys/shm.h> #include <stdio.h> int main() { key_t key=1235; int shm_id; void *shm; void

fork and exec many different processes, and obtain results from each one

混江龙づ霸主 提交于 2019-12-13 13:55:25
问题 I have managed to fork and exec a different program from within my app. I'm currently working on how to wait until the process called from exec returns a result through a pipe or stdout. However, can I have a group of processes using a single fork, or do I have to fork many times and call the same program again? Can I get a PID for each different process ? I want my app to call the same program I'm currently calling many times but with different parameters: I want a group of 8 processes of