I am trying to grasp the idea of thread scheduling in operating system. My professor said - I can use cooperative scheduling at process level, and kernel has inbuilt preemptive scheduling.
Now I am confused, say my process has 2 threads, and kernel has timer based thread scheduling. Now in my process thread after some particular code, I have invoked the yield() function to transfer the control to other thread in my process. But, before reaching this yield function in my program, what happens if the kernel automatically holds my thread (owing to preemptive nature of scheduling) and transfer control to some other thread. Then the whole idea of having control on the threads of my process goes void.
If someone can kindly answer I would greatly appreciate!