semaphore Questions

3

I am trying to teach myself Python's async functionality. To do so I have built an async web scraper. I would like to limit the total number of connections I have open at once to be a good citizen ...
Amund asked 28/11, 2016 at 3:34

4

Solved

What are the trade-offs between using a System V and a Posix semaphore?
Commemorate asked 15/12, 2008 at 13:13

1

Solved

POSIX anonymous semaphores allow me to create and use a semaphore in shared memory. This works great, because this means other processes that shouldn't have access to the semaphore don't have acces...
Arleen asked 8/9, 2022 at 1:59

6

I am studying for a midterm and this was one of the practice questions: Show how counting semaphores (i.e, semaphores that can hold an arbitrary value) can be implemented using only binary semaphor...
Pinch asked 27/2, 2013 at 16:27

2

Is there any RAII guard similar to std::lock_guard, std::scoped_lock or std::unique_lock provided by the standard which I can use in combination with std::binary_semaphore and std::counting_semapho...
Imogeneimojean asked 23/8, 2022 at 12:48

4

Solved

I'm currently training for an OS exam with previous iterations and I came across this: Implement a "N Process Barrier", that is, making sure that each process out of a group of them wait...

8

Solved

When to use a semaphore and when to use a conditional variable?

3

Solved

In the man page it appears that even if you initialise a semaphore to a value of one: sem_init(&mySem, 0, 1); It could still be incremented to a value greater than 1 with multiple calls to ...
Rego asked 19/9, 2011 at 23:59

5

Solved

I'm looking for mutex/semaphore/concurrency mechanism in shell script. Consider following situation: Unless "a" user does not close the shared file, "b" user should not able to open/update it. I'...
Pronator asked 29/7, 2011 at 8:1

5

I am working on a multi threaded WindowsPhone8 app that has critical sections within async methods. Does anyone know of a way to properly use semaphores / mutexes in C# where you are using nested...
Alchemize asked 6/11, 2013 at 22:36

3

Solved

I am doing experiments with IPC, especially with Mutex, Semaphore and Spin Lock. What I learnt is Mutex is used for Asynchronous Locking (with sleeping (as per theories I read on NET)) Mechanism, S...
Tartary asked 7/5, 2014 at 7:8

13

When should we use mutex and when should we use semaphore ?
Diocesan asked 28/10, 2010 at 5:0

2

I am testing std::counting_semaphore on C++20 with Windows 10 and MinGW x64. As I learned from https://en.cppreference.com/w/cpp/thread/counting_semaphore, std::counting_semaphore is an atomic coun...
Blowzed asked 16/4, 2022 at 10:57

2

I have multiple processes communicating using a semaphore. sem_open("\name",O_CREATE,S_IRWXU|S_IRWXG,10); I have 2 questions w.r.t following: Now, when one process dies suddenly without callin...
Reena asked 2/3, 2012 at 16:44

2

Solved

It seems like in async code these days, SemaphoreSlim is the recommended replacement for lock(obj) {}. I found this recommendation for how to use it: https://blog.cdemi.io/async-waiting-inside-c-sh...
Anchor asked 25/6, 2020 at 14:17

4

Solved

Does anybody know why semaphore operations are called P and V? Every time I read a chapter on semaphores it says something like the following: In order for the thread to obtain a resource it execu...
Nicety asked 13/4, 2015 at 13:10

5

Solved

What are the pros / cons of using pthread_cond_wait or using a semaphore ? I am waiting for a state change like this : pthread_mutex_lock(&cam->video_lock); while(cam->status == WAIT_DIS...
Malocclusion asked 16/9, 2008 at 9:40

3

Solved

I am working on some code which uses the pthread and semaphore libraries. The sem_init function works fine on my Ubuntu machine, but on OS X the sem_init function has absolutely no effect. Is there...
Lucilla asked 11/9, 2009 at 23:57

15

A semaphore is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a semaphore and how do you use it?
Metamathematics asked 29/8, 2008 at 15:58

6

Solved

I would assume that I am aware of how to work with DispatchGroup, for understanding the issue, I've tried: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoa...
Abutilon asked 19/4, 2018 at 14:38

0

I've created a binary semaphore that can be shared between two processes using pthread_mutex_t, pthread_cond_t and bool flag. But I've a little doubt of my implementation regarding the initializati...
Keepsake asked 17/10, 2021 at 14:22

6

I know that in the sync world the first snippet is right, but what's about WaitAsync and async/await magic? Please give me some .NET internals. await _semaphore.WaitAsync(); try { // todo } finall...
Curitiba asked 10/6, 2014 at 10:48

0

I am looking to use std::binary_semaphore to make sure that threads are processed in the order in which they entered the semaphore. I know that semaphore queues are typically FIFO, but I am not abl...
Radiator asked 8/8, 2021 at 18:54

1

I'd like to process coroutines in batches like: import asyncio async def test(i): print(f"Start Task {i}") await asyncio.sleep(0.1) print(f"Finished Task {i}") async def ma...
Bornie asked 25/6, 2021 at 21:25

5

Solved

I have a slice of integers, which are manipulated concurrently: ints := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} I'm using a buffered channel as semaphore in order to have an upper bound of concurrent...
Flashbulb asked 29/9, 2016 at 17:25

© 2022 - 2024 — McMap. All rights reserved.