Software-side multithreading (also just multithreading , or rarely also multithreading ) is called the division of a program into several processing strands ( threads ) to be processed at the same time . In general, the threads of a program use common resources such as address space , file handles etc.
Software-based multithreading differs from hardware-based multithreading , which supports the apparent or real simultaneous processing of several threads in only one complete processor core of a processor .
Whether the simultaneity is real or apparent depends on the operating system and hardware used . In order to achieve real simultaneity, a multi-processor system , a multi-core processor or a processor with core multi-threading, hardware-side multi-threading must be available, and the operating system must allow a process to use several CPUs simultaneously ( concurrently ) for different threads.
Goal of multithreading
Threads are used to allow individual program parts to react quickly to events.
Only by dividing a program into several threads is it possible to utilize the performance offered by several or multi-threaded processors in a single application.
Multithreading can significantly simplify the programming of systems, provided that adequate support is provided by programming language or frameworks . Since the source code and runtime seem to match in their sequentiality, developers get intuitive access.
Differentiation from multitasking
With multitasking , the concurrency of several processes is required, while multithreading refers to the concurrency of processing strings within a process.
Some operating systems, e.g. B. Linux before kernel version 2.6, implement multithreading within multitasking. Here each thread is a separate task that is listed independently in the process table. In contrast to independent processes, however, the various threads of a process share the memory ( heap ) and the computing time allocated by the scheduler .