posix threads n.
Skip this Video
Loading SlideShow in 5 Seconds..
POSIX Threads PowerPoint Presentation
Download Presentation
POSIX Threads

Loading in 2 Seconds...

play fullscreen
1 / 13

POSIX Threads - PowerPoint PPT Presentation

  • Uploaded on

POSIX Threads. Kevin Sawicki Rachel Strong. Overview. IEEE Standard Thread Basics Thread Safety Thread Characteristics POSIX comparison to Java. IEEE Standard 1003. Internationally known as ISO/IEC 9945 Developed jointly by IEEE and The Open Group

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'POSIX Threads' - llewellyn-timothy

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
posix threads

POSIX Threads

Kevin Sawicki

Rachel Strong

  • IEEE Standard
  • Thread Basics
  • Thread Safety
  • Thread Characteristics
  • POSIX comparison to Java
ieee standard 1003
IEEE Standard 1003
  • Internationally known as ISO/IEC 9945
  • Developed jointly by IEEE and The Open Group
  • POSIX replaced original name of IEEE-IX
  • Stands for Portable Operating System Interface
  • Name created by Richard Stallman
  • Incredibly long documents
    • Base Definitions over 500 pages
    • System Interfaces over 1750 pages
posix breadth
POSIX Breadth
  • Defines a lot more than just threads:
    • Error Numbers
    • I/O Streams
    • Realtime
    • Sockets
    • Tracing
  • Outlines C Header files
  • Examples and code snippets are in C
  • Outlines concept of command interpreter or “shell”
thread basics
Thread Basics
  • IEEE Thread Definition:

“A single flow of control within a process. Each thread has its own thread ID, scheduling priority and policy, errno value, thread-specific key/value bindings, and the required system resources to support a flow of control. Anything whose address may be determined by a thread, including but not limited to static variables, storage obtained via malloc( ), directly addressable storage obtained through implementation-defined functions, and automatic variables, are accessible to all threads in the same process.”

thread contents
Thread Contents
  • Each POSIX thread must maintain the following:
    • Thread ID (pthread_t)
      • Unique and reusable within the same process
    • Thread attributes (pthread_attr_t)
      • Scheduling information
      • Stack information
    • Cancellability State
    • Start routine
    • Arguments to start routine
thread safety
Thread Safety
  • Definition:
    • “A function that may be safely invoked concurrently by multiple threads.”
  • Standard outlines all functions that must be thread-safe
  • Defined as functions that lock on static storage or shared objects
mutually exclusive locks
Mutually Exclusive locks
  • Defined data structure (pthread_mutex_t)
  • Configurable to multiple modes:
    • Normal  Relocking causes deadlock
    • Error Check  Error codes on incorrect calls
    • Recursive  Semaphore type behavior
    • Default All incorrect calls cause undefined behavior
  • Obtained two ways:
    • Via successful return from locking functions
    • Via return from wait functions
  • Released two ways:
    • Via success return from unlocking functions
    • Via blocking call to wait functions
conditional variables
Conditional Variables
  • Defined data structure (pthread_cond_t)
  • Used to signal between threads on specific conditions
  • Wait and notification calls utilize conditionals
  • Must be used in conjunction with a mutex
  • Created through function call
  • Destroyed via function call
posix vs java







mutex and semaphore

new and start

no conditional waits, another object could notify when the condition was met



leave run method




POSIX vs. Java
real time java
Real Time Java
  • RealtimeThread
    • Larger priority range
    • Control over scheduling algorithms
  • NoHeapRealtimeThread
    • Can preempt the garbage collector
  • More predictable and better control
  • Java threads encourage a better program structure than POSIX threads.
  • Although with the addition of Real Time thread libraries to Java provides more control and it can approach C++ in some thread performance tests, for programs that need precise control and has hard deadlines Java Real Time threads are not the best choice.
more information
More Information
  • IEEE Standards available through:
    • http://ieeexplore.ieee.org
    • Freely accessible from RIT network
    • Select Standards and enter “1003”
  • The Open Group:
    • http://www.opengroup.org/onlinepubs/000095399/toc.htm
  • Man pages