Operating System

2006 Fall, Project One

Context Switch Ratio

Due Time:

  1. Nov 2nd
  2. Nov 6th night, or TA office hours, M T 5.

Problem:

System call is an interface between users and the kernel. Understanding how the system calls work can help us to know how the user programs communicate with kernel. However, information in the kernel cannot be read directly by the user programs. As we know, context switch happens frequently, and we want to know how often context switch happens to study system behavior.

Project:

You are to design a new system call that can returncurrent values of some new system information counters. You can modify the kernel source or make a kernel module to build this system call. Your output should be exactly the same as the following to print the percentage of context switch happened for each call to scheduler. You should create a new file named “myservice.c”to build your system call and your system call might have some arguments. Your user program name should be“test.c”.

Output:

From <time> to <time>,

Percentage = number of context switch / number of scheduler called

Sample Output

From Thu Oct 19 13:35:35 2006 to Thu Oct 19 13:35:45 2006

90.9% = 5000000 / 5500000

Platform:

OS: Linux, kernel version: 2.6.x

Programming Language: C

Machine: try to find one yourself

Grading:

Kernel modification: 35%

System calldesign: 25%

Program result: 20%

Reports: 10%

Coding style 10%

Bonus :Some special design to improve your output accuracy 15%

Late penalty is 10% per day. E.g. if 2 days late and with grade 90, the final grade will be 90 * 90% * 90% = 72.9

Hint:

To count the number of context switch happened, you should modify <directory to Linux source>/kernel/sched.c and sched.h. You can define and extern the variables in original kernel sources and make your coding in another new source file, for either approaches.

Handing in:

Email TA your source code and simple one page report show how you did it and how good it is, including makefile, *.c, *.h, …, and executables in a zipped file. Make the source code self-documented.

Reference:

(the OS forum)

Understand the Linux Kernel 3rd Edition

Daniel P. Bovet & Macro Cesati, O'REILLY

The other references will be announced later in the OS forum.