B L O G G E R

--> This is JAN AUSTIN EVANGELISTA hir signing..

Showing posts with label OS 5. Show all posts
Showing posts with label OS 5. Show all posts

Thread Library


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

Multithreading Methods


Multithreading Methods
• Many-to-One
• One-to-One
• Many-to-Many

MANY-TO-ONE
• Many user-level threads mapped to single kernel thread
• Examples:
- Solaris Green Threads
- GNU Portable Threads



----------

ONE-TO-ONE
• Each user-level thread maps to kernel thread
• Examples
- Windows NT/XP/2000
- Linux
- Solaris 9 and later



----------

MANY-TO-MANY
• Allows many user level threads to be mapped to many kernel threads
• Allows the operating system to create a sufficient number of kernel threads
• Solaris prior to version 9
• Windows NT/2000 with the ThreadFiber package



Kernel Thread


Supported by the Kernel

OS manages threads
- Slower to create and manage because of system calls
- A blocking system call will not cause the entire process to block.
- The kernel can schedule threads on different CPUs.

User Thread


Thread management done by user-level threads library

A blocking system call will cause the entire process to block
- OS is unaware of threads


The kernel cannot schedule threads on different CPUs.

Example: Pthread, a POSIX standard (IEEE 1003.1c) API for thread creation and synchronization.

Benefits of Multi-Threaded Programming


Responsiveness
- User interaction in parallel with data retrieval

Utilization of MP Architectures

Resource Sharing between Threads (vs. Process)
E.g. Synchronization by accessing shared data

Economy (vs. Process)
- If the task is the same, why not share the code?
- In Solaris 2, creating a process is about 30 times slower than threads. Context switch threads is about 5 times slower.

Thread


• A piece of code that run in concurrent with other threads.

• Each thread is a statically ordered sequence of instructions.

• Threads are being extensively used express concurrency on both single and multiprocessors machines.

• Programming a task having multiple threads of control – Multithreading or Multithreaded Programming.

SINGLE and MULTI-THREADED PROCESSES




Welcome

=] an eXciting WORLD awaits you [=

"dount count your
friends
on a
SUNNY DAY
when the sky is blue
and
laughter is
abundant.
Instead,
wait for the
STORM
when the clouds are dark
and
smiles are
scarce.
When someone
stands
besides
you
and
lift your
SPIRITs high,
then you'll
know who deserves
to be
called
FRIENDS..
"

Followers

Labels