The Driving Midterm
-
How long is a tick?
-
1/10 second
-
1/100 second
-
1/1000 second
-
other
-
What variable holds the number of ticks since the last reboot?
-
Suppose I want to make the speaker produce a 30,000 hz tone. What
register would I change?
-
What value would I put there?
-
(Yes/No) Could I hear the tone?
-
When you install a module that implements a device driver, what's the first
function of the module that is called by the kernel?
-
Under what circumstances will a device have it's read function called before
it's open function?
-
(Yes/No) Can a device ever have it's open and then release functions called,
but not it's read or write functions?
-
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.
-
Suppose someone calls you device's write function, and they offer a length
of -1287. What should your function return?
-
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)
-
pointer
-
pointer+50
-
pointer+107
-
pointer-10
-
Suppose the kernel calls your module's cleanup code, but you don't want
to unload. What return value will prevent you from unloading?
-
How can your module cause itself to be unloaded?
-
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?
-
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.)
-
What is the biggest and smallest possible major number?
BIggest: __________________
Smallest: __________________
-
Beyond open, read, write, and close, list three functions in the "file
operations" structure.
____________________________ _________________________
__________________________
-
(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;
-
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.
-
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.
-
I want to have the function pinto() called in 17 second. Show me
code to do this?
-
(Yes/No) Can a file position ever be negative?
-
Name three function calls that change the file position: _____________
_______________ ____________
-
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?
-
(Yes/No)In a normal device, should all reads the give data to the user
give null terminated data?
-
(Yes/No) In a normal /proc file, that is offering strings of data to the
user, should the /proc file give null terminated strings?
-
What is the most number of processes that can have your device open at
one time?
-
One
-
A few
-
Hundreds
-
Thousands
-
Millions
-
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?
-
(Yes/No) You are running on a multi-CPU computer. Will the kernel
ever call your open and read functions at the same time?
-
I wish to use F.U.S.D. Would a gigabit ethernet be a good candidate
for this driver style? Why?
-
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?
-
How can I prevent it?