Questions tagged [semaphore]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers

Implementation details about pthread mutex and realtime semaphore with regard to signal safety

In the current standard, the sem_post is listed as an async-signal safe function; pthread mutex unlocking (and condition variable signalling) functions on the other hand are not. In my understanding: ...
DannyNiu's user avatar
  • 622
0 votes
1 answer

How does the Kernel implement synchronisation techniques on file access

I've read that the kernel implements synchronisation mechanisms when accessing files. For example, if we try and write or read to a file in the file system using read() or write() from different ...
Engineer999's user avatar
  • 1,121
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 ...
Andy Lin's user avatar
  • 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 ...
Owen Morgan's user avatar
2 votes
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: # ...
Jozef Dzurenda's user avatar
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 ...
Alex Williams's user avatar
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. ...
Pierre's user avatar
  • 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 ...
Harald's user avatar
  • 878
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 ...
kdm6389's user avatar
  • 11
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 ...
Raja Sekhar's user avatar
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 ...
Meeaz's user avatar
  • 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 ...
stefanct's user avatar
  • 608
5 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. ...
Nick Grealy's user avatar
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, ...
toshmarch's user avatar
18 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 ...
Sebi's user avatar
  • 999
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?
Allexandra05's user avatar
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 ...
Alex's user avatar
  • 5,642
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
Hanna's user avatar
  • 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 "...
Razvan's user avatar
  • 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, ...
Daniel C. Sobral's user avatar
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?
Renjith G's user avatar
  • 5,818
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 ...
Navaneeth Sen's user avatar
49 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?
Larry Wang's user avatar
  • 2,635