Questions tagged [semaphore]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
38 views

Can a Unix semaphore be used to communicate with a guest Kernel?

Unnamed semaphores can be shared between processes using shared memory. Can these semaphores be shared with a guest kernel as well? Imagine you have a Linux host acting as hypervisor, running a Linux ...
0
votes
0answers
14 views

Semaphore removed after logout of non-root user

I see an effect that I am not aware of. I create a semapohre and a shared memory in a C++ program. The program is started in background with &. Start it from root and logout: program keeps ...
1
vote
1answer
78 views

GNU Parallel Python Semaphore

I have a Python script parallelized through GNU parallel which finds a certain result which I would like to output to a file, which I currently do through standard Python file IO. The issue is that I ...
0
votes
0answers
125 views

Limit the number of thread in a parallel Bash script

I try to improve with semaphores some photo processing script I use. I run sable GNU/DEBIAN There is a function called travail that uses a given filename as an argument, and that processes the file. ...
2
votes
0answers
29 views

Obtaining and returning a permit from a semaphore in a shell script

In a shell script I can use: ipcmk -S 4 To create a semaphore with 4 slots. With ipcrm I could delete the semaphore again. But how can I use it? I cannot find any semwait, ipcsemget or similar. How ...
0
votes
3answers
2k views

mutex and semaphore like in shell script [closed]

proc1.sh #!/bin/sh touch /tmp/proc1.signature.mutex #do something for long time sleep 100 rm -rf /tmp/proc1.signature.mutex proc2.sh #!/bin/sh touch /tmp/proc2.signature.mutex #do something for ...
-1
votes
2answers
753 views

What are the benefits of mutex over semaphore in linux system programming [closed]

if binary semaphore can protect a resource atomically, then what is the benefit of mutex. For example, sem_init(&sem, 0, 1); sem_wait(&sem); critical session; sem_post(&sem); Please ...
1
vote
0answers
172 views

How to fetch semaphores and sharedmem objects for a specific apache instance when more than one apache instances run with the same app id on the box

Not sure if the question is pertinent for this forum. We have a server with 3 apache instances running with the "same" app/functional ID These instances communicate with their corresponding ...
1
vote
0answers
314 views

How to synchronize the initialization of unnamed POSIX semaphores?

In order to use unnamed POSIX semaphores with multiple processes one has to create/obtain access to a portion of shared memory. After that, one process has to initialize the semaphore by calling ...
1
vote
2answers
1k views

Using `sem` to make a script run in parallel

I have the following shell script (one liner), which I wanted to use to identify directories that have the exact same contents. I'm using it, to identify and remove duplicate (child) directories. ...
3
votes
2answers
5k views

Where is a named semaphore stored? [closed]

A named semaphore (using semaphore.h) is identified by a name in the form /somename; that is, a null-terminated string of up to NAME_MAX-4 (i.e., 251) characters consisting of an initial slash, ...
13
votes
2answers
6k views

Performing atomic write operations in a file in bash

After going through the bash documentation, this question and this one it's still not clear to me how can I perform atomic write (append) operations to a file in bash. I have a script that is run in ...
3
votes
0answers
224 views

process waiting for a semaphore

If I have a process that is in sleep state and I can see in ps column WCHAN that is waiting to obtain a semaphore, is there any way to find the address of that semaphore?
1
vote
0answers
958 views

How to debug a semop failure?

Using a 2.6.30-gentoo-r4 Linux a very complex system of php code is executed (with 4.4.9-pl0-gentoo and 5.2.10-pl0-gentoo), which occasionally runs into a semaphore blocking problem. The call to the ...
17
votes
1answer
70k views

How to get proccesses currently running semaphores by /proc?

I wonder how to get processes currently running semaphores by /proc ? I guess it's possible by SysVIPC subdirectory.But I don't know how to use this commands. Ubuntu 12.10
1
vote
2answers
663 views

Apache server doesn't start when mod_sm.so is loaded [closed]

I have an Apache 1.3 on a Sun machine (SunOS 5.10 Generic_138888-01 sun4u sparc SUNW,Sun-Fire-15000). If I keep the following two lines in httpd.conf, the server will not start: LoadModule sm_module "...
5
votes
1answer
29k views

How do I increase the number of semaphore arrays in Linux?

In a Debian lenny server running postgresql, I noticed that a lack of semaphore arrays is preventing Apache from starting up. Looking at the limits, I see 128 arrays used out of 128 arrays maximum, ...
15
votes
3answers
36k views

what is the difference between spin locks and semaphores?

What are the basic differences between spin locks and semaphores in action?
6
votes
4answers
20k views

Why are spin locks good choices in Linux Kernel Design instead of something more common in userland code, such as semaphore or mutex?

I understand that Spinlocks are real waste in Linux Kernel Design. I would like to know why is it like spin locks are good choices in Linux Kernel Design instead of something more common in userland ...
40
votes
7answers
24k views

What Unix commands can be used as a semaphore/lock?

I want to run multiple Bash shell scripts in parallel. However, I want to avoid race conditions. What Unix commands are truly atomic that I could use for this purpose, and how can I use them?