Skip to main content

Questions tagged [semaphore]

0 votes
1 answer
294 views

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,233
0 votes
1 answer
4k 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 ...
Andy Lin's user avatar
  • 121
0 votes
1 answer
633 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 ...
user avatar
2 votes
2 answers
2k 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 # ...
Jozef Dzurenda's user avatar
1 vote
1 answer
438 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 ...
Alex Williams's user avatar
1 vote
0 answers
864 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. ...
Pierre's user avatar
  • 11
3 votes
1 answer
214 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 ...
Harald's user avatar
  • 1,040
0 votes
3 answers
5k 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 ...
kdm6389's user avatar
  • 11
0 votes
2 answers
2k 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 ...
Raja Sekhar's user avatar
2 votes
0 answers
295 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 ...
Meeaz's user avatar
  • 19
2 votes
0 answers
627 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 ...
stefanct's user avatar
  • 666
5 votes
2 answers
4k 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. ...
Nick Grealy's user avatar
4 votes
2 answers
10k 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, ...
toshmarch's user avatar
19 votes
2 answers
14k 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 ...
Sebi's user avatar
  • 1,039
4 votes
0 answers
288 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?
Allexandra05's user avatar

15 30 50 per page