COSC440

Assignment 1 (20%)

In this assignment, implement a virtual ramdisk as a character device based on this template module.

You can write to the device and read from the device using

$ ls > /dev/asgn1
and
$ cat /dev/asgn1
You should be able to write to the device with unlimited size of files (it is limited by the available memory space of your system, of course).

To manage your device memory, you should get a page using alloc_page() when more memory is needed. The pages should be linked together using double-linked list, so that the total number of pages is unlimited. Please use the kernel list utilities to manage the list (e.g. LIST_HEAD, list_add, list_del, list_entry, list_empty).

When the device is opened as write only, you should remove the page list and free the pages you requested.

Users should be able to seek the device.

The device should be controlled with ioctl() regarding the maximum number of users (processes) accessing the device. If there are more than the maximum number of processes to access the memory device, open() should deny their access.

Make sure you free any memory when the module is unloaded.

Note: The template uses udev to automatically create/destroy nodes upon module loading/unloading. the node name is asgn1, which after loading the module, you need to change its permission to allow everyone to read and write from it.

Assessment schedule:

  • 12% for working code
  • 3% for design
  • 2% for understandable comments
  • 3% for extra challenges. For examples, but not limited to:
    • mmap() implementation. The user-space program mmap_test to test your implementation is already included in the tarball.
    • using memory cache.

    Submission due date: 4pm Wednesday 23 August.

    Source code of your module should be tarballed and submitted to Zhiyi by email by the due date and time.