Specified mutex attribute when initializing mutex.
Added asserts when modifying head and tail.
Simplified cb_read_single.
Added check for amount in cb_write function.
Use mutex in cb_clear.