Emutex Fibers Library and how it can improve your packet processing applications.
The quantity of CPU cycles consumed by the overhead of thread switching in Linux is often not considered in many real-time software applications. However, when processing tens of thousands of network packets per second on a CPU the overhead can become so significant that it can unfairly prohibit the volume of traffic processed by the CPU.
Software engineers can reduce thread switching costs in high performance Linux applications by using cooperative multi-tasked fibers instead of pre-emptive multi-tasked threads. To assist with this transition, Emutex has developed the Emutex Fibers Library. In software engineering terms, a fiber is a very light weight thread of execution. Like threads, each fiber may have its own stack pointer but unlike threads a fiber does not have its own task context and is not scheduled by the kernel. This has several advantages from a developer's perspective. In addition to having a lower context switch time, the cooperative multi-tasking nature of fibers obviates much of the need for traditional locks such as semaphores and spinlocks. It also allows a developer to have more control over context switches and to implement more deterministic scheduling policies than with native Linux processes. This is because fibers must explicitly yield execution to allow other fibers to run. Since fibers do not pre-empt each other, their concurrency is referred to as cooperative multi-tasking as opposed to pre-emptive multi-tasking.