embedded xinu kernel programming
DESCRIPTION
Embedded Xinu Kernel Programming. [email protected] University at Buffalo. Topics. Creating a task/thread Ready/adding to the queue Resched /no rescheduling Semaphores of synchronization and mutual exclusion Memory operation errors including memory leak. Memory leaks etc. - PowerPoint PPT PresentationTRANSCRIPT
![Page 2: Embedded Xinu Kernel Programming](https://reader036.vdocuments.net/reader036/viewer/2022082505/56812c2f550346895d90b3da/html5/thumbnails/2.jpg)
Amrita-UB-MSES-2013-13
2
Topics
Creating a task/threadReady/adding to the queueResched/no reschedulingSemaphores of synchronization and mutual
exclusionMemory operation errors including memory
leak
5/24/2013
![Page 3: Embedded Xinu Kernel Programming](https://reader036.vdocuments.net/reader036/viewer/2022082505/56812c2f550346895d90b3da/html5/thumbnails/3.jpg)
Amrita-UB-MSES-2013-13
3
Memory leaks etc.
See http://www.ibm.com/developerworks/aix/library/au-toughgame/
IBM developer works is good source of valuable information
Good practices while working with small footprint systems
Though there are tools available to detect most of these, it is always good to know the best practices in any technology and field
5/24/2013
![Page 4: Embedded Xinu Kernel Programming](https://reader036.vdocuments.net/reader036/viewer/2022082505/56812c2f550346895d90b3da/html5/thumbnails/4.jpg)
Amrita-UB-MSES-2013-13
4
Known Pitfalls
These are some of the prominent pitfalls while working with memory at low level
Uninitialized memorychar *p = malloc (10); memset(p,’\0’,10);
Memory overwritechar *name = (char *) malloc(11); // Assign some value to name memcpy ( p,name,11);
Memory overeadchar *ptr = (char *)malloc(10); char name[20] ; memcpy ( name,ptr,20);
5/24/2013
![Page 5: Embedded Xinu Kernel Programming](https://reader036.vdocuments.net/reader036/viewer/2022082505/56812c2f550346895d90b3da/html5/thumbnails/5.jpg)
Amrita-UB-MSES-2013-13
5
Known Pitfalls (contd.)
Memory leak: reassignmentchar *memoryArea = malloc(10); char *newArea = malloc(10);memoryArea = newArea;
Memory leak: freeing the parent area firstfree(memoryArea); //wrong//correct method is given belowfree( memoryArea->newArea); free(memoryArea);
5/24/2013
![Page 6: Embedded Xinu Kernel Programming](https://reader036.vdocuments.net/reader036/viewer/2022082505/56812c2f550346895d90b3da/html5/thumbnails/6.jpg)
Amrita-UB-MSES-2013-13
6
Known Pitfalls (contd.)
Improper handling of return functionschar *func ( ) { return malloc(20); // make sure to memset this location to ‘\0’… }
void callingFunc ( ) { func ( ); // Problem lies here }
5/24/2013
![Page 7: Embedded Xinu Kernel Programming](https://reader036.vdocuments.net/reader036/viewer/2022082505/56812c2f550346895d90b3da/html5/thumbnails/7.jpg)
Amrita-UB-MSES-2013-13
7
Summary
5/24/2013
We discussed some things to pay attention to when designing systems at low level and deal with dynamic memory management.
This is especially critical for small embedded systems with limited memory.
Memory leaks are serious problem resulting in dramatic system slow down at runtime.