Recommended

Multicore community

 

Articles

Intel.com

Microsoft.co.il

 

Community

Microsoft Forums

Intel's Forum

Intel's Multicore Community

 

Resources

http://msdn.com/concurrency

Intel Multicore

NVidia Multicore GPU

 

Downloads

.Net Parallel Extensions

Intel's TBB

WinModules   

 

Tools

AsyncOp Logger

Intel thread analysis

Intel VTune

 

Contact

Asaf Shelly

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ichilov

-->

 

 

 

 

 

 
2 / 1
 
 
 
 
 
 
 

Synchronization API

In this section we go over the common API used for synchronization. Not all API are available on all operating systems and libraries. The section covers the majority of common API as a general concept with little reference to specific library implementation and parameters.

The API can be grouped into several sets as follows:

 

Task

The task API set deals with creation and destruction of tasks which means Processes, Threads, Fibers, and so on.

 

Wait

Today the majority of operating systems and libraries use Wait API for synchronization. A task can wait for something to happen and while it is waiting it will not waste CPU time. It is possible to wait for a MUTEX to release, an Event to happen, a Semaphore, etc.

 

Lock

Lock is a core element of synchronization today. We use this API set to synchronize access to resources in code. Only one Task can own the locking element and all other Tasks can wait for it. These include MUTEX object, Critical Sections etc.

 

Event

Every parallel system reacts to events. Events are basic elements of interruptible systems. Tasks wait on Events that other Tasks can signal. Software events in an interruptible system are called Events. Hardware events in an interruptible system are called Interrupts.

 

Count

The majority of libraries also include an implementation of a counter. This API is usually called Semaphore and can either count to a limit or unlimited depending on the library.

 

Timer

A Timer is also a synchronization element because it allows synchronous operations periodically. There are timers that can send an event and there are timers that can block a Task that it waiting until the time has elapsed.

 

Atomic Operations

Most high level CPUs support Read-Modify-Write sequences in a single op-codes (represented as a single Assembly instruction). The CPU cannot perform a Context Switch during an op-code so this is considered thread safe. These op-codes represented in high level API are called Atomic Operations.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
 
 
 
 
 
   
 
 
  MUTEX  
 
 

The term MUTEX stands for Mutual Exclusion which signifies that Tasks use this synchronization object to mutually exclude access from each other to resources.

 
 
 
 
 
 
   
 
 
  Condition Variables  
 
 

Condition Variables are common in versions of the UNIX operating system. Microsoft introduced support for Condition Variables with Windows Vista. On Windows OS the synchronization object is interprocess and therefore does not have a name and cannot be shared between processes.

 
 
 
 
 
 
   
 
 
  APC  
 
 

Asynchronous Procedure Call is a synchronization mechanism that works somewhat differently from the common and simpler synchronization objects.

 
 
 
 
 
 
   
 
 
  TLS  
 
 

Thread Local Storage is one of the better ways to work in a parallelized system: non - parallel.