FIT2070 Lecture Notes - Lecture 4: File Descriptor, System Call, Automatic Block Signaling
L4 - Threads
The unit of dispatching for execution.
Multithreading - the ability of an OS to support multiple paths of execution within a single
process
Threads within a Process
● Different part of a program may do different things and they can be executed at the
same to improve the response time.
Each thread can be thought of a lightweight process therefore can be be in different
states
Each Thread has:
● An execution state
○ Running
○ Ready
○ Blocked
● Save thread context when not running
● An execution stack
● Some per-thread static storage for local variables
● Access to the memory and resources of its process
Benefits
● Takes less time to create thread than a process
● Less time to terminate a thread than a process
● Switching between two threads take less time than switching between processes
● Threads enhance efficiency in communication between programs
OS that supports threads
● Scheduling and dispatching done on a thread basis
● Suspending a process involves suspending all the threads of the process as the
threads in a process share the same address space
● Termination of process terminates all the threads within the process
● There is synchronisation between the threads
Types of Threads
● User Level Thread (ULT)
○ All thread management is done by the application
○ Kneral is not aware of the existence of threads
○ Any application can be programmed to be multithreaded by using a threads
library
○ Advantages
■ Thread switching does not require kernel mode privileges
■ Scheduling can be application specific
Document Summary
Multithreading - the ability of an os to support multiple paths of execution within a single process. Different part of a program may do different things and they can be executed at the same to improve the response time. Each thread can be thought of a lightweight process therefore can be be in different states. Some per-thread static storage for local variables. Access to the memory and resources of its process. Takes less time to create thread than a process. Less time to terminate a thread than a process. Switching between two threads take less time than switching between processes. Threads enhance efficiency in communication between programs. Scheduling and dispatching done on a thread basis. Suspending a process involves suspending all the threads of the process as the threads in a process share the same address space. Termination of process terminates all the threads within the process. All thread management is done by the application.