Feature #3: Schedule Processes

Implementing the "Schedule Processes" feature for our "Operating System" project.


When a system is booted, the operating system needs to run a number of processes. Some processes have dependencies, which are specified using ordered pairs of the form (a, b); this means that process b must be run before process a. Some processes don’t have any dependencies, meaning they don’t have to wait for any processes to finish. Additionally, there cannot be any circular dependencies between the processes like (a, b)(b, a). In order to successfully start the system, the operating system needs to select an ordering to run the processes. The processes should be ordered in such a way that whenever a process is scheduled all of its dependencies are already met.

We’ll be provided with the total number of processes, n, and an array of process dependencies. Our task is to determine the order in which the processes should run. The processes in the dependency array will be represented by their ID’s.

Here is an illustration to better understand this:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.