Synchronization Mechanism

STREAMS uses a synchronization-queueing mechanism that maximizes execution throughput. A synchronization queue is a linked list of structures.

Each structure encapsulates a callback to a function attempting to access a resource. A thread which cannot block (a service procedure, for example) can access the resource using a transparent call.

  • If the resource is already held by another thread, the thread puts a request on the resource's synchronization queue.
  • If the resource is free, the thread executes its request immediately. After having done its job, and before releasing the resource, the thread goes through the synchronization queue and executes all the pending requests.

In either case, the call returns immediately. Routines performing synchronous operations, like stream head routines, are blocked until they gain access to the resource. Although the mechanism is completely transparent, the user needs to set the adequate synchronization level.