I think you are idiotic, since you are saying that you have
to use like an hybrid way of using blocking and lock-free, but it is an idiotic
way of doing since you will lose some important advantages of lock-free ,
so it is why i am not idiotically throwing away lock-free queues as you are
doing it, since i still want to take advantage of the characteristics of the
being lock-free, so you have to read my following other extended answer
so that you notice that operating systems schedulers such as Windows
and Linux are giving a big enough time slice that allows the next producer
to successfully put the item in the lock-free queue. So read my following
extended thoughts about it:
I say that eventhough the producer is scheduled away ,
you have to think about the big enough time slice that allows
the next producer to successfully put the item in the lock-free queue,
and as we know that each software thread gets a short turn,
called a time slice, to run on a hardware thread. When the time slice
runs out, the scheduler suspends the thread and allows the next
thread waiting its turn to run on the hardware thread. And time slicing
ensures that all software threads make some progress. And as we know
that there is the overhead of saving the register state of a thread when
suspending it, and restoring the state when resuming it.
You might be surprised how much state there is on modern processors.
However, schedulers typically allocate big enough time slices so that
the save/restore overheads are insignificant, so this obvious overhead
is in fact not much of a concern.
So you are like idiotic Bonita Montero, since it is as you are comparing
the locks that use CPU-intensive spinning and mutexes that don't use it,
so we can use CPU-intensive spinning if the critical section is small,
so it is by logical analogy the same as lock-free algorithms, since
lock-free algorithms need from you to control correctly the situation or
the context, i mean that you have to know how to tune the number of
threads of the system including the consumers and producers of the
lock-free queues so that to be able to benefit from advantages of the