CMPS 105 Fall04: Systems Programming

Programming Assignment #6: Process Information


Remember: your programming assignment must be turned in online.


The Basics

The goal of this assignment is to get familiar with the 'ps' command.

In this assignment, you are to implement the 'ps' command. It will be called like this:

 >myPS 

where the output of this command is similar to what you would get as output of command 'ps -f -l' on your system. You need not show the information for the processes that are not owned by you.


The Details

To implement your program, you will need the following system calls :open(), close(), fread() and fwrite().

Use the man pages to read up on how to use these functions. These are defined in section two of the manual, and have the same name as other commands or functions, so you should call man like this: "man -s2 open" to tell it to give you the open description from section 2.

The information about all the processes is stored in the directory '/proc'. All the subdirectories in this directory are named by the corresponding process-ids. You might need to look at the files 'lstatus' and 'psinfo' in each subdirectory for getting all the relvant information for each process. Note that the data in these files cannot be read using normal text editors. You would need to use the header file 'sys/procfs.h' and the strucutres defined in that file to access the data in the files 'lstatus' and 'psinfo' (You can directly include procfs.h file in you code to use the structures). Do 'man -s4 proc' to know more about how to get the required information.

Note: You must check and correctly handle all return values. This means that you need to read the man pages for each function to figure out what the possible return values are, what errors they indicate, and what you must do when you get that error.


What to turn in

Your code, a working makefile and your design document. In addition, include a README file to explain anything unusual to the TA — testing procedures, etc.

REMEMBER: Do not submit object files, assembler files, or executables. Every file in the submit directory that could be generated automatically by the compiler or assembler will result in a deduction from your programming assignment grade.