Software/Embedded system

Threads Concept

neovaga 2021. 5. 23. 10:13

Thread is a basic unit of execution so each program may have a number of processes associated with it and each process can have a number of threads executing in it. 

- A thread is a basic unit of CPU utilization 

It comprises: A thread ID/ A program counter/ A register set / A stack

- It shares with other threads belonging to the same process its code section, data section and other operating-system resources, such as open files and signals.

- A traditional/ heavyweight process has a single thread of control. 

- If a process has multiple threads of control, it can perform more than one task at a time. 

1. Responsiveness: Multithreading an interactive application may allow a program to continue running even if part of it is blocked or is performing a lengthy operation, thereby increasing responsiveness to the user. 

2. Resource sharing: By default, threads share the memory and the resources of the process to which they belong. The benefit of sharing code and data is that it allows an application to have several different threads of activity within the same address space. 

3. Economy: Allocating memory and resources for process creating is costly. Because threads share resources of the process to which they belong, it is more economical to create and context-swich threads. 

4. Utilization of multiprocessor architectures: The benefits of multithreading can be greatly increased in a multiprocessor architecture, where threads may be running in parallel on different processors. A single-threaded process can only run on one CPU, no matter how many are available. Multithreading on a multi-CPU machine increases. 

 

Single and Multi Thread

Process: A process can be thought of as a program in execution. 

Thread: A thread is the unit of execution within a process. A process can have anywhere from just on thread to many threads.  

반응형

'Software > Embedded system' 카테고리의 다른 글

exec() System call concept  (0) 2021.06.27
fork() system call concept  (0) 2021.06.27
Memory - stack and heap  (0) 2021.05.26
Priority Inversion (feat. Embeded system)  (0) 2021.05.23
The Keyword (feat. static, volatile)  (0) 2021.05.20