We changed our privacy policy. Read more.

Questions tagged [semaphore]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
45 views

How to open an existing named semaphore?

Obviously O_CREAT and O_EXCL are not required when opening an existing semaphore. O_CREAT is required when creating a new semaphore. O_EXCL is only meaningful when OR-ing with O_CREAT, specifying that ...
0
votes
1answer
38 views

Adding 'Progress bar / counter' to a parallelised For Loop

I've been greatly inspired by this question: Parallelize a Bash FOR Loop to parallelise some tools I've written that involve very loooong while read loops (ie doing the same task / set of tasks ...
1
vote
1answer
128 views

FIFO-based semaphore explanation

I am trying to work on some parallelization of many processes (task send/to be executed on many (let's say hundreds) nodes). I came across this solution: https://unix.stackexchange.com/a/216475 # ...
1
vote
1answer
164 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 ...
1
vote
0answers
457 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
46 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
4k 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 ...
0
votes
2answers
1k 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
199 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 ...
2
votes
0answers
371 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
2k 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. ...
4
votes
2answers
7k 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, ...
16
votes
2answers
8k 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 ...
4
votes
0answers
227 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
1k 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 ...
19
votes
1answer
78k 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
710 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 "...
6
votes
1answer
31k 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
38k views

what is the difference between spin locks and semaphores?

What are the basic differences between spin locks and semaphores in action?
7
votes
4answers
22k 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 ...
45
votes
7answers
28k 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?