Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 )
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 )
So aside from posting your verbatim homework question, where are you stuck, and what is your question???? Read the "Question Guidelines" link in my posting signature.
We will help you, but we WILL NOT write your code for you, do your homework for you, or otherwise give you a handout. Show effort of your own.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.