Questions tagged [threads]

112 questions
34
votes
5 answers

What threads share in general?

Well this is general question. And if anyone want to make it implementation specific then I will prefer Unix related stuff. But first need to know following problems in generality: I read single process can have multiple threads. Multiple threads of…
Mahesha999
  • 1,773
  • 7
  • 30
  • 45
12
votes
3 answers

Is it possible to prove thread safety?

Given a program consisting of variables and instructions which modify these variables, and a synchronization primitive (a monitor, mutex, java's synchronized or C#'s lock), is it possible to prove that such a program is thread safe? Is there even a…
11
votes
3 answers

Why are most mutex implementations unfair?

My understanding is that most popular implementations of a mutex (e.g. std::mutex in C++) do not guarantee fairness -- that is, they do not guarantee that in instances of contention, the lock will be acquired by threads in the order that they called…
Jeremy Friesner
  • 267
  • 2
  • 7
10
votes
1 answer

Why using Hyper-threading can lead to performance degradation

I have read it at various places like this, that Hyper-threading leads to performance degradation. I am unable to get why or how hyper-threading leads to degradation. Why it is so that even when Hyper-threading allows the OS to utilize free…
atur
9
votes
1 answer

Why is quiescent consistency compositional, but sequential consistency is not

I'm having trouble in comparing these two memory consistency models. Essentially for sequential consistency I think of real code like this: int x, y; void ThreadA() { x = 20; //Write int a = y; //Read } void ThreadB() { y = 20; int…
William
  • 193
  • 1
  • 5
9
votes
1 answer

Inconsistent state of a lock

I'm reading The Art of Multiprocessor programming and trying to understand their concept of inconsistent locks. Specifically, on page 37, the definition 2.8.1 of an inconsistent lock is not clear to me, as well as Lemma 2.8.1. Definition 2.8.1. A…
alexwriteshere
  • 241
  • 1
  • 5
8
votes
2 answers

Why can't fibers utilize multiple processors?

It seems that the distinction between fibers and threads is that fibers are cooperatively scheduled, whereas threads are preemptively scheduled. The point of the scheduler seems like a way to make an otherwise serial processor resource act in a…
James M. Lay
  • 183
  • 4
7
votes
1 answer

Question about threads and locks

I am currently reading Fuss, Futexes and Furwocks: Fast Userland Locking in Linux and came across this quote: In a fair locking scheme the lock is granted in the order it was requested. This can have negative impact on throughput due to the …
7
votes
1 answer

How are threads implemented in different OSs?

I was reading Linux Kernel Development by Robert Love, where I came across this Linux takes an interesting approach to thread support: It does not differentiate between threads and normal processes.To the kernel, all processes are the same—…
Ankit
  • 1,337
  • 2
  • 14
  • 18
6
votes
2 answers

Why are multi-threading programs more prone to errors?

Why are multi-threading programs more prone to errors than single threaded programs ? or why is multi-threading programming one of the areas where developers are (more) prone to errors? Is this in general or is it valid only for scenarios where…
Zack
  • 161
  • 4
6
votes
1 answer

Mutex implementation on top of a minimalistic preemptive scheduler

In this question, I'm implementing some synchronization primitives in the standard library of an operating system. Specifically, I want to implement mutexes and condition variables. This is on top of a microkernel with a preemptive scheduler (a…
6
votes
1 answer

What happens when thread is created

When working on Linux what happens when a thread is created? It is a separate execution flow. Does each thread have their own code section? Personally I don't think threads would be able to share code section even if it's the same section. Say if…
Parth Shah
  • 171
  • 1
  • 3
6
votes
2 answers

What is the fastest way to a Publish/Subscribe pattern?

I am running in a conceptual problem in my development which I previously also encountered in the Drupal CMS and was wondering what would be the best solution to circumvent the problem. Drupal, and my own Snap Websites software, make use of a…
Alexis Wilke
  • 225
  • 1
  • 9
5
votes
1 answer

Is there a generic word for "thread or process"?

I'm writing about a problem that could be caused by race conditions between multiple threads, or OS-level processes on the same machine or different machines, or VM-level processes like the Erlang VM has. In this context, the fact of parallel…
Nathan Long
  • 273
  • 2
  • 7
5
votes
1 answer

Can threads use resources from other processes?

This is how I see threads. Please do correct me if I'm wrong: A thread is a part of a process that runs a sequence of program code. There can be many threads within a process that run different parts of a program (one thread manages keyboard input,…
user51172
  • 51
  • 1
1
2 3 4 5 6 7 8