The Driving Midterm

  1. How long is a tick?
    1. 1/10 second
    2. 1/100 second
    3. 1/1000 second
    4. other
  2. What variable holds the number of ticks since the last reboot?

  3. Suppose I want to make the speaker produce a 30,000 hz tone.  What register would I change?

  4. What value would I put there?

  5. (Yes/No) Could I hear the tone?
  6. When you install a module that implements a device driver, what's the first function of the module that is called by the kernel?

  7. Under what circumstances will a device have it's read function called before it's open function?




  8. (Yes/No) Can a device ever have it's open and then release functions called, but not it's read or write functions?
  9. Suppose someone calls your device's write function.  How can you tell if the data pointer is valid?  I'm looking for a line or three of code.



  10. Suppose someone calls you device's write function, and they offer a length of -1287.  What should your function return?



  11. Some has called your read function.  The gave you a valid pointer, and a length of 100.  Is it acceptable to change the byte pointed to by ... (circle all that apply)
    1. pointer
    2. pointer+50
    3. pointer+107
    4. pointer-10
  12. Suppose the kernel calls your module's cleanup code, but you don't want to unload.  What return value will prevent you from unloading?

  13. How can your module cause itself to be unloaded?



  14. Suppose I have two device files with the same major and minor number.  How can my device tell which file is being open when the kernel calls my open call?


  15. I have a device /dev/porche, major and minor of 12/5.  I have a device /dev/chevy, major and minor of 12/7.  How can the write fuction of the associated device tell which files was accessed?  (I want code here.)


  16. What is the biggest and smallest possible major number?
    BIggest: __________________
    Smallest: __________________
  17. Beyond open, read, write, and close, list three functions in the "file operations" structure.
    ____________________________       _________________________     __________________________
  18. (Virtual/Phyical)Suppose I run the following code in a kernel module.  Is the memory reference a virtual or a phyical address?
    int *ptr = 12345;
    *ptr = 12;
  19. I wish to allocate from within a kernel module 17 bytes.  Show me code that does this?  Be sure to check for errors in case the allocation fails.





  20. Suppose a user has called read.  He gave me a pointer named 'base'.  I wish to put the letters 'c', 'a',  and 'r' into consecutive places starting at that pointer.  Show me code to do this.




  21. I want to have the function pinto() called in 17 second.  Show me code to do this?







  22. (Yes/No) Can a file position ever be negative?
  23. Name three function calls that change the file position:  _____________ _______________ ____________
  24. Suppose I have a device file called /dev/chevycamero.  It returns the letters of "chevycamero" in that order, and then end-of-file.  If the file descriptor is at 7, and I request a read of 6 bytes, what should that read return?

  25. (Yes/No)In a normal device, should all reads the give data to the user give null terminated data?
  26. (Yes/No) In a normal /proc file, that is offering strings of data to the user, should the /proc file give null terminated strings?
  27. What is the most number of processes that can have your device open at one time?
    1. One
    2. A few
    3. Hundreds
    4. Thousands
    5. Millions
  28. In my device, I need to keep track of the order in which it was opened.  For the first open, I need to associate with that file descriptor a '1'.  For the second open I need to associate with that file descriptor a '2', and so on.  Where is the best place to store this data?



  29. (Yes/No) You are running on a multi-CPU computer.  Will the kernel ever call your open and read functions at the same time?
  30. I wish to use F.U.S.D.  Would a gigabit ethernet be a good candidate for this driver style?  Why?




  31. Suppose I have a hard drive attached to a USB controller.  The user disconnects the drive without unmounting it first.  How can I the device driver writer cope with this?




  32. How can I prevent it?