mutual-exclusion Questions

5

Solved

I have a shared-memory between multiple threads. I want to prevent these threads access this piece of memory at a same time. (like producer-consumer problem) Problem: A thread add elements to a q...
Ehrlich asked 12/9, 2017 at 6:36

25

Solved

Is there a Pythonic way to have only one instance of a program running? The only reasonable solution I've come up with is trying to run it as a server on some port, then second program trying to ...
Ruse asked 19/12, 2008 at 12:42

7

Solved

If you have two threads within an application, and you don't want them to run a certain piece of code simultaneously, you can just put a lock around the piece of code, like this: lock (someObject)...
Arlinda asked 24/2, 2010 at 21:57

8

Solved

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

11

Solved

I'm using a spin lock to protect a very small critical section. Contention happens very rarely so a spin lock is more appropriate than a regular mutex. My current code is as follows, and assumes x...
Lutero asked 5/9, 2009 at 13:45

7

Solved

I have a Python class which needs to accept one of two mutually exclusive arguments. If the arguments are not exclusive, (ie: if both or neither are given), an error should be raised. class OrgLoc...
Bulbiferous asked 14/2, 2018 at 18:52

2

Solved

I'd like to write a function that is accessible only by a single thread at a time. I don't need busy waits, a brutal 'rejection' is enough if another thread is already running it. This is what I ha...
Bascom asked 17/11, 2020 at 22:0

7

Solved

I have two use cases. A. I want to synchronise access to a queue for two threads. B. I want to synchronise access to a queue for two threads and use a condition variable because one of the threads ...
Carpology asked 11/12, 2013 at 10:35

9

Solved

What's the difference between a monitor and a lock? If a lock is simply an implementation of mutual exclusion, then is a monitor simply a way of making use of the waiting time inbetween method exe...
Michaelmas asked 23/5, 2009 at 18:59

5

Solved

Read some texts about locking in PHP. They all, mainly, direct to http://php.net/manual/en/function.flock.php . This page talks about opening a file on the hard-disk!! Is it really so? I mean, th...
Frida asked 27/5, 2010 at 13:23

1

Solved

I read an answer on this site says the spin-lock reduce the overhead with context switches, and after that I read an textbook statement related to this: Spin-lock makes a busy waiting program no...

6

Solved

For concurrency and ensuring the integrity of the data, how would you obtain a mutual-exclusion lock for a given object? Would you need to use locking within the database, or a file, or does PHP su...
Aw asked 8/2, 2010 at 15:20

8

The book Operating System Principles by Silberschatz, Galvin and Gagne contains the following definition for the TestAndSet() instruction in the chapter on synchronization: boolean TestAndSet(bool...
Altman asked 20/7, 2009 at 8:10

8

Solved

I need to start 1-3 external programs in my Java application that have paths defined by the user. I have few requirements: I don't want the program to execute if it is already running I don't wan...
Tears asked 18/3, 2009 at 21:32

5

I am reading Operating System Concepts by Galvin. In the semaphore section it says that all the interrupts to the processor must be disabled while modifying the value of semaphore. Why it is requir...
Kaiulani asked 21/7, 2015 at 5:40

1

Solved

I am reading the famous Operating System Concepts book of (Avi Silberschatz, Peter Baer Galvin, Greg Gagne) edition 9: http://codex.cs.yale.edu/avi/os-book/OS9/ In the process synchronization chap...

2

Solved

What is the difference between above two? This question came to my mind because I found that Monitors and locks provide mutual exclusion Semaphores and conditional variables provide synchroniz...
Lycanthrope asked 11/4, 2012 at 6:24

1

Solved

My table has two columns: startsAt endsAt Both hold date and time. I want to make following constraint: IF both columns are NOT NULL then range between startsAt and endsAt must not overlap wit...

2

Here's the Test and Set written in software: boolean TestAndSet(boolean *target) { boolean rv = *target; *target = TRUE; return rv; } and do { while(TestAndSetLock(&lock)) ; // do noth...
Hendrik asked 4/8, 2014 at 11:8

6

Solved

I know that declaring a static variable within a function in C means that this variable retains its state between function invocations. In the context of threads, will this result in the variable r...
Crissie asked 7/4, 2013 at 0:59

2

Solved

I'm pretty new at spin model checking and wanted to know what this error means: unreached in proctype P1 ex2.pml:16, state 11, "-end-" (1 of 11 states) unreached in proctype P2 ex2.pml:29, stat...
Or asked 31/3, 2014 at 10:27

1

Solved

I have read this for Peterson's algorithm for mutual exclusion.Then there was the question what will happen if we reorder the first and second command in the do...while loop? I cannot see something...
Thibeault asked 15/3, 2014 at 16:39

2

Solved

I have a webpage, in which a certain Ajax event is triggered asynchronously. This Ajax section could be called once or more than once. I do not have control over the number of times this event is t...

4

Solved

I've written this hook: #include <linux/kernel.h> #include <linux/module.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> #include <linux/skbuff.h> #...

1

I define mutual exclusion and deadlock as below, respectively: The mutual exclusion condition exists if at every moment, each shared resource is either assigned to exactly one process, or available...
Borchert asked 5/3, 2013 at 4:15

© 2022 - 2025 — McMap. All rights reserved.