Concurrency Ability
concurrency ability
blockability
Illustrate behavior of
singlethread.
Emphasis on whether this thread ispauseon execution or not.
We consider current function is blocking function if any instruction of this function is blocking.
Otherwise we say this function is non-blocking function.
blocking
Current thread is paused on execution, usually due to waiting for resources.
For instance:
scanffunction inCwill wait for user keyboard input.readsystem call to load data from network.writesystem call to flush data to persistence layer.- current thread waiting for resource lock to release from another thread.
All the examples illustrate the fact that, while executing blocking function, current thread must wait for other threads or operating system to finish the underlying task before executing next instruction.
Blocking has nothing to do with user thread. Just as example 1-3 above, current thread is waiting for OS to finish its job. But as a matter of fact, OS operation is done by system thread, hence it is still deemed as thread.
But blocking can wait on another user thread, as shown for case 4.
In all, blocking emphasis on pause behavior of single thread, but it must happen because of another thread, regardless of system or user thread.
non-blocking
Current thread does not wait. It keeps executing instruction without pause.
synchronization
Illustrate behavior between
multiplethreads.
Emphasis on whether thread shouldcoordinatewith other threads or not.
We consider a function that involves only single thread or does not need to coordinate with other threads at all as non-synchronized.
1 | |
One the other hand, a function is synchronized/asynchronized if thread have to coordinate with others.
In detail:
synchronized
A function is synchronized if thread must process communication immediately after sent/receipt. Like answering phone call.
1 | |
asynchronized
A function is asynchronized if thread is able to process communication whenever comfortable. Like email communication.
1 | |
multiplexing
This conception is regarding how a single thread should handle request.
A function is not multiplexing if the single thread is to solely handle the entire request from inbound to outbound. From connection acceptence to read/write and eventually, disconnection etc.,
Upon completion, this thread is released or terminated. It is more like a dedicate maid of a client.
Otherwise, if the single thread will handle across multiple request. The thread will provide service separately.
For instance it will handle connection establishment of many client, also handle I/O of many client as well. It does not dedicate to specific request.
This would drastically enhance the performance.