In the context of process scheduling, does the operating system intervene after each time slice/quantum ends? For example if the computer was idle and 4 tasks arrived : t1, t2, t3 and t4, and they got scheduled using first-come-first-serve, we would normally consider t1, t2, t3, t4 to be in the CPU but isn't this a simplification? Because it we t1, OS, t2, OS, t3 OS t4 is what would actually happen? If it's true the OS intervenes after each time slice (aka quantum) isn't this very inefficient?
Not necessarily. Typically the scheduler will lower the dynamic priority of a task after its quantum expires, but if it is still the highest priority task, then it gets another. In general though, yes, when the task has run long enough, the OS takes over and switches to another. Why should that be inefficient?
I believe that in modern operating systems the time-slices are variable length. The scheduler is invoked after servicing every interrupt (keyboard, mouse, touchscreen, network, disk-transfer finished, ...) as well as the timer interrupts.
Roughly speaking, the scheduler is designed to estimate the moving average of the times between a process's blocking system calls. Before the scheduler gives control to process X it sets up a timer that will interrupt at a time just slightly longer than process X's moving average. If the scheduler is doing a good job of guessing the time to the next blocking system call, then a large fraction of processes will actually voluntarily release the CPU by doing a blocking system call.
The goal is to get interactive processes to do a little bit of computation, make a blocking system call to request some data from a slow device, and then get rescheduled as soon as the data is returned. If the scheduler has to decide between scheduling between two processes, then all other things being equal, it will favor the process that is making blocking system calls more frequently. This tends to maximize the number of simultaneous blocking i/o requests, which improves overall system throughput.