a simple program in C for context switching

Context Switching, particularly, is a switching mechanism of the CPU which is done by storing
the state (i.e. registers and pc etc.) of one process to a persistent storage location and loading the
stateof another process into main memory. The Linux Kernel is responsible to keep the track of
all context switches which are made during the processes or threads life cycle.
In this question, you have to develop a utility in C language which will extend the Linux Kernel
implementation and extract the number of Voluntary Context Switches and Involuntary
Context Switches of a process. After that, to test the functionality, write a simple program in C,
which just display the results to the screen as follows;

Pid : 123
nr_voluntary_switches : 10
nr_involuntary_switches : 12
You have to provide your own implementation, you are not allowed to use any C function that
takes an argument of any Linux command and executes that command.
With source code of the application (test program and modified kernel files etc.), screen-shots
after running this application are also required.
(Hint: getrusage() system call provides the system resource information of a process in struct
named task_struct, to get desired values, modify this struct along with INIT_TASK macro;
both are available in sched.h )

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!