CS 635 PROJECT 4 Due Date: Noon Monday 04/14/2003 The purpose of this project is to construct a tool for studying the relative frequencies with which the various Linux system-calls are being invoked by application programs, and to learn how interrupt-handlers can be 'intercepted' by using some assembly language code within our module. PROJECT STATEMENT Write a Linux kernel module (named 'syscalls.c') which installs its own exception-handler for software interrupt 0x80 (the Linux system-call interface). Your module should create an array of counters, initialized to zeros, enough for every implemented system-call (the exact number can be determined using a system constant (named NR_syscalls) defined in the kernel header . Whenever the exception-handler is invoked, it increments the counter corresponding to the specific system-call that is being requested. And your module should create a '/proc' pseudo-file that allows users to view a screen-display showing some usage statistics for the twenty most frequently invoked system-calls. Your module should display the following statistical information on these "top twenty" system-calls: The ID-number of each system-call being reported The official name of this system-call in kernel sources The absolute number of times this system-call has been invoked Its relative frequency (as a percentage of all system-calls) You will need to build an array of pointers to character-strings for the names of the various system-calls. You will find a complete listing for the system-call names and their ID-numbers in the header- file -- although not yet in a format which your module can directly use. So, unless you want to individually retype (and proofread) that complete list of over two hundred system-call names, you'll want to automate that job by writing an application-program (similar to a 'wizard') that reads the file, extracts the names and ID-numbers of all system calls, and creates your own local header-file (e.g., "syscalls.h") which defines the needed array of string-pointers; e.g., looking like this: // syscalls.h static const char *name[ NR_syscalls ] = { "", "exit", // 1 "fork", // 2 "read", // 3 "write", // 4 "open", // 5 "close", // 6 "waitpid", // 7 ..... }; ------------------------------------------------------------------------ (c) Allan B. Cruse University of San Francisco Spring 2003