poject manajment

Topics: Operating system, Computer multitasking, Process Pages: 13 (1063 words) Published: April 4, 2014
Chapter 4:
Threads

Ch4: Threads

CPIS 222– Principles of Operating Systems -2012– KAU

Dr.Lamiaa Elrefaei

1

Outline
 Overview

 Multithreading Models
 Thread Libraries
 Threading Issues

 Operating System Examples

Ch4: Threads

CPIS 222– Principles of Operating Systems -2012– KAU

Dr.Lamiaa Elrefaei

2

4.1 Overview
 Single-threaded process – multithreaded process:


A thread is a basic unit of CPU utilization.



Traditional process has a single thread of control.



Multithreaded process can perform more than one task at a time.

 Many applications are multithreaded.


A web browser might have one thread displaying images while another thread retrieving data from the network.



A word processor may have a thread for responding to keystrokes from the users, and another thread for performing spelling and grammar checking in the background.

 Many operating system kernels are now multithreaded.
 Several threads operate in the kernel.
 Each thread performs a specific task.
 For example, Linux uses a kernel thread for managing the amount of free memory in the system.
Ch4: Threads

CPIS 222– Principles of Operating Systems -2012– KAU

Dr.Lamiaa Elrefaei

3

4.1 Overview (cont’d)
 A thread 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 operating-system resources, such as open files.

Ch4: Threads

CPIS 222– Principles of Operating Systems -2012– KAU

Dr.Lamiaa Elrefaei

4

4.1 Overview (cont’d)
Heavyweight Process= process

Ch4: Threads

Lightweight Process = Thread

CPIS 222– Principles of Operating Systems -2012– KAU

Dr.Lamiaa Elrefaei

5

New Process Description Model

Single-threaded process

multithreaded process
Ch4: Threads

CPIS 222– Principles of Operating Systems -2012– KAU

Dr.Lamiaa Elrefaei

6

4.1.1 Motivation : Why multiple thread??
 In many situations, an application may be required to perform several similar tasks.


A web server accepts several client requests for web pages.



If the web server run as a traditional single-threaded process … it would be able to service only one client at a time.

 Solution 1:


When the server receives a request, it creates a separate process to service that request.


E.g., fork().



This process-creation method was in common use before threads became popular.



Process creation is time consuming and resource intensive.

 Solution 2:


It is more efficient to use one process that contains multiple threads.



When a client request is accepted, the server (a thread) would create another thread to service the request.

Ch4: Threads

CPIS 222– Principles of Operating Systems -2012– KAU

Dr.Lamiaa Elrefaei

7

4.1.1 Motivation : Why multiple thread??
Multithreaded Server Architecture

Ch4: Threads

CPIS 222– Principles of Operating Systems -2012– KAU

Dr.Lamiaa Elrefaei

8

4.1.2 Benefits of multithreading
 Responsiveness:


Application can continue running even if part of it is blocked ( wait I/O) or is performing a lengthy operation.



A multithreaded web browser allow user interaction in one thread while an image was being loaded in another thread.

 Resource sharing:


Threads share the memory and the resources of the process to which they belong.

 Economy:


Allocating memory and resources for process creation is costly.



In Solaris, creating a process is about thirty times slower than is creating a thread. Context switching is about five times slower.

 Utilization of multiprocessor architectures:


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.

Ch4: Threads

CPIS...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • project manajment Essay
  • Marketing Research final poject Essay
  • Poject of Mcdonals Essay
  • Math533 Poject B 1 Essay
  • Essay on Spanish Poject on Uruguay

Become a StudyMode Member

Sign Up - It's Free