The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [threads]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
17
votes
4answers
39k views

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 ...
10
votes
3answers
1k views

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 ...
10
votes
1answer
333 views

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 ...
9
votes
3answers
1k views

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 ...
8
votes
2answers
828 views

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 ...
7
votes
1answer
1k views

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: ...
7
votes
1answer
357 views

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 ...
7
votes
1answer
2k views

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 ...
7
votes
1answer
626 views

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 ...
6
votes
2answers
819 views

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 ...
6
votes
2answers
189 views

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 ...
5
votes
1answer
1k views

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 ...
5
votes
1answer
884 views

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 ...
5
votes
1answer
146 views

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 ...
4
votes
3answers
95 views

Reasons for decreasing the number of threads in a parallel implementation

What are the reasons for decreasing the number of threads in a parallel implementation ? Assume that we have two implementations, the first one with 4 threads, and a second one with 8 threads, and ...
4
votes
1answer
104 views

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 ...
4
votes
1answer
1k views

How do locks work?

Suppose I have an application with two threads, which both use the same resource. Normally, a synchronized block keeps these threads from messing with the resource in a way the user doesn't expect. I ...
4
votes
1answer
158 views

How to express Rob Pike's classic Go Code presentation in Hoare's CSP Algebra?

At 15:30 in this talk (p13 of this presentation here) Rich Hickey mentions the formalisms available for reasoning about Communicating Sequential Processes. He then goes on to mention that these haven'...
4
votes
1answer
135 views

What techniques could be used to support thread-local contexts and resources in a language?

I am interested in the subject of thread-local contexts, which is a feature that I use quite often in solutions, but seems to lack first-class support in any languages I have used. Quite often in ...
4
votes
1answer
2k views

Difference between IO threads and worker threads

I have read that NodeJs is able to support hundreds and thousand of concurrent calls because the worker threads do not wait on the IO calls to complete. They use event driven IO. Similarly in .NET we ...
4
votes
1answer
126 views

Does a reentrant list for signal queue in a single-thread environment exist?

I need to handle Unix signals in a single-threaded application with the following goals: Signals doesn't mask on receive (thus, the signal handler must be reentrant). I am not allowed to lose signal ...
4
votes
0answers
150 views

Mutex implementation on top of a preemptive scheduler that does not guarantee liveness

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 ...
3
votes
1answer
70 views

What should be the minimum value when the two threads are executed concurrently

int count=0; void *thfunc() { int ctr=0; for(ctr=0;ctr<100;ctr++) count++; } If *thfunc() is executed by two threads concurrently in a uniprocessor ...
3
votes
1answer
928 views

Is it possible to solve the critical section problem with an atomic subtract operation?

In my Operating Systems class, our professor asked us to solve the critical section problem with the following atomic operation: ...
3
votes
1answer
50 views

One rational interval function and one irrational, will they ever collide?

This question may be a little mathy or hardware-y, so I may have to ask elsewhere. I've recently learned that if a is a positive rational number and b is a positive irrational number, there exists no ...
3
votes
1answer
94 views

What is the benefit of using one to one thread mapping model instead of Many to Many or two level?

So in the silberschatz O.S book it says Windows uses one to one model (mapping user level threads to kernel level threads) but why? i thought many to many and two level models are much better, ...
2
votes
2answers
2k views

Why there must be a relationship between user threads and kernel threads?

The following is an excerpt from OS concepts by galvin.Here is the book. Multithreading Models Our discussion so far has treated threads in a generic sense. However, support for threads may ...
2
votes
2answers
1k views

How to implement mutex on single processor (single core) system other than using spinlock

How does one implement mutex on a single processor system without using spinlock mechanism. Mutex is to be implemented in user space (for any user level library like pthread lib for example).
2
votes
1answer
2k views

User level threads are transparent to the kernel?

Find whether given statement True or False? Explain. User level threads are transparent to the kernel? My attempt : False. Since, user level threads are managed by a user level library however, ...
2
votes
2answers
2k views

Time cost of thread creation

While creating an algorithm, the following question came up: In uniform cost, what is the time cost of a process that creates a thread? Is there a difference between creating a thread in a thread ...
2
votes
1answer
51 views

If a thread containing main terminates, can another thread do anything?

