Explain the concept of CPU scheduling.
CPU scheduling is a core function of operating systems that manages the allocation of CPU (Central Processing Unit) time among processes or threads competing for execution. Its primary goal is to maximize system throughput, minimize response time, and ensure fairness among users or processes. Scheduling algorithms determine which process should run next and for how long, balancing between different criteria such as CPU utilization, throughput, turnaround time, and response time. Examples of scheduling algorithms include First-Come, First-Served (FCFS), Round Robin (RR), Shortest Job Next (SJN), and Priority Scheduling.