●●● ●●●● 4. Threads ●●●●● ●●●● ●●●0● ●●●0 Objectives To introduce the notion of a thread -a fundamental unit of cpu utilization that forms the basis of multi-threaded computer systems o To discuss the apis for the pthreads Win 32 and Java thread libraries o To examine issues related to multi- threaded programming
2 4. Threads ⚫ Objectives ⚫ To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the basis of multi-threaded computer systems ⚫ To discuss the APIs for the Pthreads, Win32, and Java thread libraries ⚫ To examine issues related to multithreaded programming
●●● ●●●● 4. Threads ●●●●● ●●●● ●●●0● ●●●0 ●41 Overview o 4.2 Multi-threading Models ●4.3 Thread libraries 4.4 Threading Issues 0 4.5 Operating System Examples
3 4. Threads ⚫ 4.1 Overview ⚫ 4.2 Multi-threading Models ⚫ 4.3 Thread Libraries ⚫ 4.4 Threading Issues ⚫ 4.5 Operating System Examples
●●● ●●●● 4.1 Overview ●●●●● ●●●● ●●●0● ●●●0 ● a thread is a basic unit of cpu utilization°。 It comprises ● A thread|D ● A program counter A register set e A stack o It shares with other threads belonging to the same process Code section o Data section Other Os resources, such as open files and sIgnals
4 4.1 Overview ⚫ 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 ⚫ Code section ⚫ Data section ⚫ Other OS resources, such as open files and signals
●●● ●●●● 4.1 Overview ●●●●● ●●● ●●●0● ●●0 o A traditional (or heavyweight)process has a single thread of o control a lightweight process has multiple threads of control, it can perform more than one task at a time code data data files registers stack registers‖ registers‖ registers stack ck stack ← thread single-threaded multithreaded
5 4.1 Overview ⚫ A traditional (or heavyweight) process has a single thread of control ⚫ A lightweight process has multiple threads of control, it can perform more than one task at a time
●●● ●●●● 4.1 Overview ●●●●● ●●●● ●●●0● ●●●0 ● Motivation EXamples of multi-threaded program o web browser o word processor o database server web server
6 4.1 Overview ⚫ Motivation ⚫ Examples of multi-threaded program: ⚫ web browser ⚫ word processor ⚫ database server ⚫ web server