Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sesiuni:kernel:day-5 [2013/07/04 00:05]
alexj [Tasks]
sesiuni:kernel:day-5 [2013/07/05 08:12] (current)
alexj [Tasks]
Line 20: Line 20:
 #** sudo mknod /dev/mydev c 42 0  #** sudo mknod /dev/mydev c 42 0 
 #** All the code is implemented by commented out. Take each ''​TODO''​ and analyse the commented code and then uncomment it step by step. #** All the code is implemented by commented out. Take each ''​TODO''​ and analyse the commented code and then uncomment it step by step.
 +#** After implementing TODO 1a and TODO 1b, compile, load the module and view the contents of ''/​proc/​devices''​ to see that the kernel module registered the major number.
 +#* After implementing TODO 5, compile, load the module and do a ''​cat /​dev/​mydev''​ and and ''​echo something>/​dev/​mydev''​ and see the dmesg messages.
 +#* After implementing all TODOs, write something into /dev/mydev and read from it.
 # Double the work, same effort # Double the work, same effort
 #* Modify the code such as the device driver could handle more devices (NUM_MINORS devices) #* Modify the code such as the device driver could handle more devices (NUM_MINORS devices)
Line 25: Line 28:
 #** Most code can be reused (such as the file operations),​ but each device needs it's own instance of the struct my_device_data and each cdev structure needs to be initiated. #** Most code can be reused (such as the file operations),​ but each device needs it's own instance of the struct my_device_data and each cdev structure needs to be initiated.
 #** Use a static array of my_device_data[NUM_MINORS]. Iterate from 0 to NUM_MINORS and initiate all needed structures. #** Use a static array of my_device_data[NUM_MINORS]. Iterate from 0 to NUM_MINORS and initiate all needed structures.
 +# Unique access
 +#* Create a new character device that prints out the string "​42"​ forever (sort of like /dev/zero).
 +#* Implement only the open, read, and release file operation (make mocks for the rest).
 +#* Try to access the device driver with two cat processes (in two terminals, for example).
 +#* Attach an atomic variable to the char_device structure that keeps track of how many processes access the device
 +#* In the open handler, set the variable to 1 if is set to 0; if it's already set to 1, return -EBUSY
 +#* Try to access the device driver again with two cat processes.
sesiuni/kernel/day-5.1372885516.txt.gz · Last modified: 2013/07/04 00:05 by alexj