I'm studying threads in C and I have this theoretical question in mind that is driving me crazy. Assume the following code: ...
2
votes
1answer
275 views

Understanding google's user level threads in kernel threads

I came across Paul Turner work on increasing efficiency of M:N threading model. I am not able to grasp the concept at slide 18 of LPC-User-Threading It says : for two threads ...
2
votes
1answer
114 views

synchronization (test-and-set)

I have benn wondering about the following possibility: if I have multiple hardware threads on the same core, and then someone decides to use shared register to allow fast synchronization among threads ...
2
votes
2answers
69 views

Does splitting a process across 4 terminal windows decrease the time it takes?

Basically, I using an algorithm called 'miranda' to look at miRNA targets and it only runs on a single thread. It compares everything in one file against everything in another file, produces a file as ...
2
votes
1answer
49 views

Passing parameters to threads

in Programming language course my professor take an example. Suppose the following code: ...
2
votes
1answer
169 views

Process state in multi threaded process

What would be the process state in a multi threaded process, in which threads are in different states (running, waiting, blocked etc)
2
votes
0answers
28 views

What does it mean by “consistent view of memory” in lock-free dequeue implementation?

I am currently reading this paper by Chales-Lev. This paper explain an implementation of work-stealing dequeue. The part where I don't understand is in the implementation of steal operation. ...
2
votes
0answers
172 views

many to many multithreading

In many to many multithreading model the processor threads are multiplexed to a lesser or equal number of kernel threads. What exactly does it mean?? Does it mean that if a kernel is executing a ...
2
votes
0answers
64 views

Context switching in M:N threading models?

I wanted to know how M:N kernel user thread model handles context switching, between multiple khread and pthread. How does the PCB/TCB for process and threads look like, how is state of registers ...
1
vote
2answers
5k views

How does RAM is shared in multi core environment?

I learnt that multi core processors have more than one processing units( i.e. the main executing units ALU etc.) and they are better at performance. I want to know how they share Physical memory. I'll ...
1
vote
2answers
53 views

What is the difference between a page and thread?

"Each process that is executed is divided into blocks of same size, called pages." "Thread is a part of process being executed." Are pages and threads both part(s) of process? Whats the difference ...
1
vote
1answer
130 views

Multi-threading : N cores = N times one core?

This question is about modern CPU architectures and multi-threading. I'm mainly interested in personal computers or servers having 2, 4, 8, 16... cores like for example an Intel core i7. I mean not a ...
1
vote
1answer
66 views

Simulating a sequence of events concurrently subject to a happened-before partial order

I am building a strategy game where multiple units(5 - 20) is fighting each other in the same time. I have a logic part that calculate those actions for each turn, and than pass it to the game ...
1
vote
2answers
102 views

What does it mean that a core supports 2 threads?

I understand that a process may have multiple threads, and that a processor may have multiple cores to run processes in parallel. But I can't understand how a core may allow multiple threads, what ...
1
vote
1answer
170 views

Is the way an OS schedule threads related to parallel computing?

From Wikipedia: Operating systems schedule threads in one of two ways: Preemptive multitasking is generally considered the superior approach, as it allows the operating system to determine ...
1
vote
1answer
115 views

Work-stealing: where and how many to steal

If one ignores the conflicts when accessing the dequeue in Work-Stealing algorithms, does it matter (and in what ways) if one steals from the top or bottom (or anywhere randomly) of the dequeue? Does ...
1
vote
1answer
2k views

What is “time-slice multi-threading”?

My goal is to understand the exact differences between SoEMT, SMT and "time-slice multi threading". Thus far I already found information on SoEMT and SMT and it does not seem to hard to find more on ...
1
vote
1answer
454 views

How can context switch affect the modification of a variable?

float myTotalAmount=0; void update(float amt){ myTotalAmount+= amt; } Task A called update(10); Calculated ...
1
vote
2answers
2k views

Switching between user-level and kernel-level threads

After reading difference between user-level threads and kernel-level threads ,now I am in doubt of context switching.Context switching is managed by OS when switching between processes/threads but ...
1
vote
1answer
387 views

processes response time confusion

An OS contains 10 identical processes that were initiated at the same time.Each process contains 15 identical requests. Each request consume 20 msec of CPU time.A request is followed by an I/O ...