Question: I have written a c program which shows voluntary and involuntary context switches but when I run the program, it gives 0 now i want

I have written a c program which shows voluntary and involuntary context switches but when I run the program, it gives 0

now i want to print three values

Pid : 123 nr_voluntary_switches : 10 nr_involuntary_switches : 12

I have to modify the struct named task_struct, to get desired values, modify this struct along with INIT_TASK macro;

but I have not much skills to modify these values and also help me to modify this program

#include #include #include #include #include #include int main(int argc, char *argv[]) { pid_t getpid(void);

struct rusage ru; getrusage(RUSAGE_SELF, &ru); printf(" voluntary context switches %ld,involuntary context switches %ld ", ru.ru_nvcsw,ru.ru_nivcsw);

}

plz help me

thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!