Questions tagged [semaphore]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer

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 ...
  • 121
0 votes
1 answer

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
2 answers

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: # ...
1 vote
1 answer

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
0 answers

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. ...
  • 11
3 votes
1 answer

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 ...
  • 786
0 votes
3 answers

mutex and semaphore like in shell script [closed] #!/bin/sh touch /tmp/proc1.signature.mutex #do something for long time sleep 100 rm -rf /tmp/proc1.signature.mutex #!/bin/sh touch /tmp/proc2.signature.mutex #do something for ...
  • 13
0 votes
2 answers

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
0 answers

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 ...
  • 9
2 votes
0 answers

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 ...
  • 540
4 votes
2 answers

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
2 answers

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
2 answers

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 ...
  • 925
4 votes
0 answers

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
0 answers

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 ...
  • 5,384
19 votes
1 answer

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
  • 323
1 vote
2 answers

Apache server doesn't start when 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 "...
  • 215
6 votes
1 answer

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
3 answers

what is the difference between spin locks and semaphores?

What are the basic differences between spin locks and semaphores in action?
  • 5,618
7 votes
4 answers

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 ...
48 votes
7 answers

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?
  • 2,485