static void calculate_oil(t_bunny_pixelarray *pix, t_bunny_pixelarray *save, t_oil *oil) { int width; int height; oil->pos.y = 0; width = pix->clipable.clip_width; height = pix->clipable.clip_height; while (oil->pos.y < height) { oil->pos.x = 0; while (oil->pos.x < width) { init_oil(oil, LEVEL); calculate_avg(pix, oil, oil->pos.x, oil->pos.y); apply_normalize_oil(save, oil, LEVEL); ++(oil->pos.x); } ++(oil->pos.y); } }
void ccp_session::read_alive_response() { int retval; int tmp; //QM int tmp2, tmp3; retval = read_int(&tmp); if (retval == -1) { printf("ccp_session::read_alive_response socket-closed-1\n"); return; } // QM retval = read_int(&tmp2); if (retval == -1) { printf("ccp_session::read_alive_response socket-closed-2\n"); return; } retval = read_int(&tmp3); if (retval == -1) { printf("ccp_session::read_alive_response socket-closed-3\n"); return; } alive_response_received = true; latest_checkpoint = tmp; // QM cpu_utilization = tmp2; idle_time = tmp3; cpuUtil.push_back(cpu_utilization); idleTime.push_back(idle_time); if(cpuUtil.size() > 33) { vector<int>::iterator i; i = cpuUtil.begin(); cpuUtil.erase(i,i+1); } if(idleTime.size() > 33) { vector<int>::iterator i; i = idleTime.begin(); idleTime.erase(i,i+1); } calculate_avg(); /* printf("[%d.%d.%d.%d] Alive resp is (chkpt=%d, util=%d, idle=%d)\n", (ip % 256), ((ip>>8) % 256), ((ip>>16) % 256), ((ip>>24) % 256), latest_checkpoint, cpu_utilization, idle_time);*/ }