Threads: Question on Sharing Memory & Performance

  • Thread starter Thread starter FrostScYthe
  • Start date Start date
  • Tags Tags
    Threads
Click For Summary
SUMMARY

This discussion focuses on the nuances of thread implementation and performance in multithreaded applications. Threads share the heap memory but maintain separate stacks, and registers are not preserved during context switches. The performance of user-level threads on multiprocessor systems depends on their implementation; user-space threads cannot utilize multiple processors, while kernel-managed threads can. The POSIX threads (pthreads) standard is highlighted as a prevalent threading model.

PREREQUISITES
  • Understanding of threading concepts, specifically POSIX threads (pthreads)
  • Knowledge of memory management in multithreaded environments
  • Familiarity with user-level vs. kernel-level thread management
  • Basic principles of processor architecture and multiprocessing
NEXT STEPS
  • Research the POSIX threads (pthreads) documentation for detailed threading implementation
  • Learn about memory management techniques in multithreaded applications
  • Explore user-level vs. kernel-level threading models and their performance implications
  • Investigate how to optimize thread allocation on multiprocessor systems
USEFUL FOR

Software developers, systems programmers, and anyone interested in optimizing multithreaded applications for performance on multiprocessor systems.

FrostScYthe
Messages
80
Reaction score
0
Hiya :),
1). I understand that threads are like processes except that they share the state information, and memory.
So I would think they share the values of the registers, the memory heap, and the stack, right? would they also share global variables?

2). Also, could a multithread solution that uses multiple user threads get better performance on a multiprocessor system than on a system with only 1 processor? I think it could get better performance if indeed we assign a thread to each processor, but I’m not sure whether the user level thread can allocate this processors or not?

Thanks in advance for any help

Frost.
 
Technology news on Phys.org
There are many different thread implementations, and they can actually differ in many respects. The most ubiquitous threading system is probably pthreads (POSIX threads), which is described here:

http://www.die.net/doc/linux/man/man7/pthreads.7.html

Note that pthreads share only the heap; they each have their own stack. Registers are not preserved across thread context switches, either.

The answer to your last question depends on the implementation. If the threads are implemented entirely in user space, they cannot be distributed across multiple processors. If the threads are implemented by the operating system kernel, on the other hand, they generally can be distributed across multiple processors.

- Warren
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 17 ·
Replies
17
Views
4K
Replies
6
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
1
Views
2K