Skip to main content

All Questions

39 votes
11 answers
116k views

Delete all SYSTEM V shared memory and semaphores on UNIX-like systems

How can I delete all not used semaphores and shared memory with a single command on a UNIX-like system, e.g., Ubuntu?
simone's user avatar
  • 811
27 votes
2 answers
56k views

How to use POSIX semaphores on forked processes in C?

I want to fork multiple processes and then use a semaphore on them. Here is what I tried: sem_init(&sem, 1, 1); /* semaphore*, pshared, value */ . . . if(pid != 0){ /* parent process */ ...
Varaquilex's user avatar
  • 3,463
13 votes
1 answer
2k views

Why does PHP's sem_acquire blocks program execution?

I am working on a very large and complex PHP project running on gentoo Linux which obviously has some issues with PHP semaphores. Because of the size and complexity of the project I cannot post the ...
Alex's user avatar
  • 44k
10 votes
3 answers
22k views

Do forked child processes use the same semaphore?

Let's say I create a semaphore. If I fork a bunch of child processes, will they all still use that same semaphore? Also, suppose I create a struct with semaphores inside and forked. Do all the ...
jmnwong's user avatar
  • 1,667
10 votes
2 answers
29k views

How to create semaphores in shared memory in C?

My task is to create two different C files and then use the semaphores for process synchronization (I run both C files simultaneously). My main concern is: if I want to access the semaphores in both ...
Abhishek Gangwar's user avatar
8 votes
1 answer
4k views

Using shared memory with fork()

I already looked at the only similar post I could find, but it wasn't what I was looking for. Basically, I'm trying to run the Odd-Even Sort with forking, so the child runs odds and parent runs the ...
Befall's user avatar
  • 6,760
7 votes
1 answer
425 views

semaphore keys lost after some time

I have a parent-child processes using shared memory. Child put data into shared memory about 10 times per second. Parent and child are using semaphore to lock resource while writing/reading. This ...
J.T's user avatar
  • 270
4 votes
2 answers
4k views

what is difference between semaphore and shared memory

What is difference between semaphore and a shared memory ? can I use semaphores between two different processes or it must be used only in threads of a same process ?
Waqas's user avatar
  • 291
4 votes
2 answers
2k views

Segmentation fault when using semaphores with POSIX shared memory

I have a problem with some simple code I'm writing to teach myself about semaphores and POSIX shared memory. The idea is that one program, the server, opens the shared memory and writes a structure (...
Luka Aleksić's user avatar
4 votes
1 answer
802 views

Right strategy with shared memory and semaphore removing in RAII like php class

When such situation occurs? If your are using shared memory and semaphores for interpocess locking (with pcntl extension) you should care about semaphore and shared memory segment life circle. For ...
Nick Bondarenko's user avatar
4 votes
2 answers
2k views

Does Mach semaphore work in shared memory between processes?

I'm interested in using a semaphore, created using semaphore_create(task, sem, policy, value) from mach/semaphore.h, in a shared memory to synchronize two processes in Mac OS. I know that on Linux ...
sxu's user avatar
  • 551
4 votes
1 answer
396 views

What is the best kind of diagram to illustrate the workings of a semaphores / multiprocess / shared memory program?

I have made a small project in which I have used various processes / shared memory / semaphores. I am now going to have to explain my code and the program logic to both my lecturer and a couple of ...
devoured elysium's user avatar
3 votes
3 answers
4k views

Looking for good analogy/examples for monitor verses semaphore

A monitor is supposed to solve problems with semaphores in concurrent environments. I'm looking for a good analogy using a monitor verses semaphore. Please use information for the analogy: 4 tasks (...
mrwes's user avatar
  • 639
3 votes
1 answer
2k views

Where do you place POSIX semaphores when using POSIX shared memory?

I'm trying to build a client server application using POSIX shared memory and POSIX semaphores. Do I have to place the semaphores inside the shared memory segment or can the semaphores just be global ...
Anonymous's user avatar
  • 4,183
3 votes
1 answer
2k views

Asynchronous Shared Memory Read/Write

In my application, I am using shared memory for IPC between parent and child (on both Linux and Windows). Full code for Linux is at https://github.com/devendermishra/SharedMemoryTest/blob/master/...
doptimusprime's user avatar

15 30 50 per page
1
2 3 4 5
11