Home work#9
Conversation
AleksandrBulyshchenko
left a comment
There was a problem hiding this comment.
- Please format the PR according to wiki:
- conform to code standards;
- add better messages;
- take into account my comments to #7 (as these implementations are identical except hrtimer addon);
- present more flexible example of memory allocation,
you can do that while implementingkmem_cache-based solution; - fix issues in time-management solutions;
- regarding
hrtimersolution:- adapted Tsiliuric's example is a good start, but at least requires cleaning up;
- I hope to see polished solution if not created from the scratch.
|
|
||
| int __init x_init(void) { | ||
| int res; | ||
| buf_msg = kmalloc(LEN_MSG+1,GFP_KERNEL | __GFP_ZERO); |
There was a problem hiding this comment.
Very straightforward replacement of static buffer.
But dynamic allocation allow more flexible memory management.
There was a problem hiding this comment.
It was my first attempt to make pull request. Not very successful attempt. Please see pull requests 39 and 40. They refer to dynamic memory allocation and time management respectively. P.S. How can I delete this pull request (№9)?
| @@ -0,0 +1,22 @@ | |||
| # | |||
| # Memory management example | |||
There was a problem hiding this comment.
Don't forget to update comments
| static ssize_t xxx_show( struct class *class, struct class_attribute *attr, char *buf ) { | ||
| struct timeval tv_cur; | ||
| strcpy( buf, buf_msg ); | ||
| do_gettimeofday(&tv_cur); |
There was a problem hiding this comment.
IMO, absolute time API (do_gettimeofday) isn't the best choice for time interval measurement in uptime (but may be used).
|
|
||
| static ssize_t xxx_show( struct class *class, struct class_attribute *attr, char *buf ) { | ||
| strcpy( buf, buf_msg ); | ||
| printk( "previous absolute read time: %ld s %ld mks\n", tv->tv_sec, tv->tv_usec ); |
There was a problem hiding this comment.
Time value should be returned, not just logged.
Also if you construct such a long human readable strings (you should remember, that sysfs is not intended for such usage), it make sense to provide time in human-readable form as well instead of raw timestamp.
| return strlen( buf ); | ||
| } | ||
|
|
||
| static ssize_t xxx_store( struct class *class, struct class_attribute *attr, const char *buf, size_t count ) { |
There was a problem hiding this comment.
Redundant interface for this exercise.
| // printk( KERN_INFO "%s\n", buf ); | ||
| xxx_store(x_class, &class_attr_xxx,buf,strlen(buf)+1); | ||
| if (fib_n < 93) fib_n++; | ||
| else fib_n = 0; |
There was a problem hiding this comment.
Good intention to handle overflow at least somehow,
But I believe, the task assumed a bit more than 93 seconds (at least not via magic number).
…quest from user space.
# Conflicts: # lesson-04-memory-management/mm/.gitignore # lesson-04-memory-management/mm/Makefile
# Conflicts: # lesson-05-time-management/xxx_1.c # lesson-05-time-management/xxx_2.c # lesson-05-time-management/xxx_hrtimer.c # lesson-05-time-management/xxx_timer.c
No description provided.