LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-09-2016, 12:17 PM   #1
MUHAMMAD ABID SHAHZAD
LQ Newbie
 
Registered: May 2016
Posts: 2

Rep: Reputation: Disabled
context switching in linux using c programming


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 )
 
Old 05-09-2016, 12:53 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by MUHAMMAD ABID SHAHZAD View Post
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.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
context switching program aamir100 Programming 1 05-04-2016 12:55 AM
What is context switching bunhead2015 Linux - Newbie 6 06-05-2015 02:34 PM
how to increase the speed of context switching in linux zerop Linux - Kernel 1 07-27-2014 11:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration