Linux – Process scheduling data on linux

linuxprocessschedulingvirtual machine

I am doing a project on OS and require the process scheduling data for an operating system. The data has to include the list of all processes in short-term-scheduler and long-term-scheduler along with the CPU time slice and memory requirement of every one of them. Also I need the data on when and by what process is every other process preempted. Is there a way to collect all that data in linux? How can I do that?

In linux source code, there is a structure task_struct in include/linux/sched.h. Is there a way to get the state of every object of that structure as well?

Best Answer

You can get a lot of internal information about processes, the scheduler, and other components of the OS and the hardware by using

cat /proc/...

where ... can be many things. For instance, it could be a process ID, followed by a lot of specific information request, or scheduler debug information request, for example:

cat /proc/sched_debug

To see the whole list of options, type ls /proc . You will see a long list of process ID numbers, but also a few interesting names, such as sched_debug, cpuinfo, meminfo, uptime, and more.

All this is available thanks to the virtual file system procfs You can read more about it here.

Another useful command is:

top

This will show a real time information about how the processes are scheduled, memory usage, and more.

Related Question