Threads: Question on Sharing Memory & Performance

  • Thread starter Thread starter FrostScYthe
  • Start date Start date
  • Tags Tags
    Threads
AI Thread Summary
Threads operate similarly to processes but share state information, memory, and global variables. While threads share the heap, each has its own stack, and registers are not preserved during context switches. In terms of performance on multiprocessor systems, user-level threads may not benefit from multiple processors unless they are managed by the operating system. If implemented entirely in user space, these threads cannot be allocated to different processors. However, kernel-managed threads can be distributed across multiple processors, potentially enhancing performance.
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
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top