Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Multithreading models in operating system pdf

29/11/2021 Client: muhammad11 Deadline: 2 Day

CMET 331 Operating Systems

4. Threads

Outline • Overview • Multithreading Models • Threading Issues • Windows XP Threads • Linux Threads

Thread • A thread, sometimes called a lightweight

process (LWP), is a basic unit of CPU utilization; it comprises a thread ID, a program counter, a register set, and a stack. —There may be multiple threads in a single process.

Those threads share: • Code • Data • Other OS resources

Single and Multithreaded Processes

Motivation • A traditional (or heavyweight) process has a

single thread of control. • If the process has multiple threads of control, it

can do more than one task at a time. • Examples

—A web browser might have one thread display images or text while another thread retrieves data from the network

—A word processor may have a thread for displaying graphics, another thread for reading keystrokes from the user, and a third thread for performing spelling and grammar checking in the background.

Why Use Threads Other Than Processes? • In fact, this process-creation method was in

common use before threads became popular. • Process creation is very heavyweight • If the new process will perform the same tasks

as the existing process, why incur all that overhead?

• It is generally more efficient for one process that contains multiple threads to serve the same purpose.

Benefits • Takes less time to create a new thread than a

process • Less time to terminate a thread than a process • Less time to switch between two threads within

the same process • Since threads within the same process share

memory and files, they can communicate with each other without invoking the kernel

Some Features • Suspending a process involves suspending all

threads of the process since all threads share the same address space

• Termination of a process, terminates all threads within the process

User Threads • Thread management done by user-level threads

library

• Three primary thread libraries: — POSIX (Portable Operating System Interface)

Pthreads — Win32 threads — Java threads

Kernel Threads • Supported and managed directly by the

operating system

• Examples —Windows XP/2000 —Solaris —Linux —Tru64 UNIX —Mac OS X

Multithreading Models • Many-to-One

• One-to-One

• Many-to-Many

Many-to-One • Many user-level threads mapped to single kernel

thread —Thread management is done by the thread library in

user space, so it is efficient —The entire process will block if a thread makes a

blocking system call —Only one thread can access the kernel at a time,

multiple threads are unable to run in parallel on multiprocessors

• Examples: —Solaris Green Threads —GNU Portable Threads

Many-to-One Model

One-to-One • Each user-level thread maps to a kernel thread

— It provides more concurrency than the many-to-one model by allowing another thread to run when a thread makes a blocking system call

— Multiple threads are able to run in parallel on multiprocessors — The overhead of creating kernel threads can burden the

performance of an application, most implementations of this model restrict the number of threads supported by the system

• Examples — Windows NT/XP/2000 — Linux — Solaris 9 and later

One-to-one Model

Many-to-Many Model • Allows many user level threads to be mapped to

many kernel threads • Allows the operating system to create a

sufficient number of kernel threads —Developers can create as many user threads as

necessary, and the corresponding kernel threads can run in parallel on a multiprocessor

—When a thread performs a blocking system call, the kernel can schedule another thread for execution

• Solaris prior to version 9 • Windows NT/2000 with theThreadFiber package

Many-to-Many Model

Threading Issues • Semantics of fork() and exec() system calls • Thread cancellation • Signal handling • Thread pools • Thread specific data • Scheduler activations

Semantics of fork() and exec() • What happens when a multi-threaded process

calls fork()? —All threads could be duplicated.

OR

—Just the calling thread.

• How exec() works? —If a thread invokes the exec () system call, the

program specified in the parameter to exec () will replace the entire process-including all threads.

Thread Cancellation • Terminating a thread before it has finished • A thread that is to be canceled is often referred

to as the target thread • Two general approaches:

—Asynchronous cancellation terminates the target thread immediately

—Deferred cancellation allows the target thread to periodically check if it should be cancelled

Signal Handling • Signals are used in UNIX systems to notify a

process that a particular event has occurred • A signal handler is used to process signals

1. Signal is generated by particular event 2. A generated signal is delivered to a process 3. Once delivered, the signal must be handled

• Options for delivering a signal: 1. Deliver the signal to the thread to which the signal

applies 2. Deliver the signal to every thread in the process 3. Deliver the signal to certain threads in the process 4. Assign a specific thread to receive all signals for the

process

Thread Pools • Create a number of threads in a pool where

they await work • Advantages:

—Usually slightly faster to service a request with an existing thread than create a new thread

—Allows the number of threads in the application(s) to be bound to the size of the pool

Thread Specific Data • Threads belonging to a process share the data

of the process • However, in some circumstances, each thread

might need its own copy of certain data • Thread-specific data allows each thread to

have its own copy of data • Useful when you do not have control over the

thread creation process (i.e., when using a thread pool)

Scheduler Activations • One scheme for communication between the user-

thread library and the kernel is known as scheduler activation

• How it works? — The kernel provides an application with a set of virtual

processors (LWPs), and the application can schedule user threads onto an available virtual processor

— The kernel must inform an application about certain events — This procedure is known as an upcall

• Scheduler activations provide upcalls - a communication mechanism from the kernel to the thread library

• This communication allows an application to maintain the correct number kernel threads

Windows XP Threads • Implements the one-to-one mapping • Each thread contains

—A thread id —Register set —Separate user and kernel stacks —Private data storage area

• The register set, stacks, and private storage area are known as the context of the threads

• The primary data structures of a thread include: —ETHREAD (executive thread block) —KTHREAD (kernel thread block) —TEB (thread environment block)

Linux Threads • Linux refers to them as tasks rather than

threads • Thread creation is done through clone()

system call • clone() allows a child task to share the address

space of the parent task (process)

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Top Rated Expert
High Quality Assignments
Engineering Solutions
Supreme Essay Writer
Coursework Helper
Innovative Writer
Writer Writer Name Offer Chat
Top Rated Expert

ONLINE

Top Rated Expert

I have assisted scholars, business persons, startups, entrepreneurs, marketers, managers etc in their, pitches, presentations, market research, business plans etc.

$19 Chat With Writer
High Quality Assignments

ONLINE

High Quality Assignments

I have worked on wide variety of research papers including; Analytical research paper, Argumentative research paper, Interpretative research, experimental research etc.

$38 Chat With Writer
Engineering Solutions

ONLINE

Engineering Solutions

I can assist you in plagiarism free writing as I have already done several related projects of writing. I have a master qualification with 5 years’ experience in; Essay Writing, Case Study Writing, Report Writing.

$36 Chat With Writer
Supreme Essay Writer

ONLINE

Supreme Essay Writer

Being a Ph.D. in the Business field, I have been doing academic writing for the past 7 years and have a good command over writing research papers, essay, dissertations and all kinds of academic writing and proofreading.

$28 Chat With Writer
Coursework Helper

ONLINE

Coursework Helper

I reckon that I can perfectly carry this project for you! I am a research writer and have been writing academic papers, business reports, plans, literature review, reports and others for the past 1 decade.

$50 Chat With Writer
Innovative Writer

ONLINE

Innovative Writer

I can assist you in plagiarism free writing as I have already done several related projects of writing. I have a master qualification with 5 years’ experience in; Essay Writing, Case Study Writing, Report Writing.

$49 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Biology chapter 1 test answers - Criminolgy/paper - List of clarifying questions - Amazing race lesson plans - Healthcare Management - Consider a hypothetical 32 bit microprocessor - Digital dashboards provide the decision makers with a quick overview - Www languagesonline org uk français encore tricolore 1 unité 8 - Independent variable for bacterial growth - Rti remote control reset - Functional Communication Training Plan - How do capacity decisions influence productivity - Week 6 assignment - Magnetic field of a solenoid lab answers - Innovation, Entrepreneurship And Technology Transfer - Capstone Research Companion - ERM Certification - Assignment - Discussion - Need a 4 page 4 min script - What is meant by the holistic approach in anthropology - Timberjack parts case study - Hrm tree trimming - Example of hotel benchmarking - Meek v fleming [1961] 2 qb 366 - Nike employee training and development - The csirt is also known as the ir reaction team. - Edith jacobson vsim - Bus route 24 newcastle - Http www youtube com watch v qwriskyv_b8 - Csi wildlife answers - Honeywell st9100a wiring diagram - Discussion (350 words) - In a period of rising prices the inventory method - Brian foster shadow health chest pain answers - Phyhsics questions - Graitec ltd - DONT SEND A MESSAGE WITHOUT READING (I NEED CHEMISTRY EXPERT FOR HOMEWORK) - Leadership and Organizational Changes - Evaluate the responses of the motor carrier Industry following the attack of 9/11 - Week 5 Topic Essay - Pursuit Of Happiness - Adaptation worksheet answer key - Campbell biology vol 1 w mastering biologynew design - Advanced practice nursing an integrative approach 4th edition - Time value of money multiple choice questions and answers - Lundbeck korea managing an international growth engine - 32.3 inches to cm - Gd engineering bandlock 2 - Discussion forum - Strategic audit report example - Excessive piston ring groove width - The other side of outsourcing video - Project 2 - Husband wife LOVe +91-7023339183 problems solution molviji - How many atoms are in 0.70 mol of iron - When did bank of america acquired merrill lynch - Dr justice orthoindy - According to kevin bahr, which of the following is a cause for conflicts in the financial markets? - Htm 08 03 bedhead services - Bambara tickets minneapolis first avenue february 29 - Dr shelly betman patient portal - Nick bottom character description - 7215 hydrus drive harrison tn - Personal Narrative ( Business Ethics ) - Course;NURS-6003N-39/NURS-6003C-39/NRSE-6003C-39-Foundations for Graduate Study - Right of Privacy - Cuso4 + nh3 net ionic equation - Graph x less than or equal to 4 - Geopolitical community in which a person would live - Prepare a presentation of the research paper submitted in week 6. - Solid sodium hydroxide is added to water - Essay - Gamma function of 1 2 proof - Responding post - The standard unmodified audit report for nonpublic companies - Csma ca program in c - Example of soap note nurse practitioner - Discussion - John hanson show my homework - Alicia may emory doll - Sea ray v drive - Apa style - Incident Response Plan - 300 words and references. No APA format needed - Week 12 - Weldon fuel pump overhaul manual - Chapter 14 taxes and government spending answers - Castle donington parish council - Essay revising - Chapman bros v verco bros - Peggy hettrick defense - Chemical structure drawing software online free - Ymca swot analysis - HR 6 Research based - Robert holcomb extreme time cheaters - Come live with us - Why do employees resist change - Approaches to psychology practice worksheet answers - Plato apology five dialogues pdf - Describe different consultation techniques used to identify treatment objectives