r/C_Programming • u/rayriflepie • Oct 30 '26
Question Help with understanding shmget() and semaphores
I have a program which does some calculations, but I need to fork parts of it and run the calculations in parallel. Also, we are not allowed to use POSIX semaphores. I have the calculation part done, I just need to do the parallelism part. I'm also supposed to use shmget() to create a shared memory block for my threads, but I cannot find any useful resources about that function, and/or I don't understand it well. Does anyone have any advice or tips?
4
Upvotes
17
u/ThatOneCSL Oct 30 '26
Not trying to be snarky - have you tried running, or even googling,
man shmget?4
u/8d8n4mbo28026ulk Oct 31 '26
shmget()is ancient and you should probably not use it. You'll find code online that uses it, but ignore it, it's just spread confusion. On POSIX, useshm_open()withmmap().But I'm very curious now! What system are you working on?
-20
u/zemdega Oct 30 '26
Ask Claude