CS-550 Section 01 Spring 2020 Assignment 02

Character Device Driver to List Processes

Goals

The goal of this assignment is to write a Kernel Character Device Driver for a "device" which lists all processes, along with information about those processes. This assignment should provide experience with developing Kernel Modules, and learning about character device drivers, as well as how the kernel manages processes.

[Description] [References][Grading Guidelines]

Description

  1. Implement a kernel module in dev_ps.c that creates a /dev/process_list character device. The character device should support the read() operation. When the read() system call is invoked on your character device from a user space process, your kernel module should return to the following information for all currently running processes:
    1. The process ID
    2. The parent process ID
    3. The CPU on which the process is running
    4. The current state of the process

    For example, the output might look as follows:

      PID=1 PPID=0 CPU=4 STATE=TASK_RUNNING
      PID=2 PPID=0 CPU=2 STATE=TASK_INTERRUPTIBLE
      PID=10 PPID=2 CPU=0 STATE=TASK_UNINTERRUPTIBLE
      PID=16434 PPID=16424 CPU=10 STATE=TASK_DEAD
      PID=14820 PPID=16424 CPU=8 STATE=TASK_WAKEKILL,TASK_UNINTERRUPTIBLE
      ...and so forth
    

    Hints:

  2. Provide a user-space C program called user.c that opens your character device and outputs the list of processes retrieved from your character device. For example, your user program might look like:
      char *buffer;
    
      /* allocate memory for character buffers HERE before you use them */
    
      fd = open("/dev/process_list", O_RDONLY);
      /* check for errors HERE */
    
      while(!some termination condition)
      {
          bytes_read = read(fd, buffer, buffer_length);
          /* check for errors HERE. Exit loop if all processes have been retrieved. */
          /* print the output you have read so far. */
      }
    
    close(fd);
    

References

Here are some references which might be useful for this assignment:

Grading Guidelines

Tar and gzip a directory that contains the following:

We will grade your results as follows:

Note that as long as your code runs, you may make your own implementation decisions about anything not explicitly described in the instructions and grading criteria above. Use the README file to document specific decisions you make.