
Can you tell me what is the difference between the two red arrows in Unix process diagram?
Why preempted process goes directly to User Running without rescheduling? I don’t quite get it. Why Preempted and Ready to Run In Memery are connected with dashed line?
Thanks in advance.
A preempted process is ready to run in memory, which is why there is a dashed line between the Preempted and Ready to Run in Memory states on this diagram. A CPU-intensive process typically is doing work and using the CPU for an entire time slice, until a timer tick fires at the hardware level and causes the kernel to preempt the process. That doesn’t make the process any less ready to run, because in the act of preempting the process the kernel saves all the datastructures it needs for a context switch.
However, a preempted process isn’t necessarily ready to run in user mode. Instead, the kernel may preempt itself, because the kernel is doing some work when a network packet arrives, or a disk read completes, or the timer tick fires, or some other event causes preemption. If the process was originally running in user mode when it was preempted (the situation I describe in the first paragraph), then it returns to user mode whenever the scheduler decides it should run again. That’s the leftmost red arrow. On the other hand, if the process was preempted while running in kernel mode, it returns to kernel mode whenever the scheduler decides it should run again. That’s the other red arrow.