Today, I wrote the monitoring module framework. The monitoring module design steps are as follows: Create a timer: (used for timing monitoring per module) to create a queue: (for receiving the response message of each module) While (queue )) {Switch (IS_ALL) TIMER: IF (is_all_alive) Send a monitor message to all module ELSE Send a message to the master Other module: This module is alive .....: This module live} Timer {Send timing message to your own module} Then I also write the code of memory management: Design requirements: I can query the application for the current memory (length, type, and type size, and the file name of the application, the number of file names, the number of lines) limit the application length exceeds the maximum length #define num_blocks 128 // Application number #define num_sizes 64 // Application Type #define max_mem_sizes 1024 * 1024 // 1M memory static blockntry blocks [Num_blocks]; static counter counters [num_sizes];
Static void incrementcountforsize (size_t size); static void decrementcountforsize (SIZE_T SIZE);
static long FS_totalAllocated = 0; void * mMallocLineFile (size_t size, int line, char * file) {int i; if ((FS_totalAllocated size)> MAX_MEM_SIZES) return; void * newAllocation = malloc (size);
For (i = 0; i FS_TOTALLOCATED = size; return newAllocation;} void mfree (void * blocktofree) {INT i; for (i = 0; i Free (Blocktofree);} void mdisplaytable (void) {printf ("% s", "/ nsize / tfreq."); for (int i = 0; i