Part I ------ Objective: experience exception handling in Linux kernel task steps 0. Write a program to cause divide-by-zero exception. Write a signal handler to handle devision-by-zero exception in the user space. Observe the execution behavior. 1. Locate the code in kernel source which handles this exception. Insert a hook (see ex-1) to transfer control to a module. Make sure your kernel code execution continues conditionally depending on the return value of the hook implementation. For example, continue kernel code execution if the return value is 0, return from kernel exception handler otherwise. Also pass appropriate parameters to the call back (see the next steps) to avoid multiple cycles of kernel modification. 2. Observe the user space program behavior if the kernel exception handler is force terminated. 3. Modify the kernel handler (in the module) to ensure continuation of user space program (w/o the signal handler) to completion. 4. Modify the kernel handler (in module) to ensure continuation of user space program (with the signal handler) to completion. Part II ------- Objective: understand and implement user-kernel interactions through char devices, sysfs and procfs task steps 0. Compile the demo module discussed in the class, downloadable from https://www.cse.iitk.ac.in/users/deba/cs698z/resources/sysfs_chardev.tgz. Use this module to instantiate and communicate through the char device and sysfs interface as demonstrated in the class. 1. Extend the char device to implement read and write functionalities - only one process is allowed to open for read and/or write adhering to the "buffer_size" value which can be changed dynamically in the userspace through sysfs. - create three new sysfs variables to maintain (i) current buffer usage count (ii) total bytes read (iii) total bytes written 2. Implement the same functionalities for multiple reader and writer processes. - Data once read from the buffer by a process is not available for other readers. Visualize the writers as 'request generators' and readers as 'request handlers'. - Apart from global metrics in previous step, additionally maintain per-process values for the same metrics in a subdirectory under "demodev" identified by process-id. Hint: the processes performing open and close should trigger creation and deletion of a subdirectory named 'pid' of the process, respectively. 3. Implement an ioctl (see LDD-06) to control the number of active readers and writers.