We will be using xv6 OS for this exercise. In this exercise, we will construct a system call that can give read counts on per process basis and then modify it to obtain a system call that will give read counts of all processes since the start of kernel.
To add a system call that can get the number of times the system call 'read' was used in a specific program, we require to make a variable that stores this count for each process.
So, we first start by looking at the files proc.c and proc.h
These files are associated with creating a process. We need to store the count on a per process basis so we will have to add something to the structure that is created for a process.
For that, open proc.h. In this file, the structure for a process is defined. Find struct proc and then add an integer to keep account for the read calls. eg. int readid;