LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   new system call implementation help (https://www.linuxquestions.org/questions/linux-newbie-8/new-system-call-implementation-help-4175413496/)

Rhasz 06-26-2012 01:32 PM

new system call implementation help
 
I have a project assignment that I need help with. The following is the description.
//////////////////////////////////////////////////////////////////////////
There are four system calls in Linux related to creating new processes: fork, vfork, execve, and clone. (The man pages will describe for you the differences among them.) Instrument the kernel so that we can write a user-level program that will print counts of the number of times each of these four system calls has been invoked (by any process on the system); that is, I want to write a garden-variety C program that prints out the total number of invocations of each of these four system calls (by any process on the system).

To do this requires three things:

***1. Modify the kernel to keep track of this information.***

***2. Design and implement a new system call that will get this data back to the user application.***

3. Write the user application.

We'd also like to be able to reset these statistics periodically. So we need a way to clear the request information we've tracked so far. This requires either parameterizing the above system call to add a clear option, or adding another system call.
/////////////////////////////////////////////////////////////////////////////

I found these sources on how to add system calls in general.
http://www.linuxchix.org/content/cou...acking/lesson9
http://tldp.org/HOWTO/html_single/Im....6-i386/#AEN22

***I need direction on how to do step 1 and step 2.***
Here is the full project description.
http://www.cs.washington.edu/homes/z...all/proj1.html

I have part one done.
This is an independent study assignment so there are no notes or lectures and I have no kernel development experience.

Also, I have the kernel source tree but am unable to make it because the memory space on the server is too low. So I will be unable to do any testing of the kernel until the administrator fixes the memory issue. The compiling was going along for almost an hour before space ran out. Is it normal for it to take that long?
Any help will be nice.

smallpond 06-26-2012 10:37 PM

Linux does not run out of memory. Like every other modern OS it uses virtual memory. You ran out of swap space. The reason the compile took so long is that swapping to disk is slow. Increasing the swap space will allow your compile to complete (slowly). Adding more RAM will remove the need to swap so it will also make your build faster.

1) Increment a counter at the right place in each call.

2) Add a system call to read the counters. If you want an A instead of a C use locks to make sure that you don't read a counter while it is being updated or else use atomic operations.

Make sure you compile and run the UNMODIFIED kernel before making any changes. Otherwise you'll never figure out whether its something you changed or something wrong in what you started with.


All times are GMT -5. The time now is 01:13 AM.