OS Module 1 Slides-2
OS Module 1 Slides-2
3rd Semester
Operating Systems
By
Basamma Umesh Patil
Assistant Professor
Department of Information Science and Engineering
COURSE OBJECTIVE:
1. Introduce Concepts of multithreading models
COURSE OUTCOME:
The Students Will Be Able To
1. Understand The Concepts Of multithreading models
TABLE OF CONTENTS
• Overview
• Multicore Programming
• Multithreading Models
• Thread Libraries
• Implicit Threading
• Threading Issues
• Operating System Examples
OBJECTIVES
• Parallelism implies a system can perform more than one task simultaneously
• Concurrency supports more than one task making progress
• Single processor / core, scheduler providing concurrency
MULTICORE PROGRAMMING (CONT.)
• Types of parallelism
• Data parallelism – distributes subsets of the same data across multiple cores, same
operation on each
• Task parallelism – distributing threads across cores, each thread performing unique
operation
• Many-to-One
• One-to-One
• Many-to-Many
MANY-TO-ONE
• Thread library provides programmer with API for creating and managing
threads
• Two primary ways of implementing
• Library entirely in user space
• Kernel-level library supported by the OS
PTHREADS
• Thread-local storage
• Scheduler Activations
SEMANTICS OF FORK() AND EXEC()
• exec() usually works as normal – replace the running process including all
threads
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. Signal is delivered to a process
3. Signal is handled by one of two signal handlers:
1. default
2. user-defined
● Every signal has default handler that kernel runs when handling signal
● User-defined signal handler can override default
● For single-threaded, signal delivered to process
SIGNAL HANDLING (CONT.)
• If thread has cancellation disabled, cancellation remains pending until thread enables it
• Default type is deferred
• Cancellation only occurs when thread reaches cancellation point
• I.e. pthread_testcancel()
• Then cleanup handler is invoked
• Thread-local storage (TLS) 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)
• Different from local variables
• Local variables visible only during single function invocation
• TLS visible across function invocations
• Windows Threads
• Linux Threads
WINDOWS THREADS
• Windows implements the Windows API – primary API for Win 98, Win NT, Win
2000, Win XP, and Win 7
• Implements the one-to-one mapping, kernel-level
• Each thread contains
• A thread id
• Register set representing state of processor
• Separate user and kernel stacks for when thread runs in user mode or kernel mode
• Private data storage area used by run-time libraries and dynamic link libraries (DLLs)
• The register set, stacks, and private storage area are known as the context of the
thread
WINDOWS THREADS (CONT.)
•
1. Abraham Silberschatz, Peter Baer Galvin, Greg Gagne, Operating System Principles
7th edition, Wiley-India, 2006
• 2. www.tutorialspoint.com
THANK
YOU