Final Review Information
Topics Covered:
- Kernel C Programming. Pointers, kmalloc, casting void* as other things, arrays, structures with pointers included, binary arithmatic, macros, stuff we covered when talking about kernel modules
- /proc including read and write functions
- Writing kernel modules. init and cleanup functions, timers, keyboard, input devices, kernel data structures, network hooks.
- Generic OS topics like memory management, block devices, filesystems, process management, page cache, device drivers.
- Why might this crash the computer question.
- Maybe something on concurrency in the kernel.
- A simple question on Rust that won't require you to write any code
Here are a few sample questions:
- Suppose a computer has 1gb of RAM, and no swap space, and two processes each call malloc and request 600mb. Both requests are granted. One process then uses all 600mb. After this, the other process attempts to use all 600mb. What will happen next?
- Why do many filesystems use a B-tree to store information that must be looked up?
- Why does the page cache have two levels?
- Declare a function that takes a pointer to a function as an argument. The argument should be a pointer to a function that takes an integer and a float, and returns a char*
- Inside a proc_read function, 4000 characters are available to return to the user, in an array called buf. "buf" is declared as char buf[8000], but only contains 4000 characters. The user will call the function with less than 4000 characters available in the userspace buffer. Complete the following function to return no more than the user buffer can hold.
ssize_t proc_read(struct file *filp, char *user_buffer, size_t ubuf_size, loff_t *offp){
copy_to_user(user_buffer, buf, 4000); // Oh no! This will overfill the user's buffer!
return 4000;
}
- Give 3 examples of a block device.
- Suppose you have adapted an atari controller as an input device. The device calls input_report_rel and input_report_key when specific actions are triggers. Is this an example of a block device? Why or why not?
- Suppose a device is to be added, with a control file in /dev. The device is a USB nerf gun turret. How can you prevent two processes from giving conflicting instructions to the turret?
- What is borrowing in Rust? How is borrow different than move?
- How does a move enable passing a heap-allocated structure to a thread in Rust, in constrast to the default passing method of borrow?
Format
The test will have some short answer and some programming problems. It will be on paper, in MLH 310. One page of multiple choice, followed by short answer and programming. All programming questions will be answerable without too many lines of code.
Notes
Ten pages of notes are allowed, 8.5 by 11 two sided.