I want to know what exactly it means for a thread to be scheduled to run on an LWP. I'm unable to properly visualise the sequence of steps that happen when a process is scheduled to run onto the CPU because a lot of concepts are explained in a high level view. Below is the paragraph that resulted in a lot of head scratching; it is from Operating System Concepts, 10th Edition by Abraham Silberschatz.
One distinction between user-level and kernel-level threads lies in how they are scheduled. On systems implementing the many-to-one (Section 4.3.1) and many-to-many (Section 4.3.3) models, the thread library schedules user- level threads to run on an available LWP . This scheme is known as process- contention scope ( PCS ), since competition for the CPU takes place among threads belonging to the same process. (When we say the thread library schedules user threads onto available LWP's, we do not mean that the threads are actually running on a CPU as that further requires the operating system to schedule the LWP’s kernel thread onto a physical CPU core.)
I'm unable to fully comprehend the need and significance of LWP's here.
Just like a process is a container for memory, the LWP (= kernel-level thread) is a container for fibers (= user-level threads, essentially).
The kernel's thread scheduler only sees kernel-level threads (LWPs), and it schedules LWPs on and off the CPUs - namely, an LWP has a time slice where it gets to run on a CPU. The user-level thread library (= fiber scheduler) owns the LWPs of that process, and it decides which fibers get to use the timeslices allocated by the kernel's scheduler to those LWPs.
When a fiber decides to yield the CPU, but the LWP's timeslice is not over yet, the fiber scheduler schedules another fiber to run within the LWP on that CPU. But while that other fiber is running, the LWP's timeslice might run out, and the kernel's scheduler will schedule that LWP off the CPU. The fiber scheduler will not have a say on the matter - the fiber scheduler won't even get to run, because it's in userspace and the kernel is not aware of it.