3

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?

2
  • It's a good question and I would like to know the answer :D I think, that the most probable, is that you will require to edit the kernel and recompile it to get the whole status of the scheduler..... But posible is :D
    – ncomputers
    Feb 7, 2016 at 6:10
  • 1
    The paper I am following has taken that approach. They even edited some parts of the kernel to allow custom time slicing (linux kernel 2.8.2). Feb 7, 2016 at 6:45

3 Answers 3

3

If you need in depth scheduling info, you could use one of these tools -

  1. perf
  2. SystemTap
  3. dtrace (I dont know what the state of the linux port is)
  4. sysdig

All of these can tap into kernel hooks to display events such as context switches, interrupts, I/O, system calls etc.

0
2

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.

1
  • Thanks a lot! I have been trying to find something like this for a week now. I posted this ques here too : stackoverflow.com/questions/35249464/…, and someone pointed out the Heisenbug. How can I avoid that? Can using virtual env help ? Feb 7, 2016 at 6:32
2

The ps command is a good place to start. It allows you to specify what information to display for a set of selected processes (possibly all processes). You can read the man page for detailed information on the available information you can get, which are specified as flags to the -O option.

The following is a start for what you might want:

 ps -O "%mem nice state upr pri cpu"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .