{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Threads_ Basic Theory and Libraries

Threads_ Basic Theory and Libraries - Threads Basic Theory...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Subsections Processes and Threads Benefits of Threads vs Processes Multithreading vs. Single threading Some Example applications of threads Thread Levels User-Level Threads (ULT) Kernel-Level Threads (KLT) Combined ULT/KLT Approaches Threads libraries The POSIX Threads Library: libpthread , <pthread.h> Creating a (Default) Thread Wait for Thread Termination A Simple Threads Example Detaching a Thread Create a Key for Thread-Specific Data Delete the Thread-Specific Data Key Set the Thread-Specific Data Key Get the Thread-Specific Data Key Global and Private Thread-Specific Data Example Getting the Thread Identifiers Comparing Thread IDs Initializing Threads Yield Thread Execution Set the Thread Priority Get the Thread Priority Send a Signal to a Thread Access the Signal Mask of the Calling Thread Terminate a Thread Solaris Threads: < thread.h > Unique Solaris Threads Functions Suspend Thread Execution Continue a Suspended Thread Set Thread Concurrency Level Readers/Writer Locks Readers/Writer Lock Example Similar Solaris Threads Functions Create a Thread Get the Thread Identifier Yield Thread Execution Signals and Solaris Threads Terminating a Thread Creating a Thread-Specific Data Key Example Use of Thread Specific Data:Rethinking Global Variables Compiling a Multithreaded Application Preparing for Compilation Debugging a Multithreaded Program Threads: Basic Theory and Libraries This chapter examines aspects of threads and multiprocessing (and multithreading). We will firts study a little theory of threads and also look at how threading can be effectively used to make programs more efficient. The C thread libraries will then be introduced. The following chapters will look at further thead issues sucj a synchronisation and practical examples. Threads: Basic Theory and Libraries http://www.cs.cf.ac.uk/Dave/C/node29.html 1 of 24 1/27/09 7:30 AM
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Processes and Threads We can think of a thread as basically a lightweight process. In order to understand this let us consider the two main characteristics of a process: Unit of resource ownership -- A process is allocated: a virtual address space to hold the process image control of some resources (files, I/O devices...) Unit of dispatching - A process is an execution path through one or more programs: execution may be interleaved with other processes the process has an execution state and a dispatching priority If we treat these two characteristics as being independent (as does modern OS theory): The unit of resource ownership is usually referred to as a process or task. This Processes have: a virtual address space which holds the process image. protected access to processors, other processes, files, and I/O resources. The unit of dispatching is usually referred to a thread or a lightweight process. Thus a thread: Has an execution state (running, ready, etc.) Saves thread context when not running Has an execution stack and some per-thread static storage for local variables Has access to the memory address space and resources of its process
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 24

Threads_ Basic Theory and Libraries - Threads Basic Theory...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online