Esempio n. 1
0
/* Use this function to track memory allocation performance.  
 * This function does not depend on your implementation, 
 * but on the functions you wrote above.
 */ 
void print_memory_status()
{
	printf("%d out of %d bytes allocated.\n",mem_allocated(),mem_total());
	printf("%d bytes are free in %d holes; maximum allocatable block is %d bytes.\n",mem_free(),mem_holes(),mem_largest_free());
	printf("Average hole size is %f.\n\n",((float)mem_free())/mem_holes());
}
Esempio n. 2
0
int main(void) {
    cpu_interval = 0;
    int mem_load;
    int display_mode = mode_CPU; 
    char tmp_value[20];
    mem_tot = mem_total()/1024;
    
    lcd_line("    RPi i2c test");
    lcd_line("    Copyright (C)");
    lcd_line("        2013");
    lcd_line("Jesper Stockenstrand");
    usleep(5000000);
    
    for(;;) {
        int cpu_l;
            
        switch (display_mode) {
        
            case mode_CPU:
                cpu_l = cpu_load();
                sprintf(tmp_value,"         %d%%",cpu_l);
                lcd_line("      CPU LOAD  ");
                lcd_line(tmp_value);
                lcd_line("   ");
                lcd_line(">CPU<[MEM][NET][UPT]"); 
                break;
                
            case mode_MEM:
                mem_load = (int)(((double)mem_used()/(double)mem_tot)*100);
                lcd_line("     MEM USAGE      ");
                sprintf(tmp_value,"       %d/%dMb",mem_used(),mem_tot);
                lcd_line(tmp_value);
                sprintf(tmp_value,"         %d%%",mem_load);
                lcd_line(tmp_value);
                lcd_line("[CPU]>MEM<[NET][UPT]");
                break;
                
            case mode_NET:
                lcd_line("    IP ADDRESS      ");
                sprintf(tmp_value,"    %s", net_address());
                lcd_line(tmp_value);
                lcd_line("      ");
                lcd_line("[CPU][MEM]>NET<[UPT]");
                break;
                
            case mode_UPT:
                lcd_line("       UP TIME      ");
                sprintf(tmp_value,"     %d sec",uptime());
                lcd_line(tmp_value);
                lcd_line("     ");
                lcd_line("[CPU][MEM][NET]>UPT<");
                break;
                
            default:
                display_mode = mode_CPU;
                
        }
        
        switch (checkButton()) {
        
            case 1:
                display_mode = mode_CPU;
                break;
                
            case 2:
                display_mode = mode_MEM;
                break;
                
            case 3:
                display_mode = mode_NET;
                break;
            
            case 4:
                display_mode = mode_UPT;
                break;
                
        } 

            
        usleep(10000);
    
    } 
    return(0);
}