# LiteIPC Simulator **Repository Path**: freerobot/liteipc_simulator ## Basic Information - **Project Name**: LiteIPC Simulator - **Description**: Simulator for OpenHarmony LiteIPC running on Linux. - **Primary Language**: C - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2021-05-22 - **Last Updated**: 2021-05-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## License The LiteIPC Simulator is released under the same conditions as all code in the OpenHarmony project. In particular, the terms of the [OpenHarmony CLA](https://gitee.com/openharmony/community/blob/master/cla) apply to the LiteIPC Simulator project. ## Overview LiteIPC Simulator is an implementation of OpenHarmony's LiteIPC (see //docs/lite/en/readme/liteipc_driver.md for more) using POSIX threads, shared memory and semaphores and the Linux implementation of System V shared memory. It is intended to enable easier use/development of more OpenHarmony components on Linux. It can not be used in a production system due to not being secure against malicious user-space programs among other things. ## Differences/Limitations The most important differences between LiteIPC and the simulator are the memory management method and automatic cleanup of task IPC information. The simulator uses a much simpler memory management method, which more easily results in out of memory conditions if a task holds onto a message instead of processing and then immediately freeing it upon receipt. The simulator also can't detect threads which have ended when their process continues running. This can be particularly problematic when combined with the limitations of the memory model if a task receives a message after ending. If something stops working with a lot of out of memory errors, this is probably the cause. ## Use The simulator is designed to transparently replace OpenHarmony's liteipc_adapter. The simplest way to use the simulator is to change the //foundation/communication/ipc_lite:liteipc_adapter target to point at the simulator's liteipc_adapter shared library. eg. change the liteipc_adapter target for linux builds to something like ``` group("liteipc_adapter") { public_deps = [ "//third_party/liteipc_simulator:liteipc_adapter" ] } ``` if the simulator is located in the third_party/liteipc_simulator directory under the OpenHarmony project directory. Run liteipc_simulator_init before running OpenHarmony programs using LiteIPC. ## Directory structure The `simulator` directory contains the LiteIPC simulator source code. - The liteipc_simulator_init program performs the role of LiteIPC's LiteIpcInit function. It creates and initializes a POSIX shared memory object named liteipc_simulator which contains all the control information for processes using the simulator to communicate with each other. As with LiteIpcInit it should only be called once. The `adapter` directory contains the OpenHarmony liteipc_adapter modified to work with the simulator. The `sample` directory contains a sample program which uses LiteIPC. The `test` directory contains simple test cases. The `utils` directory contains a utility program for simulator development. - liteipc_simulator_remove removes the shared memory created by liteipc_simulator_init. It doesn't perform error checking, and expects that no processes are still attached to the simulator.