{"id":18769146,"url":"https://github.com/thefangbear/shared_memory","last_synced_at":"2025-12-10T12:30:13.725Z","repository":{"id":80822459,"uuid":"134106718","full_name":"thefangbear/shared_memory","owner":"thefangbear","description":"Portable cross-UNIX header-only shared memory message-passing library using POSIX shmem in C","archived":false,"fork":false,"pushed_at":"2018-05-20T00:18:05.000Z","size":6,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-29T07:24:07.888Z","etag":null,"topics":["c","posix","shmem","unix"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thefangbear.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-20T00:01:37.000Z","updated_at":"2024-10-30T05:29:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"5252662e-8fcd-44fd-8cd2-207826679cb2","html_url":"https://github.com/thefangbear/shared_memory","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thefangbear%2Fshared_memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thefangbear%2Fshared_memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thefangbear%2Fshared_memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thefangbear%2Fshared_memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thefangbear","download_url":"https://codeload.github.com/thefangbear/shared_memory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239671414,"owners_count":19677873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","posix","shmem","unix"],"created_at":"2024-11-07T19:14:58.303Z","updated_at":"2025-12-10T12:30:13.689Z","avatar_url":"https://github.com/thefangbear.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shared_memory\nThis header library aims at providing message passing / IPC via shared memory for all UNIX operating systems\nsupporting POSIX standard. It uses POSIX shmem, along with **named semaphores**; it's very portable, and the\nuse of named semaphores allows it to be used on Apple macOS (Darwin doesn't implement unnamed semaphores).\nIt starts by allocating a 4MB chunk via a single `ftruncate()` call and it's only allocated once throughout\nthe entire lifespan of the application. The single-call allocation ensures that it's usable on systems like\nDarwin (on which ftruncate can only be called once) or systems that limit shared memory size to less than\n4MB.\n\nThe message-passing semantics is implemented as a standard request-reply model. We require that once a publisher\npublishes, the consumer **must** consume the published data before the publisher publishes more. The scheme is\nguaranteed by two binary semaphores (a proof sketch is contained in the source file) that switch states.\n\nFor \u003c=4MB transfers we use two memcpy calls to transfer the data in a single contiguous chunk along with size\ninformation (so calls to our API is size-preserving; as long as they do not contain noncontiguous regions)\n\nFor \u003e4MB transfers we manually page and transfer via multiple memcpys in a for loop in chunks of 4MBs. \n\nThe 4MB limit is tunable via a macro contained in the source file, and it also controls the chunking size\nof data transfers.\n\nThe application has been tested to perform well (and on-par with OpenMPI's shared memory implementation) in another\nproject aimed at building a high-performance fault-tolerant parallel processing framework.\n\nHowever, it might still contain unknown bugs as it is only rudimantally tested. We recommend its use as a general\nguide towards programming IPC/shared memory applications instead of an off-the-shelf API.\n\nOn Apple systems, repeated creation of shared memory handles containing the same name will result in a failure.\nPlease deallocate the shared memory region after use (or manually `rm -rf /dev/shm/\u003cmy_shared_memory\u003e`).\nOn other systems, POSIX shared memory might require a special name format.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthefangbear%2Fshared_memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthefangbear%2Fshared_memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthefangbear%2Fshared_memory/lists"}