You are on page 1of 2

a. ANSI C 1. Write code for Strlen(char *). Write the test cases for this code.

int strlen(char *a) { int i = 0; while (a[i] != \0) i++; return i; } 2. Is sizeof() a macro or a function? sizeof() is a macro because ANSI C does not support template type. 3. When would you use a hash table? Specific situations were asked. A hash table or hash map is a data structure that uses a hash function to map identifying values, known as keys (e.g., a person's name), to their associated values (e.g., their telephone number). 4. Say there is an operation like a=b; Its the statement for which you want to avoid concurrency. With out using locks(spin,semaphore,mutex etc. etc.) how would you make this statement protected? By using atomic operations (atomic assign etc.) 5. How would you debug kernel code? 6. How would you do benchmarking (compare the performance) in a device driver code? 7. How would you handle sleeping or blocking instructions in an Interrupt Service Routine(if unavoidable) or basically if the length of ISR is long? Tasklets and Workqueues. 8. How does malloc work? 9. What is virtual memory ? What is the pre-requisite in hardware for supporting virtual memory ? 10. Entry points into kernel? 11. Difference between a semaphore and a mutex?

12. What is an ISR? What are the basic operations there? 13. How can one change the values of the kernel variables during the runtime? It can be done through variables available under /proc/sys/ use sysctl -a to see available parameters. 14. How to find a child process in unix? pstree, ptree, ps 15. What is cache ? How it is used and mapped the physical address cache and virtual address cache ? Cache is a component that improves performance by transparently storing data such that future requests for that data can be served faster. The data that is stored within a cache might be values that have been computed earlier or duplicates of original values that are stored elsewhere. If requested data is contained in the cache (cache hit), this request can be served by simply reading the cache, which is comparably faster. Otherwise (cache miss), the data has to be recomputed or fetched from its original storage location, which is comparably slower. 16. What is IOCTL, how it is used and kernel driver code